Skip to content

Config (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. 16 functions, the newest from API 1.4.

Explanations and examples: Config. Every function of the config 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_config_open cl.config.open both ANY 1.0
cl_config_define_bool cl.config.define_bool both ANY 1.0
cl_config_define_i32 cl.config.define_i32 both ANY 1.0
cl_config_define_f64 cl.config.define_f64 both ANY 1.0
cl_config_define_str cl.config.define_str both ANY 1.0
cl_config_get_bool cl.config.get_bool both ANY 1.0
cl_config_get_i32 cl.config.get_i32 both ANY 1.0
cl_config_get_f64 cl.config.get_f64 both ANY 1.0
cl_config_get_str cl.config.get_str both ANY 1.0
cl_config_set_bool cl.config.set_bool both ANY 1.0
cl_config_set_i32 cl.config.set_i32 both ANY 1.0
cl_config_set_f64 cl.config.set_f64 both ANY 1.0
cl_config_set_str cl.config.set_str both ANY 1.0
cl_config_save cl.config.save both ANY 1.0
cl_config_reload cl.config.reload both ANY 1.4
cl_config_comment cl.config.comment both ANY 1.4

cl_config_open

cl_result cl_config_open(cl_config_scope scope, cl_config* out);

v0.1: config/<modid>.json (flat dotted keys). Defines create missing keys with their default.

  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.open
  • C++: clight::config::open(cl_config_scope scope) → Expected<Config>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_define_bool

cl_result cl_config_define_bool(cl_config c, cl_str path, bool def);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.define_bool, config:define_bool(...)
  • C++: Config::define_bool(std::string_view path, bool def) → Expected<void>; clight::config::define_bool(Config c, std::string_view path, bool def) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_define_i32

cl_result cl_config_define_i32(cl_config c, cl_str path, int32_t def, int32_t min, int32_t max);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.define_i32, config:define_i32(...)
  • C++: Config::define_i32(std::string_view path, int32_t def, int32_t min, int32_t max) → Expected<void>; clight::config::define_i32(Config c, std::string_view path, int32_t def, int32_t min, int32_t max) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_define_f64

cl_result cl_config_define_f64(cl_config c, cl_str path, double def, double min, double max);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.define_f64, config:define_f64(...)
  • C++: Config::define_f64(std::string_view path, double def, double min, double max) → Expected<void>; clight::config::define_f64(Config c, std::string_view path, double def, double min, double max) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_define_str

cl_result cl_config_define_str(cl_config c, cl_str path, cl_str def);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.define_str, config:define_str(...)
  • C++: Config::define_str(std::string_view path, std::string_view def) → Expected<void>; clight::config::define_str(Config c, std::string_view path, std::string_view def) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_get_bool

bool cl_config_get_bool(cl_config c, cl_str path);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.get_bool, config:get_bool(...)
  • C++: Config::get_bool(std::string_view path) → bool; clight::config::get_bool(Config c, std::string_view path) → bool

cl_config_get_i32

int32_t cl_config_get_i32(cl_config c, cl_str path);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.get_i32, config:get_i32(...)
  • C++: Config::get_i32(std::string_view path) → int32_t; clight::config::get_i32(Config c, std::string_view path) → int32_t

cl_config_get_f64

double cl_config_get_f64(cl_config c, cl_str path);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.get_f64, config:get_f64(...)
  • C++: Config::get_f64(std::string_view path) → double; clight::config::get_f64(Config c, std::string_view path) → double

cl_config_get_str

cl_result cl_config_get_str(cl_config c, cl_str path, char* buf, size_t cap, size_t* out_len);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.get_str, config:get_str(...)
  • C++: Config::get_str(std::string_view path) → Expected<std::string>; clight::config::get_str(Config c, std::string_view path) → 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_config_set_bool

cl_result cl_config_set_bool(cl_config c, cl_str path, bool v);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.set_bool, config:set_bool(...)
  • C++: Config::set_bool(std::string_view path, bool v) → Expected<void>; clight::config::set_bool(Config c, std::string_view path, bool v) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_set_i32

cl_result cl_config_set_i32(cl_config c, cl_str path, int32_t v);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.set_i32, config:set_i32(...)
  • C++: Config::set_i32(std::string_view path, int32_t v) → Expected<void>; clight::config::set_i32(Config c, std::string_view path, int32_t v) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_set_f64

cl_result cl_config_set_f64(cl_config c, cl_str path, double v);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.set_f64, config:set_f64(...)
  • C++: Config::set_f64(std::string_view path, double v) → Expected<void>; clight::config::set_f64(Config c, std::string_view path, double v) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_set_str

cl_result cl_config_set_str(cl_config c, cl_str path, cl_str v);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.set_str, config:set_str(...)
  • C++: Config::set_str(std::string_view path, std::string_view v) → Expected<void>; clight::config::set_str(Config c, std::string_view path, std::string_view v) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_save

cl_result cl_config_save(cl_config c);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.config.save, config:save(...)
  • C++: Config::save() → Expected<void>; clight::config::save(Config c) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_reload

cl_result cl_config_reload(cl_config c);

Reads the file again (values the player edited), keeping the definitions; fires config.reloaded when it changed.

  • Side: both. Context: ANY (any thread). Since: API 1.4.
  • Lua: cl.config.reload, config:reload(...)
  • C++: Config::reload() → Expected<void>; clight::config::reload(Config c) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_config_comment

cl_result cl_config_comment(cl_config c, cl_str path, cl_str comment);

A short help line shown under the option in the config screen.

  • Side: both. Context: ANY (any thread). Since: API 1.4.
  • Lua: cl.config.comment, config:comment(...)
  • C++: Config::comment(std::string_view path, std::string_view comment) → Expected<void>; clight::config::comment(Config c, std::string_view path, std::string_view comment) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.