Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods to open individual libraries not working. #146

Closed
giodamelio opened this issue May 6, 2017 · 1 comment
Closed

Methods to open individual libraries not working. #146

giodamelio opened this issue May 6, 2017 · 1 comment

Comments

@giodamelio
Copy link

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.
@giodamelio
Copy link
Author

I've got a patch for this mostly done, see #147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant