this crate is for cc wasm mod
- add this crate as a dependence.
- set
[lib]-crate-typeto"cdylib" - build with
--target wasm32-wasip1(rustc 1.97+ renamedwasm32-wasitowasm32-wasip1) - copy
target/wasm32-wasip1/release/[crate name].wasmto.minecraft/wasm/ - load it in game:
wasm.load_wasm("[crate name]")or runexec_wasm [crate name]in a computer shell
coroutine— providestick/stoppedexports soexec_wasm/exec_wasm_aotcan drive your module's event loop. required when the wasm program is driven byexec_wasm.lua.eval— call back into Lua:eval_string/eval_resultround-trips between wasm and Lua. no longer forcescoroutine; can be enabled alone.addon— local monitor (LocalMonitor),vec2d,time,ColorIdhelpers etc.debug— debug output helpers (show_str/show_debug).
please see the example here (minesweeper / pic_display / txt_display / python / obj_demo / type_test).
- Lua numbers always arrive as f64; numeric adaptation (cross-type conversion + int/range
checks) lives in the
i32/i64/f32/f64imports oflua_api(Numberaccepts anything). - strings are passed as raw bytes (utf8-safe); the CC terminal display layer may still show
non-ascii as
?, but data round-trips losslessly.