Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

this crate is for cc wasm mod

Usage

  • add this crate as a dependence.
  • set [lib]-crate-type to "cdylib"
  • build with --target wasm32-wasip1 (rustc 1.97+ renamed wasm32-wasi to wasm32-wasip1)
  • copy target/wasm32-wasip1/release/[crate name].wasm to .minecraft/wasm/
  • load it in game: wasm.load_wasm("[crate name]") or run exec_wasm [crate name] in a computer shell

Features (all opt-in, default = coroutine + eval + addon)

  • coroutine — provides tick / stopped exports so exec_wasm / exec_wasm_aot can drive your module's event loop. required when the wasm program is driven by exec_wasm.lua.
  • eval — call back into Lua: eval_string / eval_result round-trips between wasm and Lua. no longer forces coroutine; can be enabled alone.
  • addon — local monitor (LocalMonitor), vec2d, time, ColorId helpers etc.
  • debug — debug output helpers (show_str / show_debug).

Example

please see the example here (minesweeper / pic_display / txt_display / python / obj_demo / type_test).

Notes

  • Lua numbers always arrive as f64; numeric adaptation (cross-type conversion + int/range checks) lives in the i32/i64/f32/f64 imports of lua_api (Number accepts 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages