Questions tagged [luaj]

Luaj is a pure Java implementation of a Lua interpreter (for versions 5.1 and now 5.2)

  • Java-centric implementation of lua vm built to leverage standard Java features.
  • Lightweight, high performance execution of lua.
  • Multi-platform to be able to run on JME, JSE, or JEE environments.
  • Complete set of libraries and tools for integration into real-world projects.
  • Dependable due to sufficient unit testing of vm and library features.

Luaj is written for JME and JSE, with string, table, package, math, io, os, debug, coroutine & luajava libraries, JSR-223 bindings, all metatags, weak tables and unique direct lua-to-java-bytecode compiling.

https://sourceforge.net/projects/luaj/

and

http://www.luaj.org/luaj/3.0/README.html#1

99 questions
18
votes
1 answer

Luaj: How to Import or Require a Lua Function Library

In the Java LuaJ library I would like to know how to require or import a lua script of functions in another lua script called by a lua closure through Java. For example this does not work: public static LuaValue runInputStreamLua(InputStream…
David Williams
  • 8,388
  • 23
  • 83
  • 171
8
votes
1 answer

How can I pass objects to an exposed luaj function?

I am trying to build a controller using Luaj + java. I have the following java classes public class Duck { public void talk() { System.out.println("Duck quacks!"); } public void walk() { System.out.println("Duck walks!"); } } public class…
6
votes
0 answers

robovm 0.0.14 NullPointerException problems

I have migrated my libgdx(1.3), maven, robovm project from 0.0.13 to 0.0.14 for supporting IOS 8 devices. I have modified my robovm.xml file according to release notes and can run on IOS 8 device but getting NullPointerException's in several places.…
Fuat Coşkun
  • 1,045
  • 8
  • 18
5
votes
2 answers

Is it possible to execute a single lua statement from a host program?

I am trying to embed a lua-based script system into my game engine. I would like the scripting to be able to have both blocking and non-blocking commands, for example: character.walkTo(24, 359); // Blocks until character arrives c = 35; // Non…
Lake
  • 4,072
  • 26
  • 36
5
votes
2 answers

LuaJ: Unable to call 'require' function in Lua script

There is a really good chance that I am doing something bizarre that is causing this error. The following simple example fails: --> thingy.lua function doThing() print( "Thing has been done." ); end and --> test.lua require( "thingy" ); When…
Nathan
  • 585
  • 6
  • 12
5
votes
2 answers

Passing arguments to a lua function with luaj

I'm trying to call a lua function in a Java program using LuaJ. It works fine when I'm not passing any arguments to the closure: String script = "print 'Hello World!'"; InputStream input = new ByteArrayInputStream(script.getBytes()); Prototype…
nerdinand
  • 876
  • 12
  • 21
4
votes
1 answer

LuaJ array/list type safety

So using LuaJ. If I pass, from Java to Lua, a userdata List with type T, Luaj still allows insertion into that array of any type of object via the :add function. For example: Java code: import java.util.ArrayList; import…
Dakusan
  • 6,504
  • 5
  • 32
  • 45
4
votes
3 answers

LuaJ - Calling a Java method

I have a Java Class with a method called test: public class MyClass() { public String test() { //Do Something } } Then, I want to call the test method in my Lua script. In order to do it, I did: Globals globals =…
diegocmaia
  • 79
  • 1
  • 10
4
votes
3 answers

Java visibility: final static non-threadsafe collection changes after construction

I found the following code snippet in luaj and I started to doubt that if there is a possibility that changes made to the Map after it has been constructed might not be visible to other threads since there is no synchronization in place. I know that…
Kin Cheung
  • 870
  • 10
  • 20
4
votes
1 answer

How can I abandon a LuaJ coroutine LuaThread?

I am experimenting with a game mechanic in which players can run scripts on in-game computers. Script execution will be resource limited at a gameplay level to some amount of instructions per tick. The following proof-of-concept demonstrates a basic…
David Lewis
  • 161
  • 6
4
votes
5 answers

Lua / Java / LuaJ - Handling or Interrupting Infinite Loops and Threads

I'm using LuaJ to run user-created Lua scripts in Java. However, running a Lua script that never returns causes the Java thread to freeze. This also renders the thread uninterruptible. I run the Lua script…
xikkub
  • 1,641
  • 1
  • 16
  • 28
4
votes
1 answer

How can I add functions to _G that run java code using Luaj?

I want to add functions to the _G that can run Java code. I'm using Luaj and it can already run user written Lua code, but I want to add apis that'll allow the user to interact with the game world.
Rule
  • 105
  • 1
  • 10
3
votes
2 answers

Terminate unresponsive thread

I have built a java application and have a thread thats doing something in the background when a button was pressed. The problem is, that thread might lock up, perhaps due to an infinite loop. Is there a way I can force terminate that thread? EDIT:…
Dave
  • 7,283
  • 12
  • 55
  • 101
3
votes
2 answers

How to excute a Lua compiled file and call functions with custom global environment in LuaJ?

I have precompiled Lua script with ScriptEngine. private void preCompile(){ ScriptEngineManager manager = new ScriptEngineManager(); engine = manager.getEngineByName("luaj"); if(engine instanceof Compilable){ try { …
RayEden
  • 31
  • 2
3
votes
2 answers

How to evaluate a simple expression with Luaj?

I'm completely new to Lua. I have a very simple script: "var = 1" I didn't find out how to get the result of this expression from my java app: "var == 3 and 100 or -1" I have started with this: Globals globals =…
SWAppDev
  • 248
  • 1
  • 3
  • 13
1
2 3 4 5 6 7