AFS Co. Posted August 19, 2021 Share Posted August 19, 2021 I'm trying to add a functionality to the actionhandler for ACTIONS.EAT. But for the compatibility, I want to only append it. local function sgmod(self) local old_eat_state = self.actionhandlers.ACTIONS.EAT.deststate self.actionhandlers.ACTIONS.EAT.deststate = function(inst, action) local oldstate = old_eat_state(inst, action) if old_eat_state ~= nil and inst:HasTag("asdf") then return "throw" else return oldstate end end end AddStategraphPostInit("wilson", sgmod) AddStategraphPostInit("wilson_client", sgmod) How would I do it? Link to comment Share on other sites More sharing options...
Monti18 Posted August 20, 2021 Share Posted August 20, 2021 local function sgmod(self) local old_eat_state = self.actionhandlers[ACTIONS.EAT].deststate self.actionhandlers [ACTIONS.EAT].deststate = function(inst, action) local oldstate = old_eat_state(inst, action) if old_eat_state ~= nil and inst:HasTag("asdf") then return "throw" else return oldstate end end end AddStategraphPostInit("wilson", sgmod) AddStategraphPostInit("wilson_client", sgmod) You need to add ACTIONS.EAT into parentheses, as otherwise the game will look for a table named ACTIONS, but you want the table that is name ACTIONS.EAT. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now