Hello there !
As some of you already know, especially as I often come here to ask for help when I am hitting difficulties, I am currently converting my map from Jass2 to Lua.
I have gone quite far, and only a few functions remain problematic, not mentioning the upcoming hidden bugs I have not yet encountered.
This is a hard task, especially when you are so used to and comfortable with Jass, because this one gives you very bad habits and negligence about variables types and initialization. Indeed, in Jass, if you misconsider the variable type or if you don't properly initialize it, it will throw you an error straight away telling you what is wrong.
In Lua, there is no such thing as variable types. In fact only values have a type, and if you don't pay attention, and you do the tiniest mistake when it comes to dealing with your variables, you will, as I did and still do, have a really tough time finding out why nothing works, or why your map crashes for unexpected reasons.
I am not complaining, these endless hours of struggling with converting my triggers and functions to Lua have been immensely instructive, and in fact, the code in Lua looks so much cleaner , even though I have not yet even tried to switch to Object Oriented programming or even scratched the surface of the overall possibilities Lua has to offer.
Yet, while I was comparing the 2 version of my maps a couple of hours ago, first one being the latest Jass2 version and the second one the latest state of my conversion, with the multiple changes and additions I have made besides the Jass2->Lua conversion (If you don't distract your mind from code from time to time, you will suffer^^), I have accidentally found that World Editor does not only have an integrated GUI to Lua converter, but also a Jass2 to Lua Transpiler.
To be honest I don't know how I invoked it.
I had both Jass2 and Lua versions of my map open in World Editor, and was exporting both map scripts in order to compare them.
Then I found out that when I tried to save my Jass2 map script, WE created a Lua version of the script !!!!
Out of curiosity, I saved my Jass map to a different name to preserve the original, disabled all my triggers (custom scripts), changed the map scripting language from JASS to LUA in the map options.
Then I grabbed all the converted functions and triggers one by one from the converted Lua map script with Notepad++ and pasted them each one by one to replace the corresponding Jass2 versions.
And guess what... the WHOLE MAP works perfectly in Lua. Not a bug, not a glitch !!!
There was only a small issue with the Map Init that was in fact a vJass scope. Fixed it with the lazy solution : GUI trigger with Map Initialization event and calling my map init function in actions.
For some reason I remember someone here saying there was a Jass to Lua transpiler that only had issues with vJass (was it you @Dr Super Good ?). By the way, I found it accidentally, but how do you invoke it at will ?
Anyways, the downside is that the converted Lua code, although functional, is definitely looking too "Jassy" and messy, so I will keep up my conversion work. This said, if I ever get stuck and fed up, I can now steal the working converted functions...
The finality of this post is to let people know about the transpiler, because I had no idea it was there, and still have no idea how to use it when needed. So if you want to switch to Lua, there is a very quick way that only takes a few minutes...
As some of you already know, especially as I often come here to ask for help when I am hitting difficulties, I am currently converting my map from Jass2 to Lua.
I have gone quite far, and only a few functions remain problematic, not mentioning the upcoming hidden bugs I have not yet encountered.
This is a hard task, especially when you are so used to and comfortable with Jass, because this one gives you very bad habits and negligence about variables types and initialization. Indeed, in Jass, if you misconsider the variable type or if you don't properly initialize it, it will throw you an error straight away telling you what is wrong.
In Lua, there is no such thing as variable types. In fact only values have a type, and if you don't pay attention, and you do the tiniest mistake when it comes to dealing with your variables, you will, as I did and still do, have a really tough time finding out why nothing works, or why your map crashes for unexpected reasons.
I am not complaining, these endless hours of struggling with converting my triggers and functions to Lua have been immensely instructive, and in fact, the code in Lua looks so much cleaner , even though I have not yet even tried to switch to Object Oriented programming or even scratched the surface of the overall possibilities Lua has to offer.
Yet, while I was comparing the 2 version of my maps a couple of hours ago, first one being the latest Jass2 version and the second one the latest state of my conversion, with the multiple changes and additions I have made besides the Jass2->Lua conversion (If you don't distract your mind from code from time to time, you will suffer^^), I have accidentally found that World Editor does not only have an integrated GUI to Lua converter, but also a Jass2 to Lua Transpiler.
To be honest I don't know how I invoked it.
I had both Jass2 and Lua versions of my map open in World Editor, and was exporting both map scripts in order to compare them.
Then I found out that when I tried to save my Jass2 map script, WE created a Lua version of the script !!!!
Out of curiosity, I saved my Jass map to a different name to preserve the original, disabled all my triggers (custom scripts), changed the map scripting language from JASS to LUA in the map options.
Then I grabbed all the converted functions and triggers one by one from the converted Lua map script with Notepad++ and pasted them each one by one to replace the corresponding Jass2 versions.
And guess what... the WHOLE MAP works perfectly in Lua. Not a bug, not a glitch !!!
There was only a small issue with the Map Init that was in fact a vJass scope. Fixed it with the lazy solution : GUI trigger with Map Initialization event and calling my map init function in actions.
For some reason I remember someone here saying there was a Jass to Lua transpiler that only had issues with vJass (was it you @Dr Super Good ?). By the way, I found it accidentally, but how do you invoke it at will ?
Anyways, the downside is that the converted Lua code, although functional, is definitely looking too "Jassy" and messy, so I will keep up my conversion work. This said, if I ever get stuck and fed up, I can now steal the working converted functions...
The finality of this post is to let people know about the transpiler, because I had no idea it was there, and still have no idea how to use it when needed. So if you want to switch to Lua, there is a very quick way that only takes a few minutes...
Last edited: