airzocker Posted May 19, 2023 Share Posted May 19, 2023 Hi, I am quite new to modding DST, but understand most of the basic concepts. My only question at the moment is, how I can get any function called every update frame. I've found the update.lua script with an Update(dt) function, but don't know how I can hook that function (to replace it with my own, call the old update and then do my stuff). If anyone could point me to a solution there would be great, this is what I tried last: local update = _G.require("update") AddGlobalClassPostConstruct("update", "Update", function(dt) update.Update(dt) print("test") end) Thanks in advance! Link to comment https://forums.kleientertainment.com/forums/topic/147868-need-help-with-frame-update-function/ Share on other sites More sharing options...
-LukaS- Posted May 19, 2023 Share Posted May 19, 2023 It depends on what you want to do. For stuff like new components or classes there are OnUpdate methods that are already ran automatically already. If you want to do something with a custom character or a custom mob there is an "updatelooper" component that could help you. If you still need to strictly hook up to the main update function you can do it like this: require("update") local old_Update = GLOBAL.Update GLOBAL.Update = function(...) print("Updating...") old_Update(...) end Link to comment https://forums.kleientertainment.com/forums/topic/147868-need-help-with-frame-update-function/#findComment-1635844 Share on other sites More sharing options...
airzocker Posted May 21, 2023 Author Share Posted May 21, 2023 Yes, that's what I needed, but maybe one of your other solutions could work at least as well. I want to make a client side mod to assist in making self-fertilizing giant crops, so one part is to display the different possible placements there are, but also it should monitor the plants for water and when they need care, so there should either be a timer or if that doesn't work just an alert when they need something. For the timer and checking on the crops you want to monitor I wanted to use the update function. Could one of the other solutions be better there? Link to comment https://forums.kleientertainment.com/forums/topic/147868-need-help-with-frame-update-function/#findComment-1636078 Share on other sites More sharing options...
-LukaS- Posted May 22, 2023 Share Posted May 22, 2023 Well, making a client sided mod like that would pose a bit of a problem because the farmplantstress component that manages plant stress is server sided. Link to comment https://forums.kleientertainment.com/forums/topic/147868-need-help-with-frame-update-function/#findComment-1636189 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