Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   ...stumped... (https://forums.graalonline.com/forums/showthread.php?t=20663)

BlKnight 01-08-2002 08:15 AM

...stumped...
 
I think its a glitch with graal now, but look. I have this loop, when I use variables it works perfect, but when I use strings (and I have to use strings because regular variables will go to 0 when you leave levels) the while loop doesn't work. Heh, it may be a n00b question, but I don't care. Here it is:

while (!strequals(#v(this.on),#s(mapf))) {
this.on=strtofloat(#s(mapf));
}

Heh...I'm not going to show the whole script because of the genius calulations and script...but anywho go ahead and make fun of me for not knowing how to fix this simple problem -_-. Tell me how to fix it first though ;)

BlKnight 01-08-2002 11:05 AM

Heh forgot to make that blue...

LiquidIce00 01-08-2002 12:31 PM

if the mapf or whatever is a non-numerical string ur code wont work since vars are numerical..
else u can just use what ur using but switch the 2 and dont use #s()

BlKnight 01-08-2002 02:27 PM

Quote:

Originally posted by LiquidIce00
if the mapf or whatever is a non-numerical string ur code wont work since vars are numerical..
else u can just use what ur using but switch the 2 and dont use #s()


The only reason I'm using a string is because normal variables are reset when changing levels. Basicly I have a key-combo NPC, this checks which keys are pressed, what order they are pressed, and how long they are pressed. Then you press A, then D it sets a string called mapf, which is basicly on or not. But, for some reason the while loop isn't working, and I can't use timeout for a few reasons.

Saga2001 01-08-2002 04:17 PM

i think what you should do, is...

NPC Code:

this.uther = strtofloat(#s(mapf));
while (this.on!=this.uther) {
this.on=strtofloat(#s(mapf));
}



simple fix...right? for some reason, if you did this:
NPC Code:

while (this.on!=strtofloat(#s(mapf))) {
this.on=strtofloat(#s(mapf));
}



it wouldn't work, i think because in order to test something, it has to be a 1 or 0 not a string, strpings always equal 0. i learned that when i jailed every player on doomsday with my jailing system...bad news bear...

Saga2001 01-08-2002 04:18 PM

299

Saga2001 01-08-2002 04:20 PM

300

sorry, had to post 300 so i could go to bed....thanks...

mhermher 01-08-2002 06:26 PM

Re: ...stumped...
 
Quote:

Originally posted by BlKnight
I think its a glitch with graal now, but look. I have this loop, when I use variables it works perfect, but when I use strings (and I have to use strings because regular variables will go to 0 when you leave levels) the while loop doesn't work. Heh, it may be a n00b question, but I don't care. Here it is:

while (!strequals(#v(this.on),#s(mapf))) {
this.on=strtofloat(#s(mapf));
}

Heh...I'm not going to show the whole script because of the genius calulations and script...but anywho go ahead and make fun of me for not knowing how to fix this simple problem -_-. Tell me how to fix it first though ;)

I think u have to change the this.on=strtofloat(#s(mapf));
to
setstring this.on,strtofloat(#s(mapf));

mhermher 01-08-2002 06:28 PM

Re: Re: ...stumped...
 
Quote:

Originally posted by mhermher


I think u have to change the this.on=strtofloat(#s(mapf));
to
setstring this.on,strtofloat(#s(mapf));


I hope it work:spam:

Xaviar 01-08-2002 11:26 PM

Wait, so why a while? It'll only run once anyways, so just use an if..

BlKnight 01-09-2002 06:15 AM

Quote:

Originally posted by Xaviar
Wait, so why a while? It'll only run once anyways, so just use an if..

What do you mean only once? If's run only once or if in a loop, Whiles run as long as the flag=true.

grim_squeaker_x 01-09-2002 06:36 PM

Re: ...stumped...
 
Quote:

Originally posted by BlKnight
I think its a glitch with graal now, but look. I have this loop, when I use variables it works perfect, but when I use strings (and I have to use strings because regular variables will go to 0 when you leave levels) the while loop doesn't work. Heh, it may be a n00b question, but I don't care. Here it is:

while (!strequals(#v(this.on),#s(mapf))) {
this.on=strtofloat(#s(mapf));
}

Heh...I'm not going to show the whole script because of the genius calulations and script...but anywho go ahead and make fun of me for not knowing how to fix this simple problem -_-. Tell me how to fix it first though ;)

while's which have run once and have no reason to run again (E.G. no "trigger" flag like timeout), won't run again. Putting it in a timeout loop will probably fix your problem.

btedji 01-09-2002 10:14 PM

Try using #v also it may help I dont know why

Xaviar 01-09-2002 11:12 PM

Quote:

Originally posted by BlKnight



What do you mean only once? If's run only once or if in a loop, Whiles run as long as the flag=true.

It'll only run once because you're making the condition false inside the loop, as soon as it runs:

while (!strequals(#v(this.on),#s(mapf))) {
this.on=strtofloat(#s(mapf));
}

after it runs once, this.on gets the value of mapf, and !strequals(#v(this.on),#s(mapf)) becomes false

BlKnight 01-10-2002 07:00 AM

But since the value of mapf changes, it becomes true again, in which case the while loop SHOULD continue.

grim_squeaker_x 01-10-2002 07:17 PM

Quote:

Originally posted by BlKnight
But since the value of mapf changes, it becomes true again, in which case the while loop SHOULD continue.
The thing is that GraalScript is the only programming language in which that isn't the case.

BlKnight 01-10-2002 09:21 PM

Quote:

Originally posted by grim_squeaker_x
The thing is that GraalScript is the only programming language in which that isn't the case.
=/ I think I know why it works with weaponfired and while(this.on=>0)...the weaponfired runs it through again, like playerenters would. Which would mean they need something to get it going...so thats all I need to figure out, anything other then timeout.

Xaviar 01-10-2002 11:10 PM

Quote:

Originally posted by BlKnight


=/ I think I know why it works with weaponfired and while(this.on=>0)...the weaponfired runs it through again, like playerenters would. Which would mean they need something to get it going...so thats all I need to figure out, anything other then timeout.

Last I knew, anything like that, playerenters, weaponfired, etc, will rerun the entire script...But why can't you use timeout?


All times are GMT +2. The time now is 04:24 AM.

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