Lua global print value is nil
Closed this issue · 2 comments
JesseKPhillips commented
When attempting to print from Lua the result is an error:
luad.error.LuaError: [string "print("Hello")"]:1: attempt to call global 'print'
(a nil value)
import luad.all;
import std.stdio;
void main() {
auto lua = new LuaState;
lua.doString("print(\"Hello\")");
}
JakobOvrum commented
You need to call .openLibs before using the standard library:
auto lua = new LuaState;
lua.openLibs();
lua.doString(`print("Hello")`);
(Also note how wysiwyg strings are useful with doString)
JesseKPhillips commented
Thought I might have been doing something wrong. Thank you for the fast turn around.