Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Why so laggy? (https://forums.graalonline.com/forums/showthread.php?t=24480)

relenakat 02-24-2002 01:43 PM

Why so laggy?
 
This is sorta jsut a simple script but what I'm wondering is why is it so laggy?

NPC Code:

}
if (created||playerenters) {
setcharprop #3,head5.gif;
set O.o;
}
while (O.o&&this.O.o<=20){
npcs[0].y=npcs[0].y-.5;
sleep .3;
this.O.o = this.O.o+1;
setcharani walk,;
dir = 0;
}
while (O.o&&this.O.o<=40){
npcs[0].x=npcs[0].x+.5;
sleep .1;
this.O.o = this.O.o+1;
dir = 3;
}
while(this.O.o==41){
setcharani idle,;
message This is *blank*'s room;
}


Faheria_GP2 02-24-2002 01:47 PM

Re: Why so laggy?
 
Quote:

Originally posted by relenakat
This is sorta jsut a simple script but what I'm wondering is why is it so laggy?

NPC Code:

}
if (created||playerenters) {
setcharprop #3,head5.gif;
set O.o;
}
while (O.o&&this.O.o<=20){
npcs[0].y=npcs[0].y-.5;
sleep .3;
this.O.o = this.O.o+1;
setcharani walk,;
dir = 0;
}
while (O.o&&this.O.o<=40){
npcs[0].x=npcs[0].x+.5;
sleep .1;
this.O.o = this.O.o+1;
dir = 3;
}
while(this.O.o==41){
setcharani idle,;
message This is *blank*'s room;
}


your "whiles" have no sleep

relenakat 02-24-2002 01:52 PM

Err sorry I guess I was jsut to lazy to press the style button but it might be the sleeps I'll go check that and thanks! :)

Wow it was that!I guess I learned something else about loops that I hadn't run into.

Faheria_GP2 02-24-2002 02:09 PM

there will be future issues with that script which I am too lazy to address

btedji 02-25-2002 10:08 PM

Loops so many loops *gets dizzy*

Admins 02-25-2002 10:21 PM

The last while should get some 'break' or 'sleep' :)

Admins 02-25-2002 10:33 PM

hehe

Saga2001 02-25-2002 11:57 PM

lol. setting O.o ? Are there any keywords (or characters) that can't be used in flags? I thought i experianced one back a few versions with '-'.

Faheria_GP2 02-26-2002 06:58 AM

Re: Why so laggy?
 
Quote:

Originally posted by relenakat
This is sorta jsut a simple script but what I'm wondering is why is it so laggy?

NPC Code:

}
if (created||playerenters) {
setcharprop #3,head5.gif;
set O.o;
}
while (O.o&&this.O.o<=20){
npcs[0].y=npcs[0].y-.5;
sleep .3;
this.O.o = this.O.o+1;
setcharani walk,;
dir = 0;
}
while (O.o&&this.O.o<=40){
npcs[0].x=npcs[0].x+.5;
sleep .1;
this.O.o = this.O.o+1;
dir = 3;
}
while(this.O.o==41){
setcharani idle,;
message This is *blank*'s room;
}


haghm, that script is very...for a lack of a better word, crappy...

the whiles aren't inside an event, the last one gets stuck in an infinite loop, the thing should be a for loop, maybe a timeout loop...just terrible...also, you should be using "x" instead of "npcs[0].x"...this.O.o is never set back to zero, so this whole thing will only run once, then poop out...what you are trying to do seems too complex for you...

Bhala 02-26-2002 07:17 AM

it would be better to use 3 if's in a time out loop....


All times are GMT +2. The time now is 07:45 PM.

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