Module Interface
Jump to navigation
Jump to search
A SOMA user module combines a script class with a native module object. This guide traces the Light Flash Handler so you can recognize the two interfaces and call the module from a map script.
Follow a stock module
- Open
script/modules/LightFlashHandler.hps. Its class inherits the base, callback interface and its own typed interface:
class cScrLightFlashHandler : iScrUserModule, iScrUserModule_Interface, iScrLightFlashHandler_Interface
- Read
script/interfaces/UserModule_Interface.hps.iScrUserModulestores the nativecLuxUserModuleinmBaseObj;SetupBaseInterfaceassigns it andGetBase()returns it. - Read
script/modules/ModuleInterfaces.hps.iScrLightFlashHandler_Interfacedeclares the module’sAddoperation. This typed interface is the contract used by the helper, rather than the lifecycle callback interface. - Follow the position overload of
LightFlash_Addinhelpers/helper_modules.hps:
iScrLightFlashHandler_Interface @LFHandler = cast<iScrLightFlashHandler_Interface>( cLux_GetUserModuleFromID(eModuleType_LightFlashHandler) );
return LFHandler.Add(afTime, afFadeInTime, afFadeOutTime, avTargetPos, aColor, afRadius, afBrightness);
The helper retrieves the registered module, casts it to the typed interface and calls Add. A map script can use the helper without repeating that lookup and cast; see the light-flash example.
Make your own module
Follow User Modules Overview for the class, callbacks and Modules.cfg entry. Match the configured class name to your script class and use a unique module ID. SOMA’s inspected configuration already uses IDs 0–20, including 20 for the Eye Tracking Handler.