BreakPipes Posted January 14, 2022 Share Posted January 14, 2022 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? Link to comment Share on other sites More sharing options...
BreakPipes Posted January 14, 2022 Author Share Posted January 14, 2022 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, Link to comment Share on other sites More sharing options...
Leonidas IV Posted January 18, 2022 Share Posted January 18, 2022 Hmm, the Cancel Attacks mod modifies some SG, you can see how it's done. There are still some details to transfer this to a mod, such as the use of the GLOBAL variable and others. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.