If you are using a Call Script event command for triggering the script then you use a variant of what Sheol made:
class MyObject
def self.run(frames_to_wait)
@@wait_time = frames_to_wait if @@wait_time.nil?
if @@wait_time > 0
@@wait_time -= 1
return false #return FalseClass if you are using SDK 2.4+
end
# Your code
#...
# Set @@wait_time to nil so the process can be repeated
@@wait_time = nil
# Continue event process
return true
end
end
Then just use this script call:
Note that this will not work for SDK 2.3 and below.
There are more ways of doing what you want to achieve. My way will not work if you want multiply events to run
MyObject.run at the same time.
Choose which version suits you best.
*hugs*
- Zeriab