1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Ceres - a WC3 build tool for Lua maps

Discussion in 'The Lab' started by mori, May 3, 2019.

  1. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Even for people who don't want to go through the trouble of rewriting their maps in Lua or even learning it, there's still some benefit to be had from the fact that Lua exists in the first place.

    Since JASS is such a relatively simple language, it is possible to transpile from JASS to Lua and attain a significant performance boost just from that. Blizzard already does that, somewhat, but there's some subtle bugs that make the conversion process prone to introducing weird and transient issues.

    Theoretically, a separate tool could be made to automate this process and to fix those bugs in Blizzard's current implementation.

    This isn't really relevant to the point being discussed at hand, but I think everyone can benefit from the addition of Lua, even people who don't use it directly :)
     
  2. Trokkin

    Trokkin

    Joined:
    Jan 23, 2015
    Messages:
    98
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    1. Less chunky syntax
    2. Execute code directly
    3. Callbacks with arguments, including vararg
    4. Native lambdas with by-reference variable capturing
    5. Code arrays
    6. Dynamic memory
    7. Classes and objects without non-unique ID referencing extra-large static arrays
    8. No strict typing
    9. Modifying environment at will
    10. Dynamic code load
    That's only the first things coming to my mind after two weeks working on my standart library for Lua. Yes, most of this is not useful to simple users, but not having interest is better than not having possibilities.
     
  3. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,362
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    I mean the ability to call functions dynamically has huge implications for extending off of Damage Engine, systems like Timer32 and missile or knockback onLoop behavior.

    Lua also allowing the overriding of natives and BJs which allows GUI people benefit incredibly while maintaining simple code.

    So you are wrong. vJass is only useful for backwards compatibility. The options are much better in Lua.
     
  4. Boar

    Boar

    Joined:
    Oct 10, 2009
    Messages:
    405
    Resources:
    0
    Resources:
    0
    Is this still being supported? It looks just perfect because I'm sick and tired of copy pasting script changes across.
     
  5. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Sort of. I'm trying to work on it when I can, but seeing as the current version works 'okay', and I'm taking the time needed for the next release, which is going to bring some big changes.

    Unfortunately right now I don't have a lot of time to focus on the project, so the progress is slow, but it's there!
     
  6. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,035
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    It accelerates development at first. You don't need as much boilerplate code and integration of libraries/frameworks should be easier as the authors have more power, have to make less assumptions and require less action from the consumer. GUI users can benefit greatly from this. See [Lua]Obliterate all GUI leaks with 1 trigger!, for instance. Fast dynamic invocation of functions had not been feasible before, causing a toll on design. Writing less boilerplates and quirky code to cope with the shortcomings of JASS raises scalability and readability.

    I still like typed languages (contracts) for the maintainability and analyzability benefits. Practically, in Lua, you would have to validate all the input parameters of at least public functions to not run into trouble or make the preconditions prominently visible, otherwise.
     
    Last edited: Jul 25, 2019
  7. iNfraNe

    iNfraNe

    Joined:
    Jun 18, 2004
    Messages:
    117
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I'm liking this thing a lot. Although I must say I don't even know if there are alternative ways of using lua in the editor for the time being. That said: for the time being, this seems to be a life-saver.

    Now, there are some issues with bugreporting. Sometimes the code will compile just fine to a combined lua file, but end of not loading the map giving a blank error ingame (I guess the lua code checking is minimal / absent in ceres?). Of course, this will make bughunting impossible, and should somehow be fixed. Perhaps a way to 'save' in the editor, so you would get a bugreport through there? I'm not sure.

    I hope the community here stops devaluing work because "you can just use old stuff we've had for 15 years" instead of using the brand-new implemented things blizzard are doing specifically to help us overcome some of the boundaries of those old things. I love that you're leading the way ahead (again, unless I'm missing other projects out there doing similar things that I've so-far neglected due to inactivity :))

    Cheers,
     
  8. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Hi, and thanks for the feedback!

    There are other projects that are floating around, though I personally have not really looked into them.

    Regarding the error checking and other things - there's definitely some things that can be improved. At the moment I'm trying to build the "foundation", which has been somewhat challenging with my limited time availability. I recently returned from a prolonged business trip and will be pouring more time into Ceres again. If you can provide test samples that compile fine, but fail to load in-game, that would be very helpful. There's probably additional analysis that I can perform on the emitted code, and having a "broken" example would help a lot.

    Once again, thank you for your patronage :)
     
  9. iNfraNe

    iNfraNe

    Joined:
    Jun 18, 2004
    Messages:
    117
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I see, perhaps someone should make an overview thread (or does this exist? Again, I haven't really looked xD) of early development so we can all learn from eachothers successes/failures :) (or is that against the competitive nature of wc3 modding xD)

    An example which gives an error would be requiring a file with a case mismatch.

    hello.lua:

    Hello = {}

    main.lua:
    require("hello")

    I should note I didn't test this specific example. If it does work, I'm sorry, I'll give another example later :)
     
  10. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,293
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Lua syntax sucks though, you see
    Code (Lua):
    function DomyStuff()
        --blabla
        if MyCondition then
            for i = 0, 10, 1
            do
                --other stuff
            end
        end
    end
    Now imagine this piece of code multiplied inside more times and you'll get confused with the keyword "end". "end" what? endfunction? endloop? endif? Seriously that just stinks.
    Another thing is the dynamic types are lame.
    I won't be able to code in lua because I would like to code it alternating with vjass/jass, I hope they manage for us to be able to do that, and no, I don't want to keep another old version of wc3 1.26 and use some other program for that. That's a complete regression for me.
     
  11. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,362
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Dynamic types are fantastic at simplifying data attachment. Also, C-based syntax uses semicolons which is even less verbose than "end".
     
  12. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Can we please keep discussions of lua syntax out of this thread? I would really appreciate it if this thread didn't devolve into another long-winded argument about the merits and downsides of Lua.

    Nobody is forcing you to use it. You can keep using JASS if you want to. You can also use C# to Lua or TypeScript to Lua, and have the luxury of a statically-typed language with a familiar syntax, if you are so inclined. There's also about a half-dozen other languages that can be compiled down to Lua, so your choices are very diverse.

    I will admit I am not a huge fan of Lua myself, and one of the things I want to do with Ceres is to build a minimal, typed language with C-like syntax on top of it for the reasons you described. With that said, I don't think that it is actually really that bad. I wrote a lot of Lua code in my time, and lots of other people I know did too, and we managed just fine. While Lua has its own problems, the issue of locating nested blocks by eye and stuff like that has never been an issue. That's what we have indentation in our code for. Python manages completely fine without any block delimeters at all, and it's a very popular language.

    EDIT: If you want to be able to mix JASS code with Lua, I think that can also be accomplished with Ceres. Would you be interested in a feature like that?
     
  13. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,528
    Resources:
    9
    Models:
    1
    Icons:
    2
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    9
    As far as I've tested in Ceres, trying to access an index of a nil value will cause the map to not load properly when compiled. This is one thing ignored in the compiler, as far as I've tested it (writing up UnitEvent, World, and DamageEvent)

    Code (Lua):

    UnitEvent

    if UnitEvent.registerflag then
        ceres.addHook("main::before", function()
            print("Something went wrong. Try again")
        end)
    end
     
     
  14. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    My guess it that if a runtime error occurs when WC3 is trying to load the map script, it will abort loading the map with a cryptic error box. IMO this isn't really an issue in Ceres itself as it is an issue with WC3 not properly reporting error messages. It should be really trivial to just print out the lua error when that happens, and display it. In order to check for these kinds of things in Ceres I would have to actually do a test run of the map script after compiling it... Which might not be a terrible idea in general.
     
  15. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,293
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Well, I would like to see an example of that. The only thing that comes to my mind is functions.
    Actually it uses { }, semicolons are for a new line. You don't see in jass typing "end" at the end of every line, that would be insane lol :D

    I never said I didn't like lua, I just made my personal rant about some things I don't like about it, rest of it is pretty great. That's the reason I would like to use it with vjass/jass. Usually I'm not a guy who likes to use 3rd party stuff, unless I really have no other choice, but there are also people besides me who would also like to use lua mixed with vjass/jass. I think that would be pretty useful and powerful.
     
  16. Trokkin

    Trokkin

    Joined:
    Jan 23, 2015
    Messages:
    98
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Code (Text):
    SetUnitUserData(u, {whatever, i, would, like, to, put, in, here})
    I doubt it would work though, since natives still (seem to) expect correct types. But if you write your own, it would be only one function to do the attachment and only one to get it.
    Hashtable (now useless) has a set of HasX, SaveX, LoadX for each type X, and jass would require you to repeat that for any data attachment you'd like to have.

    Still you type call/set keywords before every line, insane :D
     
    Last edited: Aug 22, 2019
  17. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    420
    Resources:
    0
    Resources:
    0
    I think it's a bit unfair to compare this use-case to how it needs to be done in jass, since we all know jass sucks compared to modern languages.
    That said, if I had to do this in for example C#, I could simply use either generics, or objects and then cast the types. Is there any benefit of having dynamic types here, or could you maybe provide a different example where dynamic types are a solution, but the two I mentioned wouldn't work?
     
  18. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Dynamic typing is generally considered to be an aid in rapid prototyping. Languages which have dynamic structures like Lua's tables (think JS, TS, etc.) do not force you to think about your types ahead of time, which can be useful when prototyping and experimenting with something, and it can be a legitimate time saver. It creates less friction during development as a result, which means you can do the same thing you'd do in a typed language like C# or C++ but way faster. Of course, that also means that you pay the price of not having a proper type system down the road, which can really hurt you if your codebase starts to grow big.

    I think the best of both worlds are languages that have good type inference but which are still statically typed. A lot of modern languages are starting to introduce better and better type inference, and I think that has diminished a lot of the benefits of dynamic languages. Still, sometimes dynamic languages are more convenient because the barrier of mental friction is simply lower than their static alternatives.
     
  19. Jilaer

    Jilaer

    Joined:
    Aug 27, 2019
    Messages:
    7
    Resources:
    0
    Resources:
    0
    I can not "ceres build mymap.w3x"
     
  20. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Okay. Do you have more information?