Jump to content

Photo

No idea what I'm supposed to be doing with scripts.

zscript help importing

  • Please log in to reply
18 replies to this topic

#16 Evander Berry Wall

Evander Berry Wall

    Newbie

  • Members

Posted 21 February 2016 - 11:03 PM

I'm using Windows 10, home edition. My browser is Opera 35.0. I used the copy to clipboard button. I pasted it into plain old Notepad. 

 

For the record, I put the three scripts I got from here into the txt file when I got working somehow. I have not attempted adding another one since, so there's been no chance yet for the error to repeat itself.



#17 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 23 February 2016 - 04:36 AM

I'm using Windows 10, home edition. My browser is Opera 35.0. I used the copy to clipboard button. I pasted it into plain old Notepad. 
 
For the record, I put the three scripts I got from here into the txt file when I got working somehow. I have not attempted adding another one since, so there's been no chance yet for the error to repeat itself.


I'll need to install Opera, to test this.

Do me a favour...


Load any of the scripts, and click the 'Copy to Clipboard' button. Then respond to this, and paste the clipboard contents between code tags.

Those tags use the following format:

[ code ]
to start the code block...

and
[ /code ]
...to end the code block.
...without the spaces round 'code' and '/code'.

That way, we can see if your clipboard text includes the 8-bit chars that were throwing lexical errors.

I might be able to fix that sort of problem in the lexer, by making it throw a warning, but ignore them when parsing, so that it will compile with that sort of thing, as we will never use any of the upper ASCII chart as legal tokens, or identifiers, or anything of that sort. (They will only ever be legal in 'QUOTEDSTRING' lines; so it's safe to ignore them outside of that type.)

#18 Evander Berry Wall

Evander Berry Wall

    Newbie

  • Members

Posted 24 February 2016 - 01:03 PM

AutoBigEnemy

 

const int BIGENEMY_MISC_ORIGTILE = 0; //Index for NPC`s Misc array for Npc`s real original tile chosen in Enemy Editor
const int BIGENEMY_MISC_OLDX = 1; //Index for NPC`s Misc array for Npc`s X coordinate in previous frame.
const int BIGENEMY_MISC_OLDY = 2; //Index for NPC`s Misc array for Npc`s Y coordinate in previous frame.
const int BIGENEMY_MISC_HALTCOUNTER = 3; //Index for NPC`s Misc array for Npc`s halt counter
 
global script AutoBigEnemy{
void run (){
while (true){
AutoBigEnemy(); //When combining with other global scripts, place this function in main loop before Waitdraw().
Waitdraw();
Waitframe();
}
}
}
 
//Itrates trough all enemies on screen and searches for ones that need to be extended.
void AutoBigEnemy(){
npc big;
for (int i=1; i<= Screen->NumNPCs(); i++){
big = Screen->LoadNPC(i);
SetBigEnemySettings(big);
}
}
 
// Main BigEnemy definition table. When adding more enemies that need to be bigger, repeat
// "BigEnemy" function for each extend enemy with the following arguments:
// 1. "n". it`s a pointer to affected enemy. Don`t change.
// 2. Enemy ID of affected enemy.
// 3. Draw X offset
// 4. Draw Y offset
// 5. Hitbox X offset
// 5. Hitbox Y offset
// 6. Hitbox width, in pixels.
// 7. Hitbox height, in pixels.
// 8. TileWidth, in tiles.
// 9. TileHeight, in tiles.
// 10. Custom animation flags.
 
void SetBigEnemySettings( npc n){
BigEnemy(n, 44, 0,-16,0,-16,16,32,1,2,0); //Rope L1 becomes 1x2 sized.
BigEnemy(n, 29, 0,-16,0,-16,16,32,1,2,0); //Moblin L2 becomes 1x2 sized.
BigEnemy(n, 79, 0,-16,0,-16,16,32,1,2,0); //Rope L1 becomes 1x2 sized.
BigEnemy(n, 120, 0,-16,0,-16,16,32,1,2,0); //Stalfos L3 becomes 1x2 sized.
BigEnemy(n, 39, -16,-16,-16,-16,48,16,3,2,0); //Giant Vampire Bat.
BigEnemy(n, 183, 0,-32,0,-32,16,48,1,3,0);//Monster Frankenstein
//BigEnemy(n, 188, -32,-48,-32,-48,64,64,4,4,9);//Test Giant Goomba
 
}
 
 
//Set BigEnemy parameters if enemy is not extended yet. Or run custom animation function every frame, if it is.
void BigEnemy ( npc k, int id, int drawxoffset, int drawyoffset, int hitxoffset, int hityoffset , int hitx, int hity, int tilex, int tiley, int animation){
if (!(k->ID == id)) return;
if (k->Extend == 3){
BigEnemyCustomAnimation(k, animation);
return;
}
else k->Misc[BIGENEMY_MISC_ORIGTILE] = k->OriginalTile;
k->DrawXOffset = drawxoffset;
k->DrawYOffset = drawyoffset;
k->HitXOffset = hitxoffset;
k->HitYOffset = hityoffset;
k->HitWidth = hitx;
k->HitHeight = hity;
k->Extend = 3;
k->TileWidth = tilex;
k->TileHeight = tiley;
}
 
//Used to determine animation direction for facing Link
int FacingLink (npc b){
if (IsSideview()){
if (b->X > CenterLinkX()) return DIR_LEFT;
else return DIR_RIGHT;
}
else{
int LX = CenterLinkX();
int LY = CenterLinkY();
int BX = CenterX(b);
int BY = CenterY(b);
int vector = Angle(LX,LY,BX,BY);
if (Abs(vector)>135){
return DIR_RIGHT;
}
else if (Abs(vector)>45){
if (vector > 0) return DIR_UP;
else return DIR_DOWN;
}
else return DIR_LEFT;
}
}
 
//Defines custom animation. Call this function every frame to prevent glitching tiles.
void BigEnemyCustomAnimation(npc b, int animflags){
if ((animflags&1) == 0) return; //Custom animation was not enabled.
if (b->Attributes[11] > 0) return; //Stay away from ghosted enemies.
int OrigTileOffset = b->TileHeight * 20; //Find incremental for BigEnemy`s OriginalTile offset.
float HaltThreshold = 100/(b->Step); //Find out the threshold used to detect whether the enemy is halting.
if (HaltThreshold==0) HaltThreshold = 1; //Set the threshold for fast enemies.
int andir=0; //Direction the enemy is facing. Not the npc->Dir!
     int HaltTileOffset=0; //Tile offset used for "firing"animation.
     int OrigTile = b->Misc[BIGENEMY_MISC_ORIGTILE]; //The actual original tile of enemy.
     // /!&#092; Must be recorded on enemy initialization.
     int OldX = b->Misc[BIGENEMY_MISC_OLDX]; //Enemy`s X coordinate on previous frame.
     int OldY = b->Misc[BIGENEMY_MISC_OLDY]; //Enemy`s Y coordinate on previous frame.
     if ((animflags&4)>0) andir = FacingLink(b); //Always face Link if approriate flag is used.
     else andir = b->Dir; //Otherwise, use npc->Dir.
     if ((animflags&8)>0){ //Firing animation is used?
     if ((b->X == OldX)&&(b->Y==OldY)&&(OldX==GridX(OldX))&&(OldY==GridY(OldY))){ //Main halting detection check. Not perfect. :-(
       b->Misc[BIGENEMY_MISC_HALTCOUNTER]++; //Update halt counter.
       if (b->Misc[BIGENEMY_MISC_HALTCOUNTER]>HaltThreshold){
      if ((animflags&2)>0) HaltTileOffset=  OrigTileOffset*8; //Check diagonal allowance flag.
      else HaltTileOffset=  OrigTileOffset*4; //And set tile offset accordingly.
      if (b->Misc[BIGENEMY_MISC_HALTCOUNTER] >= 24) HaltTileOffset *= 2; 
       }
}
     else b->Misc[BIGENEMY_MISC_HALTCOUNTER] = 0; //Reset halt counter.
     }
     b->Misc[BIGENEMY_MISC_OLDX] = b->X; //Update old coordinates.
     b->Misc[BIGENEMY_MISC_OLDY] = b->Y;
     b->OriginalTile = OrigTile + HaltTileOffset+ (OrigTileOffset * andir); //And, finally, set npc`s Original Tile.
     //debugValue(1, (b->Misc[BIGENEMY_MISC_HALTCOUNTER]));
     //debugValue(2, HaltThreshold);
}

 



#19 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 24 February 2016 - 01:10 PM

Now, this is the problem with Windows 8/10. They have a bunch of invisible characters that are impossible to see unless you're on something like XP or Linux. I once got stumped from a lexical error that had popped up in my program, before realizing that it was a couple of invisible characters that had somehow managed to get in. A good way to fix this would probably be deleting the entire line and retyping it. However, lexical errors don't halt zscript for some reason, which means that they aren't much of a problem, and can usually be ignored.





Also tagged with one or more of these keywords: zscript, help, importing

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users