Page 1 of 1

onLoad error

Posted: Sat Dec 04, 2010 3:17 pm
by jduartedj
I get this error:

Code: Select all

...ktop/Jogos/micromacro/scripts/rom/classes/player.lua:1424: attempt to index l
ocal 'pA' (a nil value)
when I use player:moveTo(point, nil) in the onLoad section.
heres the corresponding fragment of the file

Code: Select all

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

--WC_R+L_keypoint file
--Weeping Coast, Farming Raptors and Leopards
--JDuarteDJ's Keypoint system 
--ultimate-bot project
--COORDINATES (x="15901" z="24787")

local dqCount, dqPerDay = RoMScript("Daily_count()");
local point = CWaypoint(15901, 24787);
--force to be at keypoint				
player:moveTo(point, nil);
Any help would be appreciated, thanks.

Re: onLoad error

Posted: Sat Dec 04, 2010 3:53 pm
by Administrator
Are you sure that your player.lua is up to date? Try deleting and reupdating. It might have got broken.

Re: onLoad error

Posted: Sat Dec 04, 2010 4:10 pm
by jduartedj
Administrator wrote:Are you sure that your player.lua is up to date? Try deleting and reupdating. It might have got broken.
Oh the line numbers may not match the SVN because I included the target Boss patch in the other thread. anyway using TortoiseMerge (or Diff) I have confirmed that it is (other than that Boss part) the same as revision 529 which is, if I'm not mistaken, the last modification to the file.

I got this error more than once... then in some other occasions I don't get it anymore o.O ! It's weird...

Re: onLoad error

Posted: Sat Dec 04, 2010 4:50 pm
by Administrator
Then what is on the line that is generating the error for you?

Re: onLoad error

Posted: Sat Dec 04, 2010 6:29 pm
by jduartedj
Administrator wrote:Then what is on the line that is generating the error for you?
This is a bit of the context for you to have an idea where it is, and the line is marked 1424:

Code: Select all

	if( player.Returning ) then
		wpl = __RPL;
	else
		wpl = __WPL;
	end

	if (__WPL:getMode() == "waypoints") then
		local pA = wpl.Waypoints[wpl.LastWaypoint]
		local pB = wpl.Waypoints[wpl.CurrentWaypoint]

1424:here->V = getNearestSegmentPoint(player.X, player.Z, pA.X, pA.Z, pB.X, pB.Z);
	else
		V = CWaypoint(player.X, player.Z); -- Distance check from player in wander mode
	end

	-- use a bounding box first to avoid sqrt when not needed (sqrt is expensive)
	if( target.X > (V.X - settings.profile.options.MAX_TARGET_DIST) and
		tar

Re: onLoad error

Posted: Sat Dec 04, 2010 6:50 pm
by rock5
pA being nil would imply a problem with the value wpl.LastWaypoint. That should still be the default value of 1 in the onLoad section. It should find that waypoint. Has waypointlist.lua been kept up to date as well?

Re: onLoad error

Posted: Sun Dec 05, 2010 11:46 am
by jduartedj
rock5 wrote:pA being nil would imply a problem with the value wpl.LastWaypoint. That should still be the default value of 1 in the onLoad section. It should find that waypoint. Has waypointlist.lua been kept up to date as well?

Yeah i'm pretty sure it is because I recently updated all the bot...

Re: onLoad error

Posted: Mon Dec 06, 2010 6:01 am
by rock5
jduartedj wrote:Yeah i'm pretty sure it is because I recently updated all the bot...
Ok I figured it out. It's because you don't have any waypoints. Part of moveto is evaluating targets. Part of evaluating targets is checking their distance to the waypoints. If there are no waypoints it causes that error.

You could create a dummy waypoint but I think that would mean it wouldn't target mobs because they are too far from the waypoint. What you could do is change the mode to 'wander' that way it will check the distance to the player instead of non existing waypoints.

So first use this command.

Code: Select all

__WPL.Mode = "wander"
Then the rest should work.

I'll probably add a fix that if a waypoint file has no waypoints then it sets the mode to wander.

Re: onLoad error

Posted: Mon Dec 06, 2010 6:03 am
by jduartedj
THANKS!! it's as if you read my mind! I just have that error again and was gonna post some more info!

EDIT: I'm gonna use a lot of "keypoints" that don't have any waypoints so I'd appreciate that fix.

Re: onLoad error

Posted: Mon Dec 06, 2010 9:04 pm
by rock5
Ok added to rev 539.

Re: onLoad error

Posted: Mon Dec 06, 2010 10:13 pm
by jduartedj
rock5 wrote:Ok added to rev 539.
thanks!