27 lines
676 B
Rust
27 lines
676 B
Rust
use rlua::{Function, Lua, MetaMethod, Result, UserData, UserDataMethods, Variadic};
|
|
use std::env;
|
|
use std::fs;
|
|
|
|
|
|
|
|
pub fn execute(filename : String) -> Lua {
|
|
println!("loading lua file {}...", filename);
|
|
let lua = Lua::new();
|
|
|
|
let src = fs::read_to_string(filename).expect("loaded lua file :3");
|
|
|
|
|
|
lua.context(|lua_ctx| {
|
|
let _globals = lua_ctx.globals();
|
|
let _result = lua_ctx.load(&src).exec().expect("failed to execute file!");
|
|
});
|
|
|
|
return lua;
|
|
}
|
|
|
|
pub fn call(lua : Lua, name : String) {
|
|
lua.context(|lua_ctx| {
|
|
let code : String = format!("{}()", name);
|
|
assert!(lua_ctx.load(&code).exec().is_err());
|
|
});
|
|
} |