luajava | scripting tool for Java
kandi X-RAY | luajava Summary
kandi X-RAY | luajava Summary
LuaJava is a scripting tool for Java. The goal of this tool is to allow scripts written in Lua to manipulate components developed in Java. It allows Java components to be accessed from Lua using the same syntax that is used for accessing Lua`s native objects, without any need for declarations or any kind of preprocessing. LuaJava also allows Java to implement an interface using Lua. This way any interface can be implemented in Lua and passed as parameter to any method, and when called, the equivalent function will be called in Lua, and it’s result passed back to Java.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns a string representation of this property
- Get a boolean from the stack
- Get the current double value
- Get an object from the buffer
- Invoke a proxy object function
- Can be null
- Convert a Lua number to a number
- Returns the index of an object
- Compare type
- Get method
- Creates a console script
- Creates a new LuaState instance
- Get the next available state index
- Create an object proxy
- Creates a Java proxy object
- Compares this object to another
- Execute a script
- Get the next item type
- Create a new instance of Java class
- Loads a Lua library
- Initialize the engine
- Function to index an array
- Function function
- Pushes a new instance of the given class
- Evaluate the expression
- Create new index
luajava Key Features
luajava Examples and Code Snippets
Community Discussions
Trending Discussions on luajava
QUESTION
In my application, I need my lua script to index a java array. For some reason I don't understand, I can't index the array at all within Lua. Here is my Lua file (test_lua.lua): https://pastebin.com/zQUPVArz
Here is the Java file calling this code (experiment.Experimental.class): https://pastebin.com/Gr9EsvbM
And here is the Bobject interface: https://pastebin.com/agdS41sc
Using this method, I am unable to do anything with Java arrays from Lua. I even tried using reflection and CoerceLuaToJava to index the array, but to no avail. Below is the offending Lua code:
...ANSWER
Answered 2017-Dec-12 at 14:47Once again, I managed to solve my own issue in the end. I read up on Lua tables and found my way to this stack overflow question: Open Arrays or ArrayLists in Lua (Convert array to table)
I ended up writing a method in Java to coerce each individual object in my Java array, and place it into a LuaTable object. I called this method from my Lua script and was able to manipulate it as I wished.
I included a bit of recursion that coerces multi-dimensional arrays, by checking if array[i] instanceof Object[]
Here's the code I wrote in Java:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install luajava
You can use luajava like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the luajava component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page