• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is there a easy way to convert a Jass map to a Lua map?

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,850
There are some ways but they aren't flawless. If you are using vJass you will lose all of the objects and such, being left with only the compiled JASS.
It's a shame, then, I really don't mind redoing each trigger manually, because I'm just learning and that can help me, my problem was precisely the objects.
There is also an option if you are willing to try TypeScript, which is in my opinion superior to Lua.
I'm just learning about Lua, I can't learn another language. Also, does W3 support it?
 
Level 20
Joined
Jul 10, 2009
Messages
477
Version 1.12 of cJass2Lua can be retreived here: goshante/cjass2lua
I have used that tool to convert my Jass triggers and was happy enough with the results, although (like TriggerHappy pointed out) those conversions are never flawless.
In my example, string concatenation was converted wrongly in a lot of cases, when the concatenation involved more than two elements (should have converted second and further "+" into "..", but didn't).

Also, you might encounter a few bugs coming from lua and Jass handling a few things differently. For instance, given a string s, Jass would compute s + null to s, while lua computes s .. nil to nil. That can't be solved by a converter, but you would have to find such an after-conversion-bug on your own.

If you are willing to invest some time (not sure, how many triggers you have and how complicated they are), I can definitely recommend using lua over Jass. Once you got used to it, it offers many features that make programming quicker and more efficient (looking at arithmetic computation speed in Jass...).

Also, does W3 support it?
Wc3 doesn't natively support Typescript, but you would have to use external software to convert your Typescript code to lua, before pasting it into your map. There are even tools that do both the conversion and the pasting for you. And in contrast to Jass -> lua, those conversions should be quite bugfree.
However, I don't share TriggerHappy's opinion of Typescript being superior to lua.
If you need typesafety, you can pseudo-achieve it by using linting tools such as sumneko's lua extension for Visual Studio Code (which however requires you to annotate your code properly). And lua offers functions to properly debug your code and print useful error messages, when having used Wc3 natives with wrong inputs.
 
Level 18
Joined
Jan 1, 2018
Messages
728
Version 1.12 of cJass2Lua can be retreived here: goshante/cjass2lua
I have used that tool to convert my Jass triggers and was happy enough with the results, although (like TriggerHappy pointed out) those conversions are never flawless.
In my example, string concatenation was converted wrongly in a lot of cases, when the concatenation involved more than two elements (should have converted second and further "+" into "..", but didn't).

Also, you might encounter a few bugs coming from lua and Jass handling a few things differently. For instance, given a string
s
, Jass would compute
s + null
to
s
, while lua computes
s .. [COLOR=color: #666666]nil[/COLOR]
to
nil
. That can't be solved by a converter, but you would have to find such an after-conversion-bug on your own.
I wrote my own jass to lua transpiler which should handle string concatenation correctly: Map Transpiler
In this thread you will also find some code that fixes concatting strings where one of the operands is nil (the solution doesn't work when both are nil).

However, I don't share TriggerHappy's opinion of Typescript being superior to lua.
If you need typesafety, you can pseudo-achieve it by using linting tools such as sumneko's lua extension for Visual Studio Code (which however requires you to annotate your code properly). And lua offers functions to properly debug your code and print useful error messages, when having used Wc3 natives with wrong inputs.
If we're going to argue about which programming language is superior, allow me to link this as well: [C#] Mapmaking in csharp
 
Level 24
Joined
Jun 26, 2020
Messages
1,850
Ok, I see. Sorry, you have to rewrite your vJass-Code manually to lua.
Luckily, Lua offers multiple ways of programming in an object oriented way, although the language itself is not object oriented. The most common way involves the __index-function and the :-operator.
But the problem is in the moment I change a trigger to a custom script I can't change the programming language.
 
Status
Not open for further replies.
Top