Lua C API Custom Type: Build a BitArray with Userdata and Metatables
Build a compact BitArray custom type with the Lua C API, including userdata storage, bit operations, index validation, metatables, and Lua-style access.
Build a compact BitArray custom type with the Lua C API, including userdata storage, bit operations, index validation, metatables, and Lua-style access.
Write robust Lua C functions with integer-indexed arrays, validated strings, stack discipline, and persistent state stored in the registry or upvalues.
Learn how Lua calls C functions through lua_CFunction and the stack API, including argument checks, pushed results, errors, registration, continuations, and loadable modules.
Start a lua_State, run code, manipulate and query the Lua C API stack, call functions safely, handle errors, register C functions, and understand allocation.
Register Cocos2d-x 3.17 Lua keyboard press and release callbacks with cc.EventListenerKeyboard, handle KeyCode values, attach the listener, and clean it up.
Use Lua coroutines, yield, and resume to build a cooperative task scheduler and coordinate non-blocking network I/O without confusing concurrency with parallel execution.
Use Lua's debug library to inspect functions, stack frames, local variables, upvalues, coroutines, and execution hooks while understanding performance and sandbox risks.
Learn Lua coroutine creation, resume and yield value flow, status transitions, iterator patterns, main-loop ownership, and event-driven program structure.
Understand Lua garbage collection through reachability, weak-key and weak-value tables, caches, finalizers, external resources, and practical collectgarbage controls.
Understand Lua _G and _ENV, dynamically named globals, undeclared-variable checks, isolated module environments, and explicit environments passed to load.