开发者

LuaJava not running script until close

开发者 https://www.devze.com 2023-02-24 20:48 出处:网络
I have added loading and executing of lua scr开发者_如何学JAVAipts to java using LuaJava, but when I run a script such as:

I have added loading and executing of lua scr开发者_如何学JAVAipts to java using LuaJava, but when I run a script such as:

print("works")

It won't show up until after the program has stopped running.

This is my Java code:

LuaState state = LuaStateFactory.newLuaState();
state.openLibs();
state.LdoString(scripts.get(name));
state.close();

EDIT: Fixed using this code:

LuaState state = LuaStateFactory.newLuaState();
state.openLibs();
state.LloadString(scripts.get(name));
state.call(0, 0);
state.close();


The stream used for stdout/stderr is buffering the data. You'll need to explicitly flush the buffer in question. For example. you might try 'state.LdoString("io.flush();");

0

精彩评论

暂无评论...
验证码 换一张
取 消