Is there any way to use lua(or other script) in haxe, in order to hotfix?

Is there any way to use lua(or other script) in haxe, in order to hotfix?
just like tolua in unity.
thx

I don’t think I understand what you’re looking for, but if I’m not too mistaken hscript might interest you: https://github.com/HaxeFoundation/hscript

1 Like

Thank you very much~ It looks like what I’m just looking for~

You can embed the lua runtime into your Haxe app. For example there is this library https://github.com/kevinresol/hxvm-lua

2 Likes

Thats interesting Kevin, out of interest, does Lua (or indeed your vm bindings) have any benefit over “good 'ol” hscript?

Cheers,
Ian

1 Like

thx~ so interesting~

I tried to use hscript, it can run short script like this:
main.hx:
class Main extends Sprite
{
public function new ()
{
super ();

	var parser:Parser = new Parser();
	var hw = parser.parseString(Assets.getText("assets/Test.hx"));
	//var file = parser.parseModule();
	var interP = new Interp();
	interP.variables.set("Sprite", Sprite);
	interP.execute(hw);
}

}

Test.hx:
var sp = new Sprite();
trace(sp);

but if my Test.hx has a class, it does not work:
package;
class Test extends Sprite{}

hscript doesnt support classes by default, i have written a extension to hscript that does support “classes”: Hscript with classes, aka "hscript-ex"

I wonder if that what makes using Lua useful, does it have classes, or objects or whatever they are in Lua out the box? (I know nothing about Lua myself, so dont know if Lua even has classes)

Cheers,
Ian

lua itself has no classes, no objects, but we can use lua tables to simulate classes and objects, it is real oop.

lua is one of the ways to make your app hotfixable

we can use lua to implement complex logic, and hscript can not,maybe it can but I do not found it.

I just can’t find a reason to use hscript to be honest. It is Haxe syntax but all the goodness of Haxe are absent (macros/abstracts/type system). It is also very slow on static targets due to the extensive use of reflection.

On the other hand the Lua runtime is faster, and we can transpile Haxe to Lua. That gives you the goodnesses of both Haxe(compile time) and Lua (runtime)

1 Like

Ah - i see, got it - you can compile haxe → lua, and then run generated lua in embedded lua vm from haxe… … clever :slight_smile:

I am going to test both of them, and decide which way I will go.

there is a similar way in unity, https://github.com/yanghuan/CSharpLuaForUnity, it can translate c# to lua,and both c# code and lua code can run

so I am looking for haxe + lua, and I found haxe + hscript. I know lua more than hscript, I think if hscript is better than lua (syntax, performance, ide…etc),I will consider it

maybe what I need is “haxe version tolua” now~