MCPcopy Index your code
hub / github.com/AndroidPatch/Module-Template-Lua / main

Function main

test/src/main.rs:6–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6fn main() -> LuaResult<()> {
7 println!("Hello, world!");
8
9 let lua = unsafe { Lua::unsafe_new() };
10
11 let globals = lua.globals();
12 let package_table: LuaTable = globals.get("package")?;
13 let cpath: String = package_table.get("cpath")?;
14
15
16 let script = fs::read_to_string("mylua.lua")
17 .expect("无法读取 mylua.lua,请确保文件在当前目录");
18
19 match lua.load(&script).exec() {
20 Ok(_) => println!("Lua 脚本执行完成"),
21 Err(e) => eprintln!("Lua 执行出错: {}", e),
22 }
23
24 Ok(())
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected