Desblat Posted March 7, 2014 Share Posted March 7, 2014 As the title says.I need to override "Stategragh.lua" from "scripts" folder, adding it into my mods "scripts" folder doesnt work. Is it passable to override Stategragh OR its parts? (espicially: StateGraphInstance:GoToState) Link to comment https://forums.kleientertainment.com/forums/topic/32433-overriding-stategragh/ Share on other sites More sharing options...
squeek Posted March 7, 2014 Share Posted March 7, 2014 (edited) 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 March 7, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/32433-overriding-stategragh/#findComment-426103 Share on other sites More sharing options...
Desblat Posted March 8, 2014 Author Share Posted March 8, 2014 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. Link to comment https://forums.kleientertainment.com/forums/topic/32433-overriding-stategragh/#findComment-426483 Share on other sites More sharing options...
squeek Posted March 8, 2014 Share Posted March 8, 2014 (edited) 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 March 8, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/32433-overriding-stategragh/#findComment-426551 Share on other sites More sharing options...
Desblat Posted March 8, 2014 Author Share Posted March 8, 2014 @squeekWorks! Thank you for help! Link to comment https://forums.kleientertainment.com/forums/topic/32433-overriding-stategragh/#findComment-426950 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