Core (function list)
Status: Implemented (API 1.24). Generated from
client/clight/idl/clight_api.jsonbytools/docs/gen_api_reference.py; do not edit by hand. 12 functions, the newest from API 1.1.
Explanations and examples: Core types, Mod and lifecycle. Every function of the core 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_api_version |
cl.core.api_version |
both | ANY | 1.0 |
cl_game_version |
cl.core.game_version |
both | ANY | 1.0 |
cl_engine_build |
cl.core.engine_build |
both | ANY | 1.0 |
cl_log |
cl.log(...), cl.log.warn(...) |
both | ANY | 1.0 |
cl_last_error |
(errors are raised as cl.Error) |
both | ANY | 1.0 |
cl_last_error_message |
(errors are raised as cl.Error) |
both | ANY | 1.0 |
cl_alloc |
(not needed) | both | ANY | 1.0 |
cl_free |
(not needed) | both | ANY | 1.0 |
cl_time_now_ns |
cl.core.time_now_ns |
both | ANY | 1.0 |
cl_ident_intern |
cl.core.ident_intern |
both | ANY | 1.0 |
cl_ident_name |
cl.core.ident_name |
both | ANY | 1.0 |
cl_core_has |
cl.core.has |
both | ANY | 1.1 |
cl_api_version
uint32_t cl_api_version(void);
The engine’s CLight API version, (major << 16) | minor.
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.api_version - C++:
clight::core::api_version()→uint32_t
cl_game_version
cl_str cl_game_version(void);
“26.3”
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.game_version - C++:
clight::core::game_version()→std::string_view
cl_engine_build
cl_str cl_engine_build(void);
“seecraft 0.x (git abc1234)”
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.engine_build - C++:
clight::core::engine_build()→std::string_view
cl_log
void cl_log(cl_log_level level, cl_str message);
Writes a line to logs/latest.log with the calling mod’s [modid] prefix.
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.log(...),cl.log.warn(...) - C++:
clight::core::log_(cl_log_level level, std::string_view message)→void
cl_last_error
cl_result cl_last_error(void);
The last error recorded on this thread by a getter that cannot return cl_result.
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua: (errors are raised as
cl.Error) - C++:
clight::core::last_error()→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_last_error_message
cl_result cl_last_error_message(char* buf, size_t cap, size_t* out_len);
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua: (errors are raised as
cl.Error) - C++:
clight::core::last_error_message()→Expected<std::string> - Writes a string:
buf/cap/out_len(a too small buffer returnsCL_E_BUFFER_TOO_SMALLwith the needed length in*out_len). Lua and C++ return the string. - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_alloc
void* cl_alloc(size_t size, size_t align);
Engine allocator, tracked per mod (WASM: maps to the guest’s own malloc, implemented in clight.h).
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua: (not needed)
- C++:
clight::core::alloc(size_t size, size_t align)→void*
cl_free
void cl_free(void* p);
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua: (not needed)
- C++:
clight::core::free_(void* p)→void
cl_time_now_ns
uint64_t cl_time_now_ns(void);
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.time_now_ns - C++:
clight::core::time_now_ns()→uint64_t
cl_ident_intern
cl_ident cl_ident_intern(cl_str id);
Interns “namespace:path” (a missing namespace means “minecraft”).
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.ident_intern - C++:
clight::core::ident_intern(std::string_view id)→cl_ident
cl_ident_name
cl_result cl_ident_name(cl_ident id, char* buf, size_t cap, size_t* out_len);
- Side: both. Context: ANY (any thread). Since: API 1.0.
- Lua:
cl.core.ident_name - C++:
clight::core::ident_name(cl_ident id)→Expected<std::string> - Writes a string:
buf/cap/out_len(a too small buffer returnsCL_E_BUFFER_TOO_SMALLwith the needed length in*out_len). Lua and C++ return the string. - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_core_has
bool cl_core_has(cl_str name);
Whether an optional feature or module is available in this engine and this process (05_Language_Bindings). Names: a module (“gui”, “sound”, …; client-only modules are false on a dedicated server), a function as “<module>.<verb>” (“level.set_block”), a runtime (“lua”, “wasm”), “side.client” / “side.server”, or a feature (“hot_reload.lua”, “hot_reload.wasm”, “rml.overlay”, “net.http”, “fs.data”, “mixins”). Unknown names are false.
- Side: both. Context: ANY (any thread). Since: API 1.1.
- Lua:
cl.core.has - C++:
clight::core::has(std::string_view name)→bool