ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Grandewd on September 27, 2014, 02:34:36 PM
-
:-[
Here's the simple code I'm using:
event pathfind 2149 1415 -23
while #charposx <> 2149 && #charposy <> 1415
{
wait 5
event pathfind 2149 1415 -23
}
I know Cheffe said in the doc's: Please note that your script will keep on executing while the character is moving.
but in my example the script jumps out of the while loop before it reaches the coords.
This is in one of my houses, and nothing is keeping it from reaching the destination tile.
How/why is it leaving the while loop before the condition is met? ???
-
Try this maybe it will work better.and add step as u need then.
step_m1:
move 2149 1415 0 5s
if ! ( #charposx = 2149 && #charposy = 1415 )
{
goto step_m1
}
else
{
goto step_m2
}
step_m2
-
Its because of the Logic
while #charposx <> 2149 && #charposy <> 1415 ; <- Logic
So once either your #Charposx = 2149 or your #Charposy = 1415 it will break from the while because you are telling it to only move while BOTH of them aren't what you want. Change the && to an ||
While #Charposx <> 2149 || #Charposy <> 1415
That will force it to continue to perform the code until it satisifies both Conditions.
-
Its because of the Logic
while #charposx <> 2149 && #charposy <> 1415 ; <- Logic
So once either your #Charposx = 2149 or your #Charposy = 1415 it will break from the while because you are telling it to only move while BOTH of them aren't what you want. Change the && to an ||
While #Charposx <> 2149 || #Charposy <> 1415
That will force it to continue to perform the code until it satisifies both Conditions.
Spot on!
-
Its because of the Logic: while #charposx <> 2149 && #charposy <> 1415 ; <- Logic
So once either your #Charposx = 2149 or your #Charposy = 1415 it will break from the while because you are telling it to only move while BOTH of them aren't what you want. ....
Which is why pathfind is part of the loop, so it WILL keep trying until BOTH conditions are met.
That will force it to continue to perform the code until it satisifies both Conditions.
Exactly! I mean isn't that what the AND (&&) is saying.... Isn't that the condition - that BOTH have to be true ? What else would AND be for?
Forgive me for being obtuse, but I'm trying to see why my logic is off...
-
Okay, lets look at it if you are standing on a certain spot.
Lets say you are standing on x = 2149 and y = 1414
Because your #Charposx = 2149 the first statement (#charposx <> 2149) is False. && Requires that both statements have to be true in order for it to run the code.
while #charposx <> 2149 && #charposy <> 1415 ; <- Logic
{
}
-
I believe I see the logic now, Manwinc... Thanks much for taking the time to explain... :)
-
To keep question under same topic I will post in here
The idea is to use this to move a few title it I get damage or have a enemies near by. The problem I'm having is that the doesn't get out of the loop. Not sure what I miss or did wrong here.
set %PosX #charposx - 2
set %PosY #charposy + 6
gosub healthcheck
halt
sub healthcheck
namespace push
namespace local HC
set %endX #charposx
set %endY #charposy
repeat
wait 10
event pathfind %PosX %PosY
until %endX = %PosX && %endY = %PosY
namespace pop
return
-
try this
Repeat
gosub healthcheck
Until Cstalker = Awesome
halt
sub healthcheck
namespace push
namespace local HC
set %PosX #charposx - 2
set %PosY #charposy + 6
repeat
wait 10
event pathfind %PosX %PosY
until #charposX = %PosX && #charposY = %PosY
namespace pop
return