com um clique
add-lua-binding-simple
// Add simple Cataclysm-BN Lua bindings for string_id types, enums, and basic read-only C++ types. Use when exposing straightforward C++ types to Lua.
// Add simple Cataclysm-BN Lua bindings for string_id types, enums, and basic read-only C++ types. Use when exposing straightforward C++ types to Lua.
Rewrite every `docs/*/game/changelog/{order}.stable-{semver}.md` from a ref range. Default `--limit=20`.
Add Cataclysm-BN Lua API bindings for global game functions, utility libraries, constants, callbacks, and domain-specific Lua namespaces.
Add comprehensive Cataclysm-BN Lua bindings for complex C++ classes with methods, inheritance, constructors, properties, operators, and ownership rules.
Write or modify Cataclysm-BN Deno/TypeScript scripts. Use for scripts, tools, migrations, generators, git hooks, and CLI utilities.
Quick reference for Cataclysm-BN Lua binding macros, Luna usertypes, libraries, documentation, type patterns, build steps, and common errors.
Add gettext context for ambiguous user-facing strings and repair affected PO translations.
| name | add-lua-binding-simple |
| description | Add simple Cataclysm-BN Lua bindings for string_id types, enums, and basic read-only C++ types. Use when exposing straightforward C++ types to Lua. |
| metadata | {"argument-hint":"TypeName [output-file]"} |
This skill helps you add Lua bindings for simple C++ types like string_id, enums, or basic classes.
my_type, my_enum)src/catalua_bindings_ids.cpp for IDs, or a relevant catalua_bindings_*.cpp)src/catalua_luna_doc.h// In src/catalua_luna_doc.h, add:
LUNA_ID( my_type, "MyType" )
// In src/catalua_bindings_ids.cpp, in reg_game_ids():
reg_id<my_type, has_int_id>( lua );
// Use true if type has int_id, false otherwise
// In src/catalua_luna_doc.h, add:
LUNA_ENUM( my_enum, "MyEnum" )
// In appropriate catalua_bindings_*.cpp file:
{
auto values = sol::initializers(
"VALUE_ONE", my_enum::VALUE_ONE,
"VALUE_TWO", my_enum::VALUE_TWO
);
luna::set_enum( lua, values );
}
Note: Use trailing return types and auto throughout (see patterns below).
// In src/catalua_luna_doc.h, add:
LUNA_DOC( my_class, "MyClass" )
// In appropriate catalua_bindings_*.cpp:
#define UT_CLASS my_class
{
auto ut = luna::new_usertype<UT_CLASS>(
lua,
luna::no_bases,
luna::no_constructor
);
// Add members
SET_MEMB( my_field ); // Mutable field
SET_MEMB_RO( const_field ); // Read-only field
SET_FX( my_method ); // Method
}
#undef UT_CLASS
DOC( "Description of the type" );
DOC( "Additional details about usage" );
SET_MEMB(name) - Mutable member variable or propertySET_MEMB_RO(name) - Read-only memberSET_FX(name) - Member functionSET_FX_T(name, signature) - Member function with specific overloadLUNA_ID(CppType, "LuaName") - For string_id/int_id pairsLUNA_DOC(CppType, "LuaName") - For documentation-only typesLUNA_ENUM(CppType, "LuaName") - For enum typesLUNA_VAL(CppType, "LuaName") - For value typesLUNA_PTR_VAL(CppType, "LuaName") - For pointer typesAfter adding bindings:
# Build
cmake --build --preset linux-full --target cataclysm-bn-tiles
# Test in Lua console (debug menu -> Lua console)
local my_id = MyTypeId.new("some_id")
print(my_id:str())
print(my_id:is_valid())
operator== and operator<src/catalua_luna_doc.h - Add LUNA_* macrosrc/catalua_bindings_ids.cpp - For ID typessrc/catalua_bindings_*.cpp - For other types (choose appropriate file)docs/en/mod/lua/explanation/lua_integration.mdsrc/catalua_bindings_ids.cppsrc/catalua_luna.h