Yoko

All sides of Injection
It is currently 2026-01-16 06:34:01

All times are UTC+02:00




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
 Post subject: IF Question
PostPosted: 2004-06-28 07:42:30 
Offline

Joined: 2004-05-09 19:53:49
Posts: 58
i noticed a thing and i can't explain why is it..

i have this script:

sub test()
WHILE UO.Life > 0
poison = UO.Poisoned()
IF poison == 1
UO.Cast('Cure','self)
ELSE
wait(5000)
ENDIF
WEND
end sub

In the case of poison different from 1( wait(5000) it doesn't matter if i set 100, 200 or 10000), my client go slowly.. as lag..
if i'm poisoned i go perfectly


if i change in this i move perfectly always:

sub test()
WHILE UO.Life > 0
poison = UO.Poisoned()
IF poison == 1
UO.Cast('Cure','self)
ENDIF
wait(5000)
WEND
end sub


Top
   
 Post subject:
PostPosted: 2004-06-28 14:48:29 
Offline
Site Admin
User avatar

Joined: 2004-04-03 16:49:38
Posts: 1964
this is a very very often happends logics mistake

note then script
Code:
while ...
  if <false> then
    ....
  end if
wend

is equivalent to
Code:
while ...
wend


Empty cylce will consume all CPU.

for any script you think may produce empty cycle it is safe and reliable to add wait(50) command before second operator bracket (wend, next, until, goto)

for instance your script may look like:
Code:
sub test() 
WHILE UO.Life > 0
poison = UO.Poisoned()
IF poison == 1
UO.Cast('Cure','self)
ELSE
wait(5000)
ENDIF
wait(50) ### !
WEND
end sub


Top
   
 Post subject:
PostPosted: 2004-06-28 18:38:48 
Offline

Joined: 2004-05-09 19:53:49
Posts: 58
IF poison == 1
UO.Cast('Cure','self)
ELSE
wait(5000)
ENDIF

i never had the empty cycle..if im'not poisoned, it should go to the ELSE (wait 5000), no?


Top
   
 Post subject:
PostPosted: 2004-06-28 20:02:07 
Offline
Site Admin
User avatar

Joined: 2004-04-03 16:49:38
Posts: 1964
IF you poisoned, where is delay? no delay ~= empty cycle


Top
   
 Post subject:
PostPosted: 2004-06-28 20:04:02 
Offline
Site Admin
User avatar

Joined: 2004-04-03 16:49:38
Posts: 1964
even more, i just noticed, you flooding server with casts using such script you wrote, cause many many times per second, without delay you trying to cast Cure when you are poisoned


Top
   
 Post subject:
PostPosted: 2004-06-28 20:18:52 
Offline

Joined: 2004-05-09 19:53:49
Posts: 58
sorry i can't explain very well :P

i go slowly only when i'm not poisoned :)
this is strange for me.. cause i use a big delay(5000), but it doesn't matter what delay i use


Top
   
 Post subject:
PostPosted: 2004-07-22 10:36:18 
Offline

Joined: 2004-06-23 20:56:02
Posts: 7
If you are uncertain whhat happens in your script, do some debug messages... it'll show ya the problem.


Code:
sub test() 
WHILE UO.Life > 0
poison = UO.Poisoned()
IF poison == 1
UO.print("TRUE, casting")
UO.Cast('Cure','self)
ELSE
UO.print("FALSE, waiting")
wait(5000)
ENDIF
wait(1000) ### just to slow down all the script and avoid message flood.
WEND
end sub


btw: what the heck is IF without THEN ? Parser should Yell about it!
btw2: what is "poison=" ment to be, when there is no "var poison" before? HA :)
btw3: it is ABSOLUTELY useless, you can write "IF UO.Poisoned() THEN" instead


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited