Module Interface

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 14:21, 2 October 2026 by TiMan (talk | contribs) (Add a sourced SOMA guide with explanations and stock-script examples.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

  1. Open script/modules/LightFlashHandler.hps. Its class inherits the base, callback interface and its own typed interface:
class cScrLightFlashHandler : iScrUserModule, iScrUserModule_Interface, iScrLightFlashHandler_Interface
  1. Read script/interfaces/UserModule_Interface.hps. iScrUserModule stores the native cLuxUserModule in mBaseObj; SetupBaseInterface assigns it and GetBase() returns it.
  2. Read script/modules/ModuleInterfaces.hps. iScrLightFlashHandler_Interface declares the module’s Add operation. This typed interface is the contract used by the helper, rather than the lifecycle callback interface.
  3. Follow the position overload of LightFlash_Add in helpers/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.

See also