Jump to content

How do I change an action's animation?


Recommended Posts

How can I change an action from using a long animation to using a short animation?

Picking up a carrot = short animation

Picking berry bushes = long animation

 

What I found was in SGwilson.lua it calls ActionHandler(ACTIONS.COOK, "dolongaction") and it stores that handler in a variable called actionhandlers and then actionhandlers is used when the StateGraph is created on the line 

return StateGraph("wilson", states, events, "idle", actionhandlers)

 

I have a mod where I've added my own new action, so I know how to set the animation for my new action:

local releasehandler = GLOBAL.ActionHandler(GLOBAL.ACTIONS.RELEASE, "doshortaction")
AddStateGraphActionHandler("wilson", releasehandler)

So trying to change the cook action, I tried doing the same

local cookhandler = GLOBAL.ActionHandler(GLOBAL.ACTIONS.COOK, "doshortaction")
AddStategraphActionHandler("wilson", cookhandler)

But this does not work. This makes the game crash as soon as I start up a world. How can I do this?

Link to comment
Share on other sites

@HomShaBom

_G = GLOBAL
local ACTIONS = _G.ACTIONS
local ActionHandler = _G.ActionHandler
local IsServer = _G.TheNet:GetIsServer()
local State = "wilson_client"
if IsServer then State = "wilson" end
AddStategraphPostInit(State, function(sg)
	sg.actionhandlers[ACTIONS.COOK] = ActionHandler(ACTIONS.COOK, "doshortaction")
end)

 

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
 Share

×
  • Create New...