Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: 2ma2 on Fri 13/06/2003 02:04:53

Title: Find fatal fault (a script that freezes my comp)
Post by: 2ma2 on Fri 13/06/2003 02:04:53
Yesh, I've encountered something mighty peculiar. It aint even the usual everlasting wait-loop cause I can't even break my way out of the game using good ol' lsl tricks (alt-x)

When running this, my whole comp freezes. Not even the gd forsaken ctrl-alt-del makes a difference. What the hell is wrong with this script?!

if (Mode()==4) { //this is just a function returning a value
MoveCharacterBlocking(EGO,192,145,0);SetObjectBaseline(3,character[EGO].y-1);
MoveCharacterDirect(EGO,192,136); Wait(10);
Anim(EGO,2,7,7,1,0);
//all above I know is working as it should. Anim() is my own function to ease the scripting load

while (GetObjectX(3) > 82) {
 if (character[0].frame == 2 || character[0].frame == 5) {SetObjectPosition(3,GetObjectX(3)-2,GetObjectY(3));character[0].x-=2;}
 }
//This should be the main problem. It freezes directly, the animation doesn't even start. I've tested removing this and

 character[0].animating=0;
//could this cause it? So it's stuck in the while loop? It should not, it won't execute until the while-loop is finished! Also, if so, I should be able to break myself out, not hitting the reset button on my comp.

MoveCharacterBlocking(EGO,character[0].x,150,1);Talk(EGO,"Yada yada blah blah");old=2;sds=0;MergeObject(2);MergeObject(3);
}
//old and sds are local variables, ignore them. Talk is another function to ease the script load

HEEEEEEELP!  ???
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Gilbert on Fri 13/06/2003 08:00:38
I think it is quite obvious. Right?

while (GetObjectX(3) > 82) {
 if (character[ 0 ].frame == 2 || character[ 0 ].frame == 5) {SetObjectPosition(3,GetObjectX(3)-2,GetObjectY(3));character[ 0 ].x-=2;}
Wait(1)

 }
//This should be the main problem. It freezes directly, the animation doesn't even start. I've tested removing this and
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Pumaman on Fri 13/06/2003 13:26:45

And also:

Quote from: 2ma2 on Fri 13/06/2003 02:04:53
while (GetObjectX(3) > 82) {
 if (character[0].frame == 2 || character[0].frame == 5) {
   SetObjectPosition(3,GetObjectX(3)-2,GetObjectY(3));character[0].x-=2;
 }
}

What happens if the frame is not 2 or 5? It will never move, and thus the loop will never end.
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: 2ma2 on Fri 13/06/2003 19:41:37
Well the idea was that it should react and move when the frames are 2 and 5. This will happen repeadatly since the animation starting above with Anim() is looping but not blocking. Therefor, the wait was excluded.

I presume this simply won't work then. Any ideas on how to do something equalent, ie. it moving when the appropriate frame is set. The only thing I can think of is excaching if (character[EGO].frame == 2 || character[EGO].frame == 5)  for Wait(character anim speed + delay within the animation), and this feels mighty dodgy.
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Scorpiorus on Fri 13/06/2003 20:56:44
Hmm, just can't understand why don't you want to use a Wait(1) thing? The script is blocked in any case until the object will have reached it's destination. Wait(1) updates the state and makes sure that the object was moved.

If it's not a game secret maybe you could provide a little more info about what you want to achieve. :P

-Cheers
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: 2ma2 on Sat 14/06/2003 01:11:42
'tis a game secret, alas :)

Nevertheless, I can't understand why the whole thing freezes. I should be able to break myself out of it, no?

Gah, I'll try using Wait(1) and a bunch of other things. Wish me luck. If I succed, this thread will be abandoned, otherwise I'll  be back to whine even more ;)
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Snake on Sat 14/06/2003 05:17:20
Good luck! Hope you figure this damned problem out, and finish your game at one point ;)


--Snake
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Scorpiorus on Sat 14/06/2003 13:13:10
QuoteNevertheless, I can't understand why the whole thing freezes.
It freezes because while (GetObjectX(3) > 82) loop never ends. As there is no Wait(1) the object is not moved actually and thereby GetObjectX(3) > 82 is always true.

QuoteGah, I'll try using Wait(1) and a bunch of other things. Wish me luck. If I succed, this thread will be abandoned, otherwise I'll be back to whine even more :)
Yeah, we wish you best luck! But no matter what result is let us know so we woundn't worry if it's fine or could help you to go through if it's not. :)

-Cheers
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: Pumaman on Sat 14/06/2003 15:51:30
An important point that you have to remember is that the screen is never updated unless  Wait(1);  is called. Though you start the animation, it won't actually happen until your script ends or you call a blocking function (eg. Wait). Thus, putting that in your loop will ensure that the animation happens in the background.
Title: Re:Find fatal fault (a script that freezes my comp)
Post by: 2ma2 on Sun 15/06/2003 00:54:26
CJ: Aaaaaaah, it never updates.. *enlightened* Cheers... :D