Find fatal fault (a script that freezes my comp)

Started by 2ma2, Fri 13/06/2003 02:04:53

Previous topic - Next topic

2ma2

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!  ???

Gilbert

#1
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

Pumaman


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.

2ma2

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.

Scorpiorus

#4
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

2ma2

'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 ;)

Snake

Good luck! Hope you figure this damned problem out, and finish your game at one point ;)


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Scorpiorus

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

Pumaman

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.

2ma2

CJ: Aaaaaaah, it never updates.. *enlightened* Cheers... :D

SMF spam blocked by CleanTalk