Closed
Description
ce68dd4 added a bunch of functions to allow easily loading specific Lua libraries. They don't seem to be working right. This works fine.
extern crate hlua;
use hlua::Lua;
fn main() {
let mut lua = Lua::new();
lua.openlibs();
let num: i32 = lua.execute("return string.len(\"aaa\")").unwrap();
println!("{}", num);
}
If you try to load just the string library with the open_string
function, it doesn't seem to load the library.
extern crate hlua;
use hlua::Lua;
fn main() {
let mut lua = Lua::new();
lua.open_string();
let num: i32 = lua.execute("return string.len(\"aaa\")").unwrap();
println!("{}", num);
}
This code returns the following error
Compiling lua_test v0.1.0 (file:///home/giodamelio/tmp/lua_test)
Finished dev [unoptimized + debuginfo] target(s) in 4.88 secs
Running `target/debug/lua_test`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ExecutionError("[string \"chunk\"]:1: attempt to index global \'string\' (a nil value)")', /checkout/src/libcore/result.rs:859
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Metadata
Metadata
Assignees
Labels
No labels