Jump to content

Recommended Posts

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.

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 by zUsername

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

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