Jump to content

Recommended Posts

Hello everyone, I'm new to modding and want to make a simple change to wilbur: press a button to toggle between walking and running.

I know how he goes to walking state to running state, but don't know how to make it toggleable. Could someone please help me?

Edited by BreakPipes

So, I didn't know how to toggle it, but I made a simpler and smoothier solution: If Wilbur is walking for 3 seconds AND you press right click button, he starts running. Now you have the option to walk indefinitely (my main objective) and start running whenever it pleases you.

I changed the original code, without doing any mods, by going on SGwilson.lua and just adding "TheInput:IsMouseDown(MOUSEBUTTON_RIGHT)" on the run state. My addition is commented to highlight it to everyone.

 

 State{
        
        name = "run",
        tags = {"moving", "running", "canrotate"},
        
        onenter = function(inst) 
            inst.components.locomotor:RunForward()
            inst.AnimState:PlayAnimation("run_loop")
        end,

        onupdate = function(inst)
            inst.components.locomotor:RunForward()
            if inst.components.locomotor.timemoving >= TUNING.WILBUR_TIME_TO_RUN and --[[TheInput:IsMouseDown(MOUSEBUTTON_RIGHT)--]] and  inst:HasTag("monkey") and not inst.components.rider:IsRiding() then
               inst.sg:GoToState("run_monkey_start") 
            end
        end,

 

Edited by BreakPipes

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...