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
3
votes
2 answers

Getting print calls in LuaJ

I'm writing a Java program which uses Lua scripts to determine what to output to certain areas of the program. Currently, my code looks as such: Globals globals = JsePlatform.standardGlobals(); LuaValue chunk = globals.loadfile(dir.getAbsolutePath()…
Joseph Boyle
  • 560
  • 5
  • 15
3
votes
1 answer

Luaj attempt to index ? (a function value)

I am trying to compile Lua code that has two functions which I want to invoke and get some information from but when I use invokemethod on the LuaValue object, I get this error LuaError: attempt to index ? (a function value) The code is inside a…
Nicolas Martel
  • 1,641
  • 3
  • 19
  • 34
3
votes
4 answers

Luaj os.time() return milliseconds

os.time() in Luaj returns time in milliseconds, but according to lua documentation, it should return time in seconds. Is this a bug in Luaj? And Can you suggest a workaround that will work with Luaj(for java) and real Lua(c/c++)? because i have…
bysreg
  • 793
  • 1
  • 9
  • 30
3
votes
3 answers

Loading java library functions to Luaj

I am stuck with loading java functions so that it can be called from lua file using luaj. What i currently do is create something like this : in some_package/aif.java : package some_package; public class aif extends TwoArgFunction { public…
bysreg
  • 793
  • 1
  • 9
  • 30
2
votes
2 answers

Lua Newbie stuck on simple input

I'm trying to pick up Lua programming but I'm stuck on something that's probably trivial. I'm prototyping some Lua scripts using Kahlua from IntelliJ Idea 11 and I keep getting errors whenever I try to use io.read(). Here's what I currently…
Cliff
  • 10,586
  • 7
  • 61
  • 102
2
votes
2 answers

LuaJ Import Lua Methods

I'm using LuaJ, and I have a .lua file filled with a bunch of functions. How do I import these functions to use in Java with LuaJ?
Anonymous
  • 351
  • 1
  • 5
  • 16
2
votes
1 answer

Is it possible to access userdata properties and functions?

I want to return an instance of a Java class as userdata to my lua script. Would it be possible to access properties and functions of this instance from lua? Like so local car =…
boop
  • 7,413
  • 13
  • 50
  • 94
2
votes
1 answer

Multiple return values in LuaJ

I've been trying to find a way to return multiple values from a Java method in LuaJ. That is, return multiple values from Java to be retrieved inside Lua code. Once again... What I mean is: public LuaValue call() { Dimension size =…
2
votes
1 answer

LuaJ vs Pure Java Performance Comparison

I am planning to integrate Lua into my java application. Could you please tell about performance comparison between implementing a script in LuaJ vs pure java. Are there other alternatives which have better performance ?
josh
  • 13,793
  • 12
  • 49
  • 58
2
votes
2 answers

How to solve lua errors: "attempt to index ? (a nil value)"

There has been a lot of post about this kind of error and most people say it is related to table and array indexing problems. But I am not using tables at all, I am just trying to call a library function I made and I get this error. Here is the lua…
larienna
  • 151
  • 4
  • 12
2
votes
1 answer

Requiring other lua scripts from within a Lua script using LuaJ on Android

I'm having trouble calling Lua scripts from Java via LuaJ on Android that require other Lua scripts. I think it's something to do with my current working directory. What I'm trying in Java: InputStream input =…
mnemy
  • 43
  • 7
2
votes
0 answers

Does LuaJ support __gc metamethod functionality

When experimenting with LuaJ on some personal (trivial) projects, I found that I seemed unable to make use of __gc in table metatables as shown in the example below: do local tbl = {id="tblID"} setmetatable(tbl,{__gc=function(self)…
Jabermony
  • 21
  • 3
2
votes
1 answer

LuaJ Lua bytecode confusion

I have a problem parsing lua bytecode generated using luaJ. Between the instruction count and the constant count something gets wrong. It seems like there is a byte missing. I'm using LuaJ 2.0.3. Here is a hexdump that shows what I mean: the…
ardera
  • 51
  • 1
  • 4
2
votes
4 answers

Calling a Lua function from LuaJ

So, I have a script that goes like so: function testfunction() print("Test from testfunction"); end I am able to call Java functions from Lua, but how do I accomplish the opposite? How do I call a Lua function from Java using LuaJ?
PuppyKevin
  • 2,967
  • 7
  • 25
  • 27
1
vote
1 answer

Pushing an int with LuaJ

Within my code, I need to push an int onto Lua's stack. I know of the lua_pushnumber for C, but what would be used in LuaJ? I can't find a function for it, given that LuaJ isn't clear as to what functions represent certain C functions.
PuppyKevin
  • 2,967
  • 7
  • 25
  • 27