Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Condensed Endless Loop... (https://forums.graalonline.com/forums/showthread.php?t=41056)

Googi 12-08-2002 10:32 PM

Condensed Endless Loop...
 
NPC Code:

if (timeout){
if (i=17){
if (this.key5=true){
this.key5=false;
i=16;
timeout=1;
}
else{
this.key5=false;
i=16;
timeout=1;
}
}
}



Yes, I have tried changing i=17 to i==17 but it didn't work :\.

Ningnong 12-09-2002 12:16 AM

yes, well keep the i==17 in because thats the correct format. At least thats one problem solved. Also, you have:

if (this.key5=true) it should be if (this.key5==true)

like Falcor said, = is an assignment, == means equal to

eg
this.var = 5; // Makes this.var equal to 5

Also, heres an example of a very simple timeout loop that is stopped:

NPC Code:

//#CLIENTSIDE
if (playerenters){
this.time = 100;
this.on = 1;
timeout = .05;
}

if (timeout && this.on == 1){
this.time --;
if (this.time<=0){
this.on = 0;
}
timeout = .05;
}



I suggest using :

if (timeout && i == 17) { //thingys; }

-Ning

Python523 12-09-2002 01:11 AM

last time i checked graal checks = and == in if/while/for statements as being equals, i always use == but i think = works as well, even though it is technically incorrect

Ningnong 12-09-2002 01:48 AM

kool :P

Googi 12-09-2002 02:11 AM

NPC Code:

if (timeout&&i==17){
if (this.key5==true){
this.key5=false;
timeout=1;
i=16;
}
else{
this.key5=false;
timeout=1;
i=16;
}
}



:\, that's the script now. It still doesn't work though...

Ningnong 12-09-2002 02:39 AM

In the timeout loop, you set i to 16. SO the timeout loop could never start...I may be reading it wrong, but at a glance thats how it looks

w00t im a member now :D (not junior) <3

CheeToS2 12-09-2002 03:01 AM

it says &&i==17, meaning it has to be 17 in the first place, so you have to set that somewhere
(dunno if thats what ningnong meant or not, sorry if it was :X)

Googi 12-09-2002 03:10 AM

Quote:

Originally posted by CheeToS2
it says &&i==17, meaning it has to be 17 in the first place, so you have to set that somewhere
(dunno if thats what ningnong meant or not, sorry if it was :X)

Starting the loop isn't the problem. Since that isn't the whole script, the problem is that the loop won't end.

Ningnong 12-09-2002 03:25 AM

hmm, why do you have

if (this.key5 == true) this.key5 = false ?

since the script is confusing, maybe you should explain in english what your trying to do, then I could whip you up an alternate script :P

Googi 12-09-2002 04:12 AM

Okay, at the time that this part of the script is executed...

this.key5 could be true or false.
i=17

Falcor 12-09-2002 04:34 AM

the timeout stops for me. *shrugs*

Googi 12-09-2002 05:35 AM

Falados, I'll send you the whole script whenever you get on AIM.

Loriel 12-09-2002 06:39 AM

If you need a variable to be stored longer than the current "frame", you should use this. variables, because other scripts might use the variable as well and therefore mess up your script.

Googi 12-09-2002 07:49 AM

Quote:

Originally posted by Loriel
If you need a variable to be stored longer than the current "frame", you should use this. variables, because other scripts might use the variable as well and therefore mess up your script.
I tried that before using i.

osrs 12-09-2002 10:40 PM

Quote:

Originally posted by Python523
last time i checked graal checks = and == in if/while/for statements as being equals, i always use == but i think = works as well, even though it is technically incorrect
I always use '==',works better for me.


All times are GMT +2. The time now is 03:55 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.