Skip to content

Mixins (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.2.

Explanations and examples: Mixins. Every function of the mixin 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_mixin_inject cl.mixin.inject(target, at, fn, opts) (and head / ret / wrap / …) both ANY 1.2
cl_mixin_remove h:remove(), cl.mixin.remove(h) both ANY 1.2
cl_mixin_target_lookup (done by cl.mixin.inject) both ANY 1.2
cl_mixin_info cl.mixin.info(name) both ANY 1.2
cl_mixin_cancel ci:cancel() both ANY 1.2
cl_mixin_set_return ci:set_return(v) / ci.ret = v both ANY 1.2
cl_mixin_call_original ci:call_original() both ANY 1.2
cl_mixin_invoke cl.mixin.invoke(target, self, args) both ANY 1.2
cl_accessor_lookup cl.accessor(name) both ANY 1.2
cl_accessor_get cl.accessor(name):get(handle) both TICK 1.2
cl_accessor_set cl.accessor(name):set(handle, v) both TICK 1.2

cl_mixin_inject

cl_result cl_mixin_inject(const cl_mixin_desc* desc, cl_mixin* out);

Attaches a callback to a target (CLL-7001 unknown target, CLL-7002 unknown site; overwrite/exclusive only before lifecycle.registries_frozen).

  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: cl.mixin.inject(target, at, fn, opts) (and head / ret / wrap / …)
  • C++: clight::mixin::inject(const cl_mixin_desc* desc) → Expected<Mixin>
  • 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_mixin_remove

cl_result cl_mixin_remove(cl_mixin m);
  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: h:remove(), cl.mixin.remove(h)
  • C++: Mixin::remove() → Expected<void>; clight::mixin::remove(Mixin m) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_mixin_target_lookup

cl_result cl_mixin_target_lookup(cl_str name, cl_mixin_target* out);

“entity.living.hurt” (or an alias) -> its id.

  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: (done by cl.mixin.inject)
  • C++: clight::mixin::target_lookup(std::string_view name) → Expected<cl_mixin_target>
  • 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_mixin_info

cl_result cl_mixin_info(cl_str name, cl_mixin_target_info* out);
  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: cl.mixin.info(name)
  • C++: clight::mixin::info(std::string_view name, cl_mixin_target_info* out) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_mixin_cancel

cl_result cl_mixin_cancel(cl_mixin_ci* ci);

Only inside a callback: CL_E_WRONG_PHASE outside, CL_E_UNSUPPORTED where cancelling isn’t defined.

  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: ci:cancel()
  • C++: clight::mixin::cancel(cl_mixin_ci* ci) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_mixin_set_return

cl_result cl_mixin_set_return(cl_mixin_ci* ci, const void* value, size_t size);
  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: ci:set_return(v) / ci.ret = v
  • C++: clight::mixin::set_return(cl_mixin_ci* ci, const void* value, size_t size) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_mixin_call_original

cl_result cl_mixin_call_original(cl_mixin_ci* ci);

wrap / overwrite / call: runs the rest of the chain (and finally vanilla) with the current frame values.

  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: ci:call_original()
  • C++: clight::mixin::call_original(cl_mixin_ci* ci) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_mixin_invoke

cl_result cl_mixin_invoke(cl_mixin_target target, uint64_t self, void* args, void* ret);

Calls an @invokable target (other mods’ mixins on it run too). args: the target’s cl_mx_<t>_args.

  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: cl.mixin.invoke(target, self, args)
  • C++: clight::mixin::invoke(cl_mixin_target target, uint64_t self, void* args, void* ret) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_accessor_lookup

cl_result cl_accessor_lookup(cl_str name, cl_accessor* out);
  • Side: both. Context: ANY (any thread). Since: API 1.2.
  • Lua: cl.accessor(name)
  • C++: clight::mixin::accessor_lookup(std::string_view name) → Expected<cl_accessor>
  • 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_accessor_get

cl_result cl_accessor_get(uint64_t self, cl_accessor a, void* out, size_t size);
  • Side: both. Context: TICK (tick thread). Since: API 1.2.
  • Lua: cl.accessor(name):get(handle)
  • C++: clight::mixin::accessor_get(uint64_t self, cl_accessor a, void* out, size_t size) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_accessor_set

cl_result cl_accessor_set(uint64_t self, cl_accessor a, const void* value, size_t size);
  • Side: both. Context: TICK (tick thread). Since: API 1.2.
  • Lua: cl.accessor(name):set(handle, v)
  • C++: clight::mixin::accessor_set(uint64_t self, cl_accessor a, const void* value, size_t size) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.