Target position

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
WhiteTiger
Posts: 84
Joined: Tue Jun 22, 2010 8:06 am

Target position

#1 Post by WhiteTiger »

Hi, I got two questions..
First, is there a way to get the location of your target? like a function that returns x,y and z values.. or even better to get the location of the nearest unit of a specific id number.
And 2nd, is there a function that makes your character move to a location without depending of the waypoints? Ty :P
User avatar
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: Target position

#2 Post by Administrator »

Code: Select all

local target = player:getTarget();
local x,y,z = target.X, target.Y, target.Z;

Code: Select all

player:moveTo(1000.0, 2000.0);
WhiteTiger
Posts: 84
Joined: Tue Jun 22, 2010 8:06 am

Re: Target position

#3 Post by WhiteTiger »

[quote="Administrator"]

Code: Select all

local target = player:getTarget();
local x,y,z = target.X, target.Y, target.Z;
tried that with this code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<!-- #  1 --><waypoint x="6773" z="21596">
	local target = player:getTarget();
	local x,y,z = target.X, target.Y, target.Z;
	addMessage(x);
	yrest(1000);
	</waypoint>
</waypoints>
but it only printed 0 :(
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Target position

#4 Post by rock5 »

WhiteTiger wrote:but it only printed 0 :(
Did you have something targeted?

That code is in between waypoint tags which means it would move to that point first then execute the code. It may not have something targeted when executing that code.

Try putting that code between onLoad tags instead so it gets executed immediately. Then target something first before loading the waypoint file. eg.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
   local target = player:getTarget();
   local x,y,z = target.X, target.Y, target.Z;
   addMessage(x);
   yrest(1000);
   player:sleep()
</onLoad>
   <!-- #  1 --><waypoint x="6773" z="21596">   </waypoint>
</waypoints>
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
WhiteTiger
Posts: 84
Joined: Tue Jun 22, 2010 8:06 am

Re: Target position

#5 Post by WhiteTiger »

it worked when I put it in <OnLoad>. But it still doesnt work when I have it in a waypoint:S. I think I know what the problem is tho: When it got to the waypoint before it executed any code it printed "Clearing target" in the micromacro program. Any idea how I can remove that?
WhiteTiger
Posts: 84
Joined: Tue Jun 22, 2010 8:06 am

Re: Target position

#6 Post by WhiteTiger »

player:moveTo(1000.0, 2000.0);
I also noticed now when I tried the moveTo that it doesnt work and I get this error:
...rom/classes/player.lua/player.lua:1150: attemp to index local 'waypoint' (a number value)

I tried it with this code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
player:moveTo(1000.0, 2000.0);
yrest(5000)
player:sleep()
</onLoad>
   <!-- #  1 --><waypoint x="6773" z="21596">   </waypoint>
</waypoints>
any ideas? :(
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Target position

#7 Post by rock5 »

WhiteTiger wrote:it worked when I put it in <OnLoad>. But it still doesnt work when I have it in a waypoint:S. I think I know what the problem is tho: When it got to the waypoint before it executed any code it printed "Clearing target" in the micromacro program. Any idea how I can remove that?
At this point I think we need to ask, why do you want to know the coordinates of your target and what do you intend to do with them?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Target position

#8 Post by rock5 »

WhiteTiger wrote:
player:moveTo(1000.0, 2000.0);
Looks like this is wrong. moveTo expects a waypoint so you need to create a waypoint object. This seems to work;

Code: Select all

to = CWaypoint(1000.0, 2000.0)
player:moveTo(to);
Edit: Just discovered you can do this too;

Code: Select all

player:moveTo(CWaypoint(1000.0, 2000.0));
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
WhiteTiger
Posts: 84
Joined: Tue Jun 22, 2010 8:06 am

Re: Target position

#9 Post by WhiteTiger »

Stuffs work now :) thx for all help!
Post Reply