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
1
vote
1 answer

Luaj / Java: org.luaj.vm2.LuaError: loop or previous error loading module

I am learning the Luaj library and I am trying to implement the hyperbolic example in a unit test: @Test public void testHyperbolicLuaScriptExample() throws Exception { URL luaScriptUrl =…
David Williams
  • 8,388
  • 23
  • 83
  • 171
1
vote
0 answers

How to replicate "ordinary" call syntax for dynamically bound functions?

In the example below, the variable fn2_class represents a function that is to be loaded from a lua script, hence the var definition is necessary; It is not known in compile time what the actual function will be. The variable fn1_class represents the…
1
vote
1 answer

Running Java method from Luaj, "index expected, got string"

I'm working on a small project and was hoping to include lua scripting so users could create their own content. I've gotten it to mostly work. I can load scripts, run them, or run specific Lua methods from within java, etc. But I cannot figure out…
Aroymart
  • 31
  • 5
1
vote
2 answers

Inherit Java class from Luaj

Is it possible, in Luaj, to have a Lua class extend a Java class? I tried using getmetatable() on the binded class but apparently it returns nil. Here, Wizard is a Java class binded to Lua, and SetupWizard is the Lua class that I want to inherit…
wassup
  • 2,333
  • 2
  • 21
  • 30
1
vote
1 answer

How to load Lua-Filesystem and Lua-Penlight in Luaj

I have a program using the Luaj 3.0 libraries and I found some lua scripts I want to include, but they all require lua file system and penlight and whenever I try to use those libraries, it gives an error. Does anyone know how I am supposed to make…
Thomas
  • 871
  • 2
  • 8
  • 21
1
vote
1 answer

How do I use a Java-defined instance method in Lua?

I'm aware that it is possible to use Java defined static methods in Lua, due to the section "Libraries of Java Functions" on http://luaj.org/luaj/README.html. However I am struggling to find out how I can use the same for instance methods, I have a…
skiwi
  • 66,971
  • 31
  • 131
  • 216
1
vote
1 answer

LuaJ How to avoid overriding existing entries in Globals table

I am loading different Lua scripts using LuaJ into the globals environnment as follows in Java: globals = JmePlatform.standardGlobals(); LuaValue chunk = globals.load(new FileInputStream(luaScriptA), scriptName, "t", globals); chunk.call(); My…
AvdB
  • 65
  • 7
1
vote
2 answers

LuaJ loading two functions with the same name from two different LuaScripts

I have two Lua Scripts containing functions with the same name: luaScriptA: function init() print( 'This function was run from Script A' ) end luaScriptB: function init() print( 'This function was run from Script B' ) end I would like to load…
AvdB
  • 65
  • 7
1
vote
2 answers

Using LuaJ with Scala

I am attempting to use LuaJ with Scala. Most things work (actually all things work if you do them correctly!) but the simple task of setting object values has become incredibly complicated thanks to Scala's setter implementation. Scala: class…
1
vote
1 answer

How to pass class via reflection luaj - java

I use LuaJ, it contains a library: luajava which allows to pass a class via Reflection to lua enviroment. Do you know how to do this?? I noticed that there is a way to pass compiled class: _G.get("load").call(LuaValue.valueOf( "sys =…
user1685503
  • 173
  • 1
  • 10
1
vote
1 answer

NoClassDefFoundError with LuaJ

I'm trying to use LuaJ in an Android Studio (V0.2.3) project. I added the luaj-jme-3.0-beta.jar to the libs folder. Under "Project Structure" libraries I added the project library luaj-jme-3.0-beta.jar. In the build.gradle file under "dependancies"…
Andre
  • 31
  • 1
1
vote
0 answers

LuaJ: Combine multiple byte code chunks into single chunk

I have couple of pre-compiled lua-scripts, I would like to combine them and dump into single byte-code chunk. The pre-compiled scripts can be dependent on each other. In C, I could do this using: luaL_loadfile / luaL_loadfile / lua_dump But I am not…
Icarus3
  • 2,310
  • 14
  • 22
1
vote
1 answer

Java method for compiling Lua code with the LuaJ interpreter

http://luaj.org/luaj/README.html I'm using Luaj to run Lua code in a Java application. I'm getting some really slow results, so I want to try to compile the code before running it to calculate the actual proccesing time of a Lua script. The problem…
1
vote
1 answer

Android & LuaJ 3.0 binding

I am writing Android app using LuaJ 3.0. How can I bind my Java object to specific LuaClosure(for whole script)? Lua code: local = state or nil state.foo("some string") Java code: Prototype prototype; try{ InputStream stream =…
eluiandil
  • 13
  • 5
1
vote
1 answer

How do I compile LuaJ?

I have downloaded LuaJ but it wont compile right. It keeps saying import org.apache.bcel.* is not found during compiling. I setup my workspace by combining core and jse. All the import errors occur in the package org.luaj.vm2.luajc.JavaBuilder Any…
samrg472
  • 41
  • 6