Page 1 of 1

Get player position in OnLoad

Posted: Wed Sep 25, 2013 12:02 pm
by ZZZZZ
Have tried searching around for anything related to it but unsuccessful so far...

Basically just want to load the player position within the onload of a waypoint rather than using Get_Player_Position.bat manually and put the values into playerX-playerY-playerZ which would then go into the waypoint.

example:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
 
<OnLoad>

 Get position (playerX playerY playerZ)

</OnLoad>

	<!-- #  1 --><waypoint x="playerX" z="playerZ" y="playerY">
    repeat
        yrest(1)
        player:update()
        until player.Battling or player:findEnemy(nil,nil,evalTargetDefault)
    </waypoint>
</waypoints>
Would make it far easier to move around to a different location when farming cards etc.

Any info would be great...and sorry if its obvious in another thread..havnt been able to find anything ^.^

Re: Get player position in OnLoad

Posted: Wed Sep 25, 2013 3:17 pm
by rock5
First consider using wander mode with a radius of 0 or my rbassist waypoint file.

But if you want to use your own file and you want it to keep to a certain location then you can do away with the waypoint and just use the onload.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<OnLoad>
local playerX, playerY, playerZ = player.X, player.Y, player.Z
while true do
   -- Wait for mob
   repeat
        yrest(1)
        player:update()
   until player.Battling or player:findEnemy(nil,nil,evalTargetDefault)
   -- Fight till there are no more mobs
   enemy = player:findEnemy(nil,nil,evalTargetDefault)
   while enemy do
        player:target(enemy)
        player:fight()
        enemy = player:findEnemy(nil,nil,evalTargetDefault)
   end
   -- Return to starting position
   player:moveTo(CWaypoint(playerX,playerZ,playerY), true)
end
</OnLoad>
</waypoints>
I think that should work.

Re: Get player position in OnLoad

Posted: Thu Sep 26, 2013 9:11 pm
by ZZZZZ
Works correctly, thanks :)