Giter Club home page Giter Club logo

hxvm-lua's Introduction

Haxe Lua Bindings Build Status

Embed the Lua scripting engine into your Haxe application

Supported targets

  • c++ (tested on macOS and windows)
  • js (tested on Chrome)
  • nodejs

Example Usage

// create an instance
var lua = new vm.lua.Lua();

// set global variables
lua.setGlobalVar('square', function(v) return v * v);
lua.setGlobalVar('foo', 2);

// run a script
lua.run('return square(foo)'); // gives you 4

// supply an object as second paramter to run() to set global vars
lua.run('return bar', {bar: 2}); // gives you 2

// run function
lua.run('function add(a, b) \n return a + b \n end'); // first we create a lua function
lua.call('add', [1, 2]); // gives you 3

// destroy when done with the instance
lua.destroy();

Install

Target C++

When targeting C++ we compile the Lua runtime from its C source code.

  1. Install haxelib: linc_lua
  2. Add -lib linc_lua to your haxe build

Target JS

When targeting JS we utilize Fengari, which is the Lua VM written in pure JavaScript.

You can choose to either build a standalone js file for Fengari or require it in your project.

For browser without bundlers
  1. Install haxelib: hxjs-fengari
  2. Git clone https://github.com/fengari-lua/fengari
  3. Run yarn && yarn run build
  4. Add the output file (dist/fengari.js) to your project using a <script> tag in html
  5. Add -lib hxjs-fengari -D fengari_global to your haxe build

For Node.js or browser js with bundlers

  1. Install haxelib: hxjs-fengari
  2. yarn add https://github.com/fengari-lua/fengari
  3. Add -lib hxjs-fengari to your haxe build

TODO

  • Implement/test coroutines

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.