1. Triumph has risen from these uncharted shores. The 34th Modeling Contest Results are out!
    Dismiss Notice
  2. Awaken what lies in the heart of your swarm. The 17th Techtree Contest has arrived!
    Dismiss Notice
  3. The Hive Workshop is launching its first HD modelling contest. How HD should it be?
    Dismiss Notice
  4. Check out the Staff Job Openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'Triggers & Scripts' started by HerlySQR, Jan 21, 2021.

  1. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    829
    Resources:
    0
    Resources:
    0
    Is there? or Do I have to start from 0?
    They may have already told me and I forgot.
     
    Last edited: Jan 21, 2021
  2. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    2,880
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
  3. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    829
    Resources:
    0
    Resources:
    0
    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.
    I'm just learning about Lua, I can't learn another language. Also, does W3 support it?
     
  4. Eikonium

    Eikonium

    Joined:
    Jul 10, 2009
    Messages:
    175
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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...).

    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.
     
  5. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    487
    Resources:
    0
    Resources:
    0
    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).

    If we're going to argue about which programming language is superior, allow me to link this as well: [C#] Mapmaking in csharp
     
  6. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    829
    Resources:
    0
    Resources:
    0
    @Eikonium I see, but my problem is not the triggers, is the objects, I said I don't have problem in convert the triggers manually.
     
  7. Eikonium

    Eikonium

    Joined:
    Jul 10, 2009
    Messages:
    175
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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.
     
  8. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    829
    Resources:
    0
    Resources:
    0
    But the problem is in the moment I change a trigger to a custom script I can't change the programming language.
     
  9. GhostHunter123

    GhostHunter123

    Joined:
    Oct 17, 2012
    Messages:
    540
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Copy all triggers to clipboard and then change script language. Paste back all triggers. Viola! That's it.
     
  10. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    829
    Resources:
    0
    Resources:
    0
    Is that works?
     
  11. GhostHunter123

    GhostHunter123

    Joined:
    Oct 17, 2012
    Messages:
    540
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Definitely. For coding in Lua tho, I would recommend using Ceres.