Detective – Support Mod

If you liked this item, please rate it up on Steam Workshop page.

Author: Nitroman

Last revision: 27 Feb at 14:38 UTC

File size: 9.62 KB

On Steam Workshop

Description:

This is a support mod, it doesn’t impact gameplay and isn’t useful if you are not a modder.

You want to check if another mod is loaded to adapt your mod’s behavior, but there’s no built-in way to do it? Detective is here for you.


This mod provides:

– A shared registry on game.Detective that mods can register with and query.
– Lookup by mod name or Steam Workshop ID.
– Mods work fine whether Detective is installed or not.


Usage:

Register your mod (in POST_MODS_LOADED):

local registerHandler = {} function registerHandler:handleEvent(_, _) if not game.Detective then return end game.Detective.register("YourMod", { version = "1.0.0" }, 123456789) end events:addDirectReceiver(registerHandler, { game.EVENTS.POST_MODS_LOADED })

Check if another mod is loaded (in ON_START_FINISH):

local checkHandler = {} function checkHandler:handleEvent(_, _) if not game.Detective then return end if game.Detective.check("OtherMod") then — adapt behavior end end events:addDirectReceiver(checkHandler, { game.EVENTS.ON_START_FINISH })


Compatibility: Compatible with all mods.