 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Wed Nov 17, 2004 11:26 am Post subject: Script freezing; any suggestions? |
|
|
I have a script that I want to run continuously in the background (I accomplish this with a 'while' loop) but right now it is freezing the game. I will try to explain what the script does.
The script enters a 'while' loop checking if the current map is 42 (which it will be for as long as this part of the game lasts, and I DO want this script running that entire time). Inside the 'while' loop are a whole lot of 'if' checks. However, there is not a single 'wait' command of any kind within the 'while' loop. Nevertheless, when I run game.exe, the script freezes the game up.
Script-debug mode (not detailed) gives that while the game is frozen, the command kind is 6 (built-in function), the command ID is 1 (wait) and the state is 3 (returning from command). I'm not sure exactly what these mean. In detailed mode, these numbers go all over the place, but especially the command ID which runs over all sorts of huge negative numbers. I don't know what this means. Does anyone have any ideas? Oh, the blue bar is not very high, and the pink/orange one is barely there at all.
PS: Just in case it helps, I will list all of the types of commands I use in the 'while' loop:
setting variables "X:=..."
heroX, heroY, npcX, npcY, npcreference functions
npcdirection, herodirection, setnpcdirection, setherodirection functions
random, readmapblock, readglobal, writeglobal functions
'if' and 'for' commands
the following math operators: '=='; '<>'; 'and'; 'or'; '*'; '+'; '--'; '>>'; 'mod'
parantheses, 'begin'/'end', 'then', 'do', 'else' |
|
Back to top |
|
 |
jabbercat Composer

Joined: 04 Sep 2003 Posts: 823 Location: Oxford
|
Posted: Wed Nov 17, 2004 11:31 am Post subject: |
|
|
stick a wait(1) in there somewhere and see if it sorts it. (try the end of the while loop) _________________ Moogle no longer owes prizes. |
|
Back to top |
|
 |
Mr B
Joined: 20 Mar 2003 Posts: 382
|
Posted: Wed Nov 17, 2004 11:42 am Post subject: |
|
|
How is the script called?
Because if it is called as a "load-map" script, it WILL freeze and you will get a pileup of multiple instances.
What does the script snooper debug key tell you? (I think it's F10) |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Wed Nov 17, 2004 11:45 am Post subject: |
|
|
Yeah, that fixed it. Thanks a lot! I'm not sure, but I guess that a script needs a wait command in order to allow input from the keyboard to come through? |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Wed Nov 17, 2004 3:27 pm Post subject: |
|
|
yes, you need the script to wait(1) before it should check again if the player has pressed anything on the keyboard that is valid.
if you don't put a wait(1) it'll keep checking continuously without waiting. _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
*Worthy* Critical Thinker

Joined: 11 Aug 2003 Posts: 186
|
Posted: Sun Nov 28, 2004 7:11 am Post subject: |
|
|
"Wait" commands are fun. Actually, you don't need it to wait to see if the player has pressed anything. Technically, if the player did press a key while the script was "waiting," nothing would happen. Fortunately, "wait" only waits like 1/15th of a second, and it's pretty hard to press a key for only that short of time.
However, you need the "wait" to allow the script to cool down, otherwise it will overwork itself and freeze up. In every "while" statement, you should have at least one "wait" thrown in there (usually at the end).
~Worthy _________________ You can do whatever you want...but prison is full of people who make bad decisions. |
|
Back to top |
|
 |
|
|
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
|