Giter Club home page Giter Club logo

jua's Introduction

nonlua

License Build Status

About

Nonlua 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. Nonlua 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.

Quickstart

To include Nonlua into your project, you can use Maven or Gradle. Artifacts:

  • Core: io.nondev:nonlua:0.3.0-SNAPSHOT
  • Desktop backend: io.nondev:nonfilesystem-desktop:0.1.0-SNAPSHOT
  • Desktop natives: io.nondev:nonlua:0.3.0-SNAPSHOT:natives-desktop
  • Android backend: io.nondev:nonfilesystem-android:0.1.0-SNAPSHOT
  • Android natives: io.nondev:nonlua:0.3.0-SNAPSHOT:natives-android
  • iOS backend: io.nondev:nonfilesystem-ios:0.1.0-SNAPSHOT
  • iOS natives: io.nondev:nonlua:0.3.0-SNAPSHOT:natives-ios

You must also include https://oss.sonatype.org/content/repositories/snapshots/ to repositories.

And here is simple example on how to correctly initialize new Lua instance. This example will push message variable to Lua with value Hello World from Lua, then prints it using Lua built-in print function and then tries to evaluate main.lua script.

Lua.files = new DesktopFiles();
Lua L = new Lua();

L.push("Hello World from Lua");
L.set("message");
L.run("print(message)");
L.run("main.lua");

L.dispose();

Java module

Example on how to use java module in Lua to create basic LibGDX application:

local Gdx = java.require("com.badlogic.gdx.Gdx")
local GL20 = java.require("com.badlogic.gdx.graphics.GL20")
local SpriteBatch = java.require("com.badlogic.gdx.graphics.g2d.SpriteBatch")
local Texture = java.require("com.badlogic.gdx.graphics.Texture")

local batch, img

function create()
  batch = java.new(SpriteBatch)
  img = java.new(Texture, "badlogic.jpg")
end

function render()
  Gdx.gl:glClearColor(1, 0, 0, 1)
  Gdx.gl:glClear(GL20.GL_COLOR_BUFFER_BIT)

  batch:begin()
  batch:draw(img, 0, 0)
  batch:end()
end

function dispose()
  batch:dispose()
  img:dispose()
end

Project template

To allow you to step into Lua development in Java, we build easy to use project template. Just navigate into template directory.

Here are few commands to run each template front-end

gradlew desktop:run
gradlew android:installDebug android:run
gradlew ios:launchIPhoneSimulator

And here are commands to build each of them

gradlew desktop:dist
gradlew android:assembleRelease
gradlew ios:createIPA

Credits

Nonlua is based on LuaJava. So all thanks to Jason Santos for his awesome work on it.

jua's People

Contributors

deathbeam avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.