Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Timers and map steps question

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
chronoboy
Into the past with a splash




Joined: 04 Jun 2010
Posts: 162
Location: Canada

PostPosted: Wed Oct 13, 2010 1:03 pm    Post subject: Timers and map steps question Reply with quote

Say I have a timer and also use map steps to check for triggers.

If a timer is triggered and does a routine with a few waits in it, will the map steps still run when the player is moving during the timer script activation? How would one then immediately stop the timer script inside the map steps script?

I am not using any suspend player commands in any of these scripts.

Would this work:
Code:
plotscript, timer script, begin
  For, begin
    Do this...
    wait (1)
    if (timer end trigger == 1) then (exit script)
    Do that
  end
end

plotscript, map steps script, begin
  ... some nifty if statement to catch a special trigger ...
    stop timer (0)
    timer end trigger := 1
  end that if statement here.
end


Also, when a timer ends, does it restart itself again, or does one need to use the set timer with a new count?

What I am thinking happens, is at every game tick, every running script get a slice of CPU to run until that script has it's wait command. Is this what happens, or am I just being hopeful?

If concurrent scripts are done, is it possible to create a thread command which starts a new script, but does not pause the current one? Or can one use set timer as a wrapper?
_________________
Current project: Chronoboy Adventures

Website: http://www.chronoboy.com/
Back to top
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Oct 14, 2010 2:57 am    Post subject: Reply with quote

Quote:
If a timer is triggered and does a routine with a few waits in it, will the map steps still run when the player is moving during the timer script activation?


Yes, all script triggers continue to be checked. If any scripts are triggered, they are put on top of the script stack, pausing the timer-triggered script (see below).

If you want one of these scripts to cause a script that it's paused to exit, then your script does exactly the right thing: checking a variable after a wait, because that's where the timer script will resume from.

Quote:
Also, when a timer ends, does it restart itself again, or does one need to use the set timer with a new count?


Timers do not automatically restart, but they remember their settings. So to restart a timer with the same speed, trigger, string, and options you just need to set a new length/"count":
set timer (0, 10)

Quote:
What I am thinking happens, is at every game tick, every running script get a slice of CPU to run until that script has it's wait command. Is this what happens, or am I just being hopeful?


I'm afraid not. Scripts stack on top of each other. Only the topmost (last triggered) script runs. Once that script waits, no other script is run. Only if it exits does some other script get a chance.

You can use the script debugger to see this in action: press F10 once or twice. The script debugger is awfully difficult to use, but I have a clean up in the works (should finish it this weekend). It has an F1 help screen though.

Quote:
If concurrent scripts are done, is it possible to create a thread command which starts a new script, but does not pause the current one?

This is coming in the new script interpreter!
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group