본문으로 건너뛰기
cccskills
무료GitHub에 공개

add-lua-binding-simple

Add Lua bindings that let Cataclysm-BN scripts access simple C++ types, including string IDs, enums, and basic read-only classes. The skill guides documentation macros, registration in the appropriate source file, and build and in-game checks.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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.

cataclysmbn/Cataclysm-BN스타 1,289(GitHub 1,289 + cccskills 0)

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • Exposing a C++ string ID to Lua
  • Registering an enum for Lua scripts
  • Making a basic read-only C++ type available to Lua

포함된 파일(1)

  • SKILL.md3.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Add Simple Lua Binding

This skill helps you add Lua bindings for simple C++ types like string_id, enums, or basic classes.

What You'll Do

  1. Identify the type you want to bind (e.g., my_type, my_enum)
  2. Choose the binding file (usually src/catalua_bindings_ids.cpp for IDs, or a relevant catalua_bindings_*.cpp)
  3. Add Luna documentation macro to src/catalua_luna_doc.h
  4. Register the binding in the appropriate function
  5. Build and test the changes

Step-by-Step Instructions

For string_id types

// 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

For enum types

// 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).

For simple data types (read-only)

// 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

Important Patterns

Documentation Comments

DOC( "Description of the type" );
DOC( "Additional details about usage" );

Member Macros

  • SET_MEMB(name) - Mutable member variable or property
  • SET_MEMB_RO(name) - Read-only member
  • SET_FX(name) - Member function
  • SET_FX_T(name, signature) - Member function with specific overload

Luna Macros

  • LUNA_ID(CppType, "LuaName") - For string_id/int_id pairs
  • LUNA_DOC(CppType, "LuaName") - For documentation-only types
  • LUNA_ENUM(CppType, "LuaName") - For enum types
  • LUNA_VAL(CppType, "LuaName") - For value types
  • LUNA_PTR_VAL(CppType, "LuaName") - For pointer types

Testing

After 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())

Common Issues

  1. Linker errors: Make sure the type header is included
  2. Missing comparison operators: Some types need operator== and operator<
  3. Build errors: Check macro syntax and semicolons

Files to Modify

  • src/catalua_luna_doc.h - Add LUNA_* macro
  • src/catalua_bindings_ids.cpp - For ID types
  • src/catalua_bindings_*.cpp - For other types (choose appropriate file)

References

  • Lua Integration Docs: docs/en/mod/lua/explanation/lua_integration.md
  • Existing Examples: src/catalua_bindings_ids.cpp
  • Luna System: src/catalua_luna.h

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use this skill to expose Cataclysm-BN game functions and utilities to Lua. It guides you through organizing functions into libraries, registering constants and callbacks, documenting the API, and handling errors so Lua scripts can use the new bindings.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Expose game or map functions to Lua
  • Add constants or utility functions to a Lua library
  • Let Lua scripts register callbacks
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Expose complex C++ classes to Lua by adding bindings for methods, inheritance, constructors, properties, and operators. The skill also guides ownership handling and registration so Lua scripts can use the intended class interface.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Exposing a C++ class to Lua
  • Binding inherited class methods
  • Adding constructors and properties
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Generate and synchronize player-facing changelog files across English, Korean, and Japanese from a Git reference range. It groups related changes, organizes featured updates and fixes, and preserves localized labels and relevant media.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Preparing changelogs between two Git refs
  • Updating English, Korean, and Japanese release notes
  • Grouping related player-facing changes
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Create or update Deno and TypeScript scripts for Cataclysm-BN, following the project’s conventions. Use it for command-line tools, data migrations, code or documentation generators, Git hooks, and other development utilities.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating a Deno command-line utility
  • Writing a data migration script
  • Generating code or documentation
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

Use this skill when the same English text needs different translations in different parts of an application. It adds gettext context at the source, updates affected PO entries, and guides validation of translations and formatting checks for the touched locale.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Separate translations for an ambiguous label
  • Add context to translated JSON strings
  • Update and validate affected PO entries
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

A practical reference for adding Lua bindings to Cataclysm-BN. Look up Luna macros, usertypes, libraries, type and function patterns, documentation helpers, build steps, and common errors, with examples showing how C++ types and functions become usable from Lua.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Look up Luna macros for a type
  • Register C++ methods and properties for Lua
  • Troubleshoot binding or build errors
cataclysmbn/Cataclysm-BN1.3천2026년 10월 27일 업데이트

cataclysmbn의 스킬 모두 보기

이 스킬의 문제 신고