PDA

View Full Version : User-Defined Delays?



SpacemanDan
05-22-2008, 08:04 PM
I've been working on a script for the past while. I stopped in hope that I would think of a way to do this, but no dice.
What I need is a way to make the script delay before it loops again, and allow one of the arguments being set-up so that's the delay time. I've tried putting variables inside the waitframe() but it forever gives me errors. (I'm using 796 at the moment, if that has anything to do with it.)

jman2050
05-22-2008, 10:12 PM
for(int counter=0; counter<4; counter++)
{
Waitframe();
}

?

Gleeok
05-22-2008, 11:52 PM
or Waitframes(n); where n is the frames to wait, will work fine. And if you only want it to wait 60 frames every 10 seconds then something like;

if (delay>0)delay--;
else{Waitframes(60); delay=600;}

would be easiest.

Joe123
05-23-2008, 05:01 AM
ffc script customdelay{
void run(int delay){
while(true){
//code goes here
Waitframes(delay);
}
}
}

Gleeok
05-23-2008, 06:30 PM
How many scripters does it take to screw in a light bulb?


.....







.....







...well I can't think of a good punchline, but something referring to increment and decrement is probably gold.

ScaryBinary
05-23-2008, 08:29 PM
How many scripters does it take to screw in a light bulb?

Five: One to screw in the lightbulb, and four to request that Link->Screw be implemented in the next build....:D

-------
From the compiler:
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
Pass 4: Type-checking/Completing function symbol tables/Constant folding
tmp, line 3: Error T29: That pointer type does not have a variable Screw.
-------

Joe123
05-23-2008, 08:34 PM
3 apparently Gleeok =P

It's better to get 3 help than no help =P

SpacemanDan
05-26-2008, 05:54 PM
I've tried the whole waitframe(n) thingie, but it never seems to work. (Maybe I miss-typed it or something, I'll try it again.) Thanks for the help everyone! :D

Joe123
05-26-2008, 07:14 PM
Make sure you have
import "std.zh" at the top of your script file, else it won't work.

Also, caplital 'W' for Waitframe();.

And for Waitframes(n);.

ScaryBinary
05-26-2008, 07:56 PM
Also note that Waitframe() and Waitframes(int frames) won't work in item scripts.

Waitframe() waits a single frame and does not require any argument. Waitframes(int frames) waits the specified number of frames. Joe123's example above is a good starting point for what you want to do, as it allows you to pass in the number of frames to delay (set this up using the Arguments tab in the Freeform Combo editor, assuming you're attaching this script to a freeform combo).

The following Wiki articles might be of use:
Waitframe() (http://www.shardstorm.com/ZCwiki/Global_functions_%28ZScript%29#void_Waitframe.28.2 9)
Waitframes() (http://www.shardstorm.com/ZCwiki/Global_functions_%28ZScript%29#void_Waitframes.28i nt_j.29)
Infinite Loops and Waitframe (http://www.shardstorm.com/ZCwiki/While_loop#The_Deliberately_Infinite_Loop)
The run() function (http://www.shardstorm.com/ZCwiki/Run%28%29)
Assigning scripts to items and ffcs (http://www.shardstorm.com/ZCwiki/Assigning_scripts_%28ZScript%29)
Script arguments for Freeform Combos (http://www.shardstorm.com/ZCwiki/FFC#Arguments)