Page 1 of 1

onWaypoint

Posted: Wed Nov 02, 2011 12:32 pm
by dx876234
Something I've been missing for a while is an onWaypoint event, ie to be able to specify code that would trigger on each waypoint unless there is a coded action in which would override. I use it for boss proximity checking or to code actions in wander waypoint files.

It turned out rather simple to make the event, I haven't looked into reading it from config file though.

Changes necessarily is below (in bot.lua approx line 760)

regards
-f

Code: Select all

				else
					__WPL:advance();
					-- Execute it's action, if it has one.
					if( wp.Action and type(wp.Action) == "string" and string.find(wp.Action,"%a") ) then
						keyboardRelease( settings.hotkeys.MOVE_FORWARD.key ); yrest(200) -- Stop moving
						local actionchunk = loadstring(wp.Action);
						assert( actionchunk,  sprintf(language[150], __WPL.CurrentWaypoint) );
						actionchunk();
                                        -- Start onWaypoint code
					else
						if( type(settings.profile.events.onWaypoint) == "function" ) then
							local status,err = pcall(settings.profile.events.onWaypoint);
							if( status == false ) then
								local msg = sprintf("onWaypoint error: %s", err);
								error(msg);
							end
						end
					end
                                        -- end onWaypoint code
				end

Re: onWaypoint

Posted: Wed Nov 02, 2011 11:13 pm
by rock5
I think the reason it was never implemented was because if you want something checked on a regular basis then you can use a timer event and in most cases it would work better.

But if we did have an onwaypoint event I would think that it should run regardless if there is actual code at the waypoint. It should run at every waypoint.

Re: onWaypoint

Posted: Thu Nov 03, 2011 2:33 pm
by dx876234
Ye, I pretty much agree to that, make it run every waypoint - but before or after coding in waypoint?

-dx

Re: onWaypoint

Posted: Thu Nov 03, 2011 11:11 pm
by rock5
I don't know. What uses is it likely to be used for? I can think of one. Instead of putting player:harvest() at every waypoint it would be simpler to just add it to the onwaypoint.

Re: onWaypoint

Posted: Thu Nov 03, 2011 11:16 pm
by lisa
I dabled in having player:harvest() much more frequently, it made the bot very slow. Not something I would add to bot as default behaviour.

Re: onWaypoint

Posted: Thu Nov 03, 2011 11:51 pm
by rock5
I guess it's because it would stop at every waypoint. Wouldn't be much of an issue if you took care not to make too many waypoints and keep them far apart between nodes.

That would be an issue to deal with though, as any code at waypoints makes it stop. Of course any code in the onwaypoint would be separate and probably we would have to decide if we want it to stop at every waypoint or not. I say no but then if the code in the onwaypoint requires the character to stop then the user would have to include a stop. Maybe we would have to add a 'stopmoving' function to simplify it for users.