Jump to content

Implementing "Walk To" Hotkey


tuliomir

Recommended Posts

I'm borrowing an idea from the mod "Fast Keys" here.

 

I want to bind a key, say, F1 to the "Walk To" action. Waaay better than trying to right-click and hope it works while being chased by a horde and trying to dodge the translucent bushes at the same time 😱 </panic>

 

Looking at the source code available I can imagine something along the lines of...

local KEY_WALK = {
	name = "Walk To",
	key = Keyboard.KEY_F1,
}

if ModOptions and ModOptions.AddKeyBinding then
	ModOptions:AddKeyBinding("[Player Control]",KEY_WALK)
end

local function KeyUp(keynum)
	local specificPlayer = getSpecificPlayer(0)
	if specificPlayer ~= nil then
		if keynum == KEY_WALK.key then -- F1
			ISWorldObjectContextMenu.WHAT_SHOULD_I_PUT_HERE?(0)
		end
	end
end
Events.OnKeyPressed.Add(KeyUp);

Can someone shine a light here? I'm at a loss of where to search for this "WHAT_SHOULD_I_PUT_HERE" function that calls the "Walk To" action.

 

Thanks in advance!

Link to comment
Share on other sites

  • 4 weeks later...

Hi tuliomir,

I looked at the walkToAction in there and found it was using the action of WalkToTimedAction.lua

That one requires a square as target.

I found the Mouse:getX and getY functions from https://projectzomboid.com/modding/

Then at the same place I found IsoUtils.XToIso that I was not able to use properly.

With luck they were used ~properly by DebugContextMenu.lua. Just the zoom management is wrong (I'd guess obsolete) and I was lucky to find it fast enough.

That was it for the target square.

I added a way to bypass the end of the current move action when we start the next and the result is here:

https://steamcommunity.com/sharedfiles/filedetails/?id=2591232239

Edited by Tchernobill
text construction needs clear articulation
Link to comment
Share on other sites

  • 1 month later...
On 9/1/2021 at 8:25 PM, Tchernobill said:

Hi tuliomir,

I looked at the walkToAction in there and found it was using the action of WalkToTimedAction.lua

That one requires a square as target.

I found the Mouse:getX and getY functions from https://projectzomboid.com/modding/

Then at the same place I found IsoUtils.XToIso that I was not able to use properly.

With luck they were used ~properly by DebugContextMenu.lua. Just the zoom management is wrong (I'd guess obsolete) and I was lucky to find it fast enough.

That was it for the target square.

I added a way to bypass the end of the current move action when we start the next and the result is here:

https://steamcommunity.com/sharedfiles/filedetails/?id=2591232239

Is it possible to make a mod, that if u are holding W your character always walks forward to your mouses pointer and stops moving when u let go. Then when holding S down u walk backwards but still follows your mouse pointer and faces your mouse pointer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...