SenL Posted February 4, 2016 Share Posted February 4, 2016 My mod (a character mod) needs to "cancel" the "AFK detection" effect when he is in certain form where it drains hunger. With AFK Detection mod enabled and character is "AFK" the hunger drain is stopped. This is like "cheating." Is it possible to call this mod's "afk" component function? If yes, how? (In this case, I believe it's ResetAFKTime() (passing in false as the only parameter)) Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/ Share on other sites More sharing options...
zUsername Posted February 4, 2016 Share Posted February 4, 2016 (edited) Open your modmain.lua then add: local AFKDetection = false for _, moddir in ipairs(GLOBAL.KnownModIndex:GetModsToLoad()) do if string.match(GLOBAL.KnownModIndex:GetModInfo(moddir).name, "AFK Detection") then AFKDetection = true end end if GLOBAL.TheWorld.ismastersim and AFKDetection then AddPrefabPostInit("yourprefabchacter", function(inst) if inst.components.afk ~= nil then inst.components.afk.stop_hunger = false end end) end Edited February 4, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/#findComment-717272 Share on other sites More sharing options...
SenL Posted February 4, 2016 Author Share Posted February 4, 2016 Hm, thanks but I don't want to remove the component. I just want to cancel the afk effect. I could just do health:SetInvincible( false ) hunger:Resume( ) ... Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/#findComment-717273 Share on other sites More sharing options...
zUsername Posted February 4, 2016 Share Posted February 4, 2016 I'm just edited my post. Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/#findComment-717274 Share on other sites More sharing options...
zUsername Posted February 4, 2016 Share Posted February 4, 2016 (edited) I'm just edited my post. Edited February 4, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/#findComment-717275 Share on other sites More sharing options...
SenL Posted February 4, 2016 Author Share Posted February 4, 2016 Thanks. I found out another way without changing that mod's config (stop_hunger). if GLOBAL.KnownModIndex:IsModEnabled("workshop-398858801") then --AFK Detection if inst.components.afk ~= nil then inst.components.afk:ResetAFKTime(false) end end Seems to work. When I go to this form while "char is AFK", I immediately get "char is no longer AFK". Link to comment https://forums.kleientertainment.com/forums/topic/63732-is-it-possible-to-call-other-mods-function-a-custom-component/#findComment-717279 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