Considering switching to a different scripting workflow using Haxe or MoonScript lang to build my lua scripts.

I will first try Haxe as I just know it.

I just used haxe language with other backends and it is quite good, never tested with lua, but I’ will do a complete evaluation soon.

Haxe has a lot of pros against direct use of lua language.

It is flexible for instance Proletatiat Inc. has used it in production both in Unity3D(World Zombination) and Unreal Engine 4(Streamline) .

It can be used with static typing this is a huge plus for me as I do a lot of distraction errors that generally dynamically typed languages didn’t catch before it is too late(read javascript).

Tools for haxe are very solid and and then there is Visual Studio Code that is completely customizable and just much more feature rich than Lumberyard Script Editor.

Haxe has very powerfull macros and overally way more comfortable to use for object oriented programming than lua.

Main reason is that I’m actually not very productive with lua especially with the Lumberyard Lua editor at least in the current state.

I’m still sceptic about the need to develop a new lua editor when you can customize something pre-existing.

Theorically Lumberyard may support directly Haxe in the scripting workflow and doing this it may also switch to a different scripting backend in future and still be compatible with old scripts.

The only issue I can actually foresee:

Haxe compiles to a single lua file so lumberyard may need some modification to be able to specify in entities what script to assign from a file containing multiple scripts.(it is maybe possible to create(automatically is better) empty script that just requires the big haxe compiled one and return the script we want to use).

Haxe also needs definitions of Lumberyard Classes and Ebus one can make them by hand, but it will be far better to modify the reflection system to output these definitions.

If you have just tried Haxe with lua or are interested in the subject let me know.

Made a first Test It generates a 35Kb of lua code to merge haxe functionalities in.

I haven’t even found my code in this file at first sight.

As first test I’m a bit deluded as the use in the lumberyard context with the lua backend doesn’t seem too practical without some modification that actually i’m too lazy to also try to look for I’m also realized just now that i didn’t considered a lot of other factors first of all the Debug.

So for now I put it apart next time I will try a totally different candidate MoonScript that features a more direct translation to lua and could be a better candidate for asset processor to compile to luac and requiring near zero modification to the engine.

A simple Working script in MoonScript

	rotate = Properties: Speed: default:1,description:"ciao",suffix:"d/s"
OnActivate: => Debug.Log "rotation comp activated" @.tickBusHandler = TickBus.Connect@
OnDeactivate: => @.tickBusHandler\Disconnect!
OnTick: (deltatime,timePoint) => -- Add script to be executed every frame here...
TransformBus.Event.RotateByY@.entityId,@.Properties.Speed * deltatime
rotate

It translates to

  local rotate = {
Properties = {
Speed = {
default = 1,
description = "ciao",
suffix = "d/s"
}
},
OnActivate = function(self)
Debug.Log("rotation comp activated")
self.tickBusHandler = TickBus.Connect(self)
end,
OnDeactivate = function(self)
return self.tickBusHandler:Disconnect()
end,
OnTick = function(self, deltatime, timePoint)
return TransformBus.Event.RotateByY(self.entityId, self.Properties.Speed * deltatime)
end
}
return rotate

very concise also the lua file i like it put everything in the {} instead to use the function rotate:OnActivate form