Jump to content

Recommended Posts

You should always try to avoid overriding game files. See the API Examples mod for the built-in methods for modifying stategraphs.

From the comments of the example modmain.lua:

------------------------------------- Stategraph mod example----	AddStategraphState("stategraphname", newState)--	AddStategraphEvent("stategraphname", newEvent)--	AddStategraphActionHandler("stategraphname", newActionHandler)--		Use these functions to append new states, events, and actions handlers--		to existing states.----	AddStategraphPostInit("stategraphname", initfn)--		Use this to modify and mangle existing stategraphs, such as digging--		into existing states or appending new functionality to existing--		handlers.-- -----------------------------------
What are you trying to do? Edited by squeek

Thanks for replay.

What are you trying to do?

 

You see, I need to track any state changing (playing all anims by mob). So I can save state name as data. (we need this for true-lan-coop mod).

I do NOT need to rewrite stategraghs of mobs, I need to remake main Stategragh file. 

I need to add tracking function into main Stategragh file "Stategragh.lua", so I can track all the states changing. So I need to remake function "StateGraphInstance:GoToState(statename, params)"  at line 374.

Well, all the classes defined in stategraph.lua are global, so you should be able to do:

 

-- if in modmain, need thislocal require = GLOBAL.require-- require just in case stategraph.lua has not been loaded yetrequire "stategraph"-- if in modmain, need thislocal StateGraphInstance = GLOBAL.StateGraphInstance-- save the base functionlocal StateGraphInstance_GoToState_base = StateGraphInstance.GoToState-- overwrite the GoToState functionfunction StateGraphInstance:GoToState(statename, params)    print(tostring(self.inst).." going to state "..tostring(statename))    -- call the base function    StateGraphInstance_GoToState_base(self, statename, params)end
Edited by squeek

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