Skip to content

Mod (function list)

Status: Implemented (API 1.24). Generated from client/clight/idl/clight_api.json by tools/docs/gen_api_reference.py; do not edit by hand. 11 functions, the newest from API 1.20.

Explanations and examples: Mod and lifecycle. Every function of the mod module is listed here in table order. The details of each function follow the table, in the same order. Side: where the function works (server, client, both). Context: the thread it may be called on (Conventions). Since: the API version that added it.

C function Lua Side Context Since
cl_mod_id cl.mod.id both ANY 1.0
cl_mod_version cl.mod.version both ANY 1.0
cl_mod_is_loaded cl.mod.is_loaded both ANY 1.0
cl_mod_config_dir cl.mod.config_dir both ANY 1.0
cl_lifecycle_phase cl.mod.lifecycle_phase both ANY 1.0
cl_environment cl.mod.environment both ANY 1.0
cl_server_running cl.mod.server_running both ANY 1.0
cl_is_dev cl.mod.is_dev both ANY 1.0
cl_current_context cl.mod.current_context both ANY 1.0
cl_cap_granted cl.mod.cap_granted both ANY 1.20
cl_cap_request cl.mod.cap_request both MAIN 1.20

cl_mod_id

cl_str cl_mod_id(void);

The calling mod’s id (engine-owned, lives for the process).

  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.id
  • C++: clight::mods::id() → std::string_view

cl_mod_version

cl_str cl_mod_version(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.version
  • C++: clight::mods::version() → std::string_view

cl_mod_is_loaded

bool cl_mod_is_loaded(cl_str id);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.is_loaded
  • C++: clight::mods::is_loaded(std::string_view id) → bool

cl_mod_config_dir

cl_result cl_mod_config_dir(char* buf, size_t cap, size_t* out_len);

Directory for the mod’s own files: <game>/config/<modid>/ (created on demand).

  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.config_dir
  • C++: clight::mods::config_dir() → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_lifecycle_phase

cl_phase cl_lifecycle_phase(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.lifecycle_phase
  • C++: clight::mods::lifecycle_phase() → cl_phase

cl_environment

cl_env cl_environment(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.environment
  • C++: clight::mods::environment() → cl_env

cl_server_running

bool cl_server_running(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.server_running
  • C++: clight::mods::server_running() → bool

cl_is_dev

bool cl_is_dev(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.is_dev
  • C++: clight::mods::is_dev() → bool

cl_current_context

cl_context cl_current_context(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.mod.current_context
  • C++: clight::mods::current_context() → cl_context

cl_cap_granted

bool cl_cap_granted(cl_str capability);

Capabilities from code (99_Appendix/07_Permissions_List): whether the player allowed one the mod declared.

  • Side: both. Context: ANY (any thread). Since: API 1.20.
  • Lua: cl.mod.cap_granted
  • C++: clight::mods::cap_granted(std::string_view capability) → bool

cl_cap_request

cl_result cl_cap_request(cl_str capability);

Asks the player now (client: opens the mod’s Permissions screen when the capability is still undecided; the answer fires mod.permission_changed). CL_OK: already allowed; CL_E_BUSY: asked, no answer yet; CL_E_PERMISSION_DENIED: the player said no before (they can change it on the Mods screen) or the mod did not declare it; CL_E_UNSUPPORTED: no screen to ask on (a dedicated server: grants come from config/clight/permissions.json).

  • Side: both. Context: MAIN (startup (main thread)). Since: API 1.20.
  • Lua: cl.mod.cap_request
  • C++: clight::mods::cap_request(std::string_view capability) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.