Page 1 of 1

Enable/disable Wander via keypress?

Posted: Wed Jun 17, 2015 2:15 pm
by noobbotter
I was wondering if there is a way to enable or disable the wander function via keypress within a waypoint file without having to use del and end keys to pause and resume the script?


Update...

Nevermind. I think i figured it out. All I have to do to make it stop "wandering" is, because my wandering was set to radius of 0 anyways, is to disable the skills when the key is pressed, then if I want it to "wander" again at a different key press, then I just re-enable those skills. I'll test it tonight.

Re: Enable/disable Wander via keypress?

Posted: Wed Jun 17, 2015 3:16 pm
by beanybabe
use a xbox wireless joystick and you can carry it around and press button anywhere.

Re: Enable/disable Wander via keypress?

Posted: Thu Jun 18, 2015 1:47 am
by Celesteria
I am using this little functions in one of my scripts to start/stop wandering, but I didnt figured out, how to activate/deactivate it via keypress

Code: Select all

function startWander ()
  settings.profile.friends	= {"Bubsitan"}			-- don't attack this mob
  settings.profile.mobs = {"Jungb\132r"}			-- farm mobs
  changeProfileOption ("PATH_TYPE", 'wander')
  changeProfileOption ("WANDER_RADIUS", 50)
  changeProfileOption ("MAX_TARGET_DIST", 350)
  __WPL:setForcedWaypointType ('NORMAL')
end

function stopWander ()
  settings.profile.mobs 		= {"nobody"}
  changeProfileOption ("PATH_TYPE", 'waypoints')
  changeProfileOption ("WANDER_RADIUS", 0)
  changeProfileOption ("MAX_TARGET_DIST", 0)
  __WPL:setForcedWaypointType ('TRAVEL')
end

Re: Enable/disable Wander via keypress?

Posted: Thu Jun 18, 2015 7:06 am
by noobbotter
You can try it like this. I took this function I use for turning on and off speed and changed it up with your start/stop wandering functions included. With this it should start or stop wandering each time you hit the "g" key. If you want to change which key it uses, just change the key.VK_G on line 36 to whichever key you want to use.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad><![CDATA[
	
	WanderEnabled = false
	function startWander ()
		settings.profile.friends   = {"Bubsitan"}         -- don't attack this mob
		settings.profile.mobs = {"Jungb\132r"}         -- farm mobs
		changeProfileOption ("PATH_TYPE", 'wander')
		changeProfileOption ("WANDER_RADIUS", 50)
		changeProfileOption ("MAX_TARGET_DIST", 350)
		__WPL:setForcedWaypointType ('NORMAL')
	end

	function stopWander ()
		settings.profile.mobs       = {"nobody"}
		changeProfileOption ("PATH_TYPE", 'waypoints')
		changeProfileOption ("WANDER_RADIUS", 0)
		changeProfileOption ("MAX_TARGET_DIST", 0)
		__WPL:setForcedWaypointType ('TRAVEL')
	end	
	--============= Function to show button controls ===================
	function SKM_ShowButtons()
		if WanderEnabled then
			cprintf(cli.green, "G - - > Disable Wandering!!!\n")
		else
			cprintf(cli.green, "G - - > Enable Wandering.\n")
		end
	end
   
	--============= main routine starting: =====================
	local delay = 1 -- time between key presses.
	local time = os.time()
	SKM_ShowButtons();
	while(true) do
		
		if keyPressed(key.VK_G) and (os.time() - time > delay ) then
			if WanderEnabled then
				WanderEnabled = false
				stopWander()
				cprintf(cli.yellow, "Wandering Disabled!!!\n")
			else
				WanderEnabled = true
				startWander()
				cprintf(cli.green, "Wandering Enabled!!!\n")
			end
			time = os.time()
			
		end
		yrest(50)
	end
]]></onLoad>
</waypoints>
This is untested, by the way.