Page 1 of 2

How do I force start at waypoint #1?

Posted: Mon Aug 16, 2010 7:53 pm
by randomuser01

Code: Select all

	<onLoad>
		__WPL:setWaypointIndex( 1);	
	</onLoad>
^ doesn't work. I'm out of ideas.

How do I make the script start at waypoint 1 no matter what waypoint it thinks is closer?

Re: How do I force start at waypoint #1?

Posted: Mon Aug 16, 2010 8:41 pm
by Valleyguy
randomuser01 wrote:

Code: Select all

	<onLoad>
		__WPL:setWaypointIndex( 1);	
	</onLoad>
^ doesn't work. I'm out of ideas.

How do I make the script start at waypoint 1 no matter what waypoint it thinks is closer?
Use something like the following :

Code: Select all

<onLoad>
__WPL:setWaypointIndex(__WPL:findWaypointTag("One"));
</onLoad>

<!-- #  1 --><waypoint x="-9999" z="-9999" tag="One">	</waypoint>

Re: How do I force start at waypoint #1?

Posted: Mon Aug 16, 2010 9:54 pm
by randomuser01
Does the exact same thing that my code does. Still just loads whatever waypoint is closest.

Re: How do I force start at waypoint #1?

Posted: Mon Aug 16, 2010 11:20 pm
by Administrator
At line 173 of bot.lua, you'll see this:

Code: Select all

	-- onLoad event
	-- possibility for users to overwrite profile settings
	if( type(settings.profile.events.onLoad) == "function" ) then
		local status,err = pcall(settings.profile.events.onLoad);
		if( status == false ) then
			local msg = sprintf("onLoad error: %s", err);
			error(msg);
		end
	end
Move that code down to about line 381, directly above this:

Code: Select all

	-- Update inventory
	inventory:update();
Let me know if this works.

Re: How do I force start at waypoint #1?

Posted: Tue Aug 17, 2010 12:12 am
by randomuser01
I'll give that a shot tomorrow, see what it spits out, thanks.

Re: How do I force start at waypoint #1?

Posted: Tue Aug 17, 2010 6:45 pm
by randomuser01
Still doesn't work, not getting any errors either.

Re: How do I force start at waypoint #1?

Posted: Wed Aug 18, 2010 4:32 am
by swietlowka
was looking fo just the same thing, had to make extra loop to make my script work, not so easy though so if its possible to make it in onload ith _WPL function it would be awsome

Re: How do I force start at waypoint #1?

Posted: Wed Aug 18, 2010 8:00 pm
by randomuser01
Could really use some help with this. Trying to chain together several scripts and they all start and end on the exact same spot. So half the time a new script will load, and it will automatically set the last waypoint as next (because start and end are the same) and that means it skips that waypoint file completely.

Re: How do I force start at waypoint #1?

Posted: Wed Aug 18, 2010 8:37 pm
by Administrator
Hold on a second. How are you trying to load these waypoint files? Are you talking about the waypoint list that is automatically loaded when you start the bot, or are you talking about the second (or third, or...) waypoint list being loaded by calling __WPL:load()?

Re: How do I force start at waypoint #1?

Posted: Wed Aug 18, 2010 9:44 pm
by randomuser01
Either way.

Starting rom/bot.lua and selecting the waypoint from the list, even with the onLoad script, it will start wherever is closest.

With a new waypoint list being started using loadPaths("").

Either way, the closest waypoint is selected. I even tried loading it by creating a batch file that calls the script and waypoint directly.

Re: How do I force start at waypoint #1?

Posted: Wed Aug 18, 2010 10:27 pm
by rock5
randomuser01 wrote:Could really use some help with this. Trying to chain together several scripts and they all start and end on the exact same spot. So half the time a new script will load, and it will automatically set the last waypoint as next (because start and end are the same) and that means it skips that waypoint file completely.
Normally the last point and the first point are not the same. If I understand correctly, you need the last point to be the same because the next file starts at that location. I suggest in the future you avoid starting files in exactly the same place to avoid this problem. You could connect the files together and make 1 big file. You should then be able to control what path it takes using the __WPL commands.

Re: How do I force start at waypoint #1?

Posted: Thu Aug 19, 2010 12:10 am
by randomuser01
rock5 wrote:
randomuser01 wrote:Could really use some help with this. Trying to chain together several scripts and they all start and end on the exact same spot. So half the time a new script will load, and it will automatically set the last waypoint as next (because start and end are the same) and that means it skips that waypoint file completely.
Normally the last point and the first point are not the same. If I understand correctly, you need the last point to be the same because the next file starts at that location. I suggest in the future you avoid starting files in exactly the same place to avoid this problem. You could connect the files together and make 1 big file. You should then be able to control what path it takes using the __WPL commands.
Well, let me tell you what it's doing, and maybe you can give me some input.

My character is running dailys on his high level side, then going to the housemaid, switching classes, and then going out and turning the dailys in. I do this in blocks of 3 dailys.

So bot starts with character on high side, goes out and does 4 quests, goes to house maid and switches to low side.
Bot goes out and turns in dailies, comes back to housemaid and switches back to high side.
Bot goes out and does 3 dailys, comes back to housemaid and switches to low side.
Bot goes and turns in dailies, switches to high side.
Bot goes and does 3 dailies, switches to low side.
Bot goes and turns in 3 dailies, switches to high side and enters house.


Because the bot returns to the exact same spot so many times to switch classes, the waypoint file will never start me at waypoint #1. I have to run over to kinda where waypoint 2 and 3 are, and start the bot, and pray that I'm not accidentally too close to waypoint #180 or #323 or whatever else runs right back over that spot.

I've tried it a couple ways, with 6 separate waypoint files, 4, turn in 4, 3, turn in 3, etc... And with one massive waypoint file with nearly 600 waypoints.

Both ways are equally difficult to get the bot to start at the actual beginning of the waypoint file.

One thing I was thinking MIGHT work. Could I set some sort of flag in the OnLoad code, and have that flag do something in the profile to force the next waypoint to be #1. And then have lua code inside waypoint 1 to turn the flag off? Would that work? How would I setup the profile part of the code?

Thanks!

Re: How do I force start at waypoint #1?

Posted: Thu Aug 19, 2010 6:21 am
by Administrator
First, update to r492. It contains the fix I posted earlier in this thread. You'll need it.

In your profile's onLoad event, you'll need:

Code: Select all

__WPL:setWaypointIndex(1);
This will take care of setting the index correctly the first time it is loaded.

Any time you use __WPL:load() to switch waypoint lists, you will also need to set the waypoint index directly after it. Now, it should be working as you want it to.

Re: How do I force start at waypoint #1?

Posted: Thu Aug 19, 2010 10:46 am
by swietlowka
wow, thats just what i was waiting for too :D
Thanks man onload with _WPL is awsome :)

Re: How do I force start at waypoint #1?

Posted: Thu Aug 19, 2010 3:19 pm
by fred55555
is there a line to make you just retrace your steps instead of running back to waypoint one, wanted to make a point to point route not a circle route

Re: How do I force start at waypoint #1?

Posted: Thu Aug 19, 2010 7:54 pm
by Administrator
You can use __WPL:setDirection("forward") or __WPL:setDirection("backward"), as well as __WPL:reverse().

Re: How do I force start at waypoint #1?

Posted: Fri Aug 20, 2010 2:10 am
by randomuser01
Ran the new script and setup today and it worked flawlessly, did exactly what I wanted it to.

Thanks for the help!

Re: How do I force start at waypoint #1?

Posted: Fri Aug 20, 2010 10:18 am
by fred55555
You can use __WPL:setDirection("forward") or __WPL:setDirection("backward"), as well as __WPL:reverse().

so would you put this in the waypoint.xml forward at the start and backward at the end so it keeps going backand forth through the waypoints instead of looping back to waypoint 1.

Re: How do I force start at waypoint #1?

Posted: Fri Aug 20, 2010 10:29 am
by Administrator
fred55555 wrote: so would you put this in the waypoint.xml forward at the start and backward at the end so it keeps going backand forth through the waypoints instead of looping back to waypoint 1.
Yes.

Re: How do I force start at waypoint #1?

Posted: Fri Aug 20, 2010 2:10 pm
by fred55555
thank you going to try it and hope i get the syntax correct. :)

thnx for help