
02-08-2002, 08:27 AM
|
|
Senior Member, Anti-Spam
|
Join Date: Mar 2001
Location: Missouri
Posts: 196
|
|
I'm not sure, but I think timeout is local, the only thing I know about timeouts on this level is what is in the npcprogrammng.rtf
Quote:
5.4. timeouts/ sleep command
To do animations or movements, you can use the 'timeout' variable.
If you set the timeout to 1sec, then after one second a 'timeout' event occurs and the npcs action script will be called with the flag 'timout' set. To show how it works, here a little example:
if (playerenters) timeout = 1;
if (timeout) {
x += 0.5;
timeout = 1;
}
If an npc has that script, then every second it moves 0.5 fields to the right:
1. When the player enters the level, the script will be called with the 'playerenters' flag set
2. So the timeout will be set to 1 (1 second)
3. The game counts the timeout down to 0
4. After 1 second the script will be called again, this time with the 'timeout' flag set
5. So the x variable will be increased and the timeout will be set again to 1
6. continue with step 3.
If you don't set the timeout again, then the timeout event will not occur again.
You can do the same stuff with the ‘sleep’ command:
if (playerenters) {
while (1==1) {
sleep 1;
x += 0.5;
}
}
When doing ‘sleep’, then the script execution will be paused for 1 second. So in this example the npc will forever do a while loop, in this loop the npc ‘sleeps’ 1 second, then moves to the right, then sleeps 1 second, then moves to the right and so on. Internernally the ‘sleep’ command only uses the ‘timeout’ variable: it sets the timeout variable, then when the ‘timeout’ event occurs the script execution will be started one line behind the ‘sleep’ command. If you change the timeout variable while doing ‘sleep’ (e.g. when another event occurs), then the next timeout event will start with the first script line, so be patient with changing ‘timeout’ while another animation loop may be running.
5.5. timeouts in online mode
In the online mode normally only the player who entered the level first (of all players in the current room) is getting timeout events. With ‘timereverywhere’ you can enable timeout events for all players: it enables the current player to get timeout events, so you should do it while processing the ‘playerenters’ event.
But if you want to do animations or movements you should only change the npc properties on one machine, otherwise you produce too much network traffic and strange npc movements. So check if ‘isleader’ is true. That flag is only true when the player is the one who entered the level first and would always get timeout events.
|
 |
__________________
Lomgren - devoted to classic, even though I may be gone for months on end
|
|
|
|