Post new topic    
Slime Knight
Send private message
Spin Box code crashes game 
 PostFri Jan 14, 2011 5:50 pm
Send private message Reply with quote
So I'm coding a spin box to use in a sound test script, and whenever I test the script, I get a visit from Dr. Watson32 ("GAME.EXE has encountered a problem and needs to close.")

Here's the script:
Code:
script,spin box,begin
   suspend player
   variable(holder, sl, choice)
   holder := create rect(50,40,0)
   set horiz align(holder, edge:center)
   set vert align(holder, edge:center)
   set horiz anchor(holder, edge:center)
   set vert anchor(holder, edge:center)
   sl := create text
   set horiz align(sl, edge:center)
   set vert align(sl, edge:center)
   set horiz anchor(sl, edge:center)
   set vert anchor(sl, edge:center)
   while(not(keyispressed(key:Esc))) do(
      if(choice << 10) then ($31 := "00") else (if(choice << 100) then ($31:="0"))
      append number(31, choice)
      set slice text(sl,31)
   )
   free slice(holder)
   resume player
end
Liquid Metal King Slime
Send private message
 
 PostFri Jan 14, 2011 6:44 pm
Send private message Reply with quote
That while loop looks infinite to me. If there is no wait of any kind in the while loop, it never gets a chance to poll the keyboard, so it never gets a chance to read any new ESC keypresses.

Although I would expect that to cause game.exe to stop responding, not to crash.

Also, "append number" adds the number to the end of the string, so you should clear the string first. Actually, maybe it is crashing because the infinite loop makes the string incredibly long very fast, and it overflows some memory or something?
Liquid Metal King Slime
Send private message
 
 PostFri Jan 14, 2011 9:47 pm
Send private message Reply with quote
You're going to want to use variable commands instead of string commands I think.
a command of:

choice:= choice+31

instead of

append number(31, choice)

would do what I think you were trying to do.
Liquid Metal King Slime
Send private message
 
 PostSat Jan 15, 2011 3:33 am
Send private message Reply with quote
31 is the string ID number
Liquid Metal King Slime
Send private message
 
 PostSat Jan 15, 2011 5:35 am
Send private message Reply with quote
d'oh, yea I misread that. nvm
Slime Knight
Send private message
 
 PostWed Jan 26, 2011 10:15 pm
Send private message Reply with quote
So an addition of a wait is needed? Sounds easy enough. Now to figure out how to change the value...
Display posts from previous: