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

**URL:** https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738
**Category:** Haxe
**Created:** [October 26, 2020, 8:37am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738 "2020-10-26T08:37:39Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 26, 2020, 8:37am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/1 "2020-10-26T08:37:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kLabz](https://community.haxe.org/user_avatar/community.haxe.org/klabz/32/225_2.png) [@kLabz](https://community.haxe.org/u/kLabz)
#### Post date: [October 26, 2020, 8:40am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/2 "2020-10-26T08:40:41Z")

</div>

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](https://github.com/HaxeFoundation/hscript)

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 26, 2020, 9:09am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/3 "2020-10-26T09:09:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kevinresol](https://community.haxe.org/user_avatar/community.haxe.org/kevinresol/32/272_2.png) [@kevinresol](https://community.haxe.org/u/kevinresol)
#### Post date: [October 26, 2020, 12:30pm UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/4 "2020-10-26T12:30:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [October 26, 2020, 3:42pm UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/5 "2020-10-26T15:42:18Z")

</div>

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

Cheers,  
Ian

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 8:05am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/6 "2020-10-27T08:05:20Z")

</div>

thx~ so interesting~

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 8:13am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/7 "2020-10-27T08:13:07Z")

</div>

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{}

---

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [October 27, 2020, 8:46am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/8 "2020-10-27T08:46:23Z")

</div>

hscript doesnt support classes by default, i have written a extension to hscript that _does_ support “classes”: [Hscript with classes, aka "hscript-ex"](https://community.haxe.org/t/hscript-with-classes-aka-hscript-ex/2597)

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

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 9:29am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/9 "2020-10-27T09:29:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kevinresol](https://community.haxe.org/user_avatar/community.haxe.org/kevinresol/32/272_2.png) [@kevinresol](https://community.haxe.org/u/kevinresol)
#### Post date: [October 27, 2020, 9:39am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/10 "2020-10-27T09:39:02Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [October 27, 2020, 9:45am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/11 "2020-10-27T09:45:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 9:49am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/12 "2020-10-27T09:49:21Z")

</div>

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](https://github.com/yanghuan/CSharpLuaForUnity), it can translate c# to lua,and both c# code and lua code can run

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 9:54am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/13 "2020-10-27T09:54:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ukyohpq](https://avatars.discourse-cdn.com/v2/letter/u/e99b99/32.png) [@ukyohpq](https://community.haxe.org/u/ukyohpq)
#### Post date: [October 27, 2020, 9:57am UTC](https://community.haxe.org/t/is-there-any-way-to-use-lua-or-other-script-in-haxe-in-order-to-hotfix/2738/14 "2020-10-27T09:57:32Z")

</div>

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