1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  4. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  5. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  6. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  7. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  10. 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.

[Wurst] VS Code: Toggle "debug" keyword + Custom map building automatization

Discussion in 'Triggers & Scripts' started by BizzaroFukuro, Apr 28, 2019.

  1. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    In JNGP there is an option "Enable\Disable debug mode".
    My question is how to do the same thing with VS Code Wurst extension?

    Can't find that option anywhere.
    Or maybe you have to add some argument to the wurst.build or wurst_run.args,
    but I couldn't find any info on that either.

    The only workaround that I found is just to use "Replace in Files"
    and do "debug " --> "//disabled_debug " or vise versa,
    which is fast, and works, but kinda sucks to do that every time.
     
    Last edited: May 3, 2019
  2. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    In most cases you shouldn't need anything like "debug", because Wurst does proper optimization.
    If you e.g. want debug prints to be removed, you use Log.debug("msg") and then set the log level above debug for release.
    Now all the debug logs will be removed.
    The same goes for "static ifs" - just use normal ifs. If the condition is constant, wurst removes it.
    Having lines removed based on some keyword in front of them seems like terrible style.
    Use proper programming paradigms.
     
  3. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    In my case it's the old map with "legacy code" which was in vJass and relying heavily on using this JNGP "debug" keyword approach.
    So I can't rewrite over9000 strings of code any time soon.
    And it's not only about logging messages, there is more stuff connected to this, so it's not so easy.

    Also usage of "debug" keyword doesn't give any errors and recognized by Wurst, so I assumed the whole feature was supported...
     
  4. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,237
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
    s/^( *)debug /\1/g

    You don't have to make the 9001 edits - let the computer do that for you
     
  5. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    I reckon you are mixing a few things up.
    The
    debug
    keyword exists in Jass, and has no effect (used by blizzard, or whatever, but not by the World Editor/interpreter),
    thus it is obviously valid Jass and Wurst accepts it. See JASS Manual: Formal Syntax Definition
    However, Wurst doesn't resolve any "vjassy-things" inside ".j"-files anyway. If you have vjass-exclusive stuff in there, it will not parse.
    And since the "remove lines with
    debug
    " feature is done by JassHelper, there really is no reason for you to expect it to work inside a ".j"-file.
    The only way it could work, would be inside a ".jurst"-file, which mimics vJass behavior.
    The
    debug
    keyword not working inside ".jurst"-files could be a valid Issue.
    But since we have no "release" flag yet, I'm not sure how you expect this to work.


    In any case, vscode's task mechanic allows you to build compeltely custom tasks you can execute like wurst tasks.
    This way you can build your own "remove lines with debug and build"-task if you desire.
    See Tasks in Visual Studio Code
    and Compiling vJass and Wurst using VSCode

    You can even use JassHelper itself to do it for you.
     
  6. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Yes, this is exactly what I did.

    Ok, this is probably the best way.
    I will look into it.
    Thank you for the help.
     
  7. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    Alright, it could probably be implemented.
    Just need some sort of prod flag before that.

    Thanks for trying out Wurst :)
     
  8. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Is there a way to run extension command from VS Code task?

    I will explain what I am actually aiming to do here.
    I want to automatize my map building process, which requires some outside actions BEFORE and AFTER running ">buildmap" command.

    Basically I want to make my own "one button to release" command, which does in order this:

    1. Optionally mimics JNGP toggle "debug" keyword feature
    2. Runs my .bat file which updates some stuff inside "war3mapSkin.txt", "wurst.build" and writes the map version info to "war3mapPreview.tga"
    3. Runs ">buildmap"
    4. Runs my other .bat, which takes the "Buildmap.w3x" and does some after-stuff and then runs Vex-optimizer, and then throws it into my Release folder inside WC3.

    Currently I'm stuck at Step 3, because this doesn't work:

    Code (vJASS):
    // tasks.json

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Test Build",
                "type": "shell",
                "command": "wurst.buildmap" // doesn't work (or anything similar which I tried)
            }
        ]
    }


    I know I can just do this in order, like type "task PreBuild", enter, type ">buildmap", enter, type "task AfterBuild", enter (or just run bats outside).
    But I wonder if it's possible to make it as one command (which calls these 3 commands consequentially), because that would be perfect.
     
  9. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,237
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
    Just use search and replace. This is a very easy regular expession
     
  10. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Are you blind or can't read?
    I already know this and mentioned that in first post.
    That's what I was already doing even before creating this thread.

    New question is this:
     
  11. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    ->

    Rudeness won't get you anywhere.
    I gave you two links, which describe exactly what you want to do. (compound tasks)
    More info because perhaps you are blind and can't read.
     
    Last edited: May 2, 2019
  12. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    You know, there is a small difference: I did check out your links (and I appreciate the help), and I did read that, and I did find that other article before you gave the link just now, and I did
    read about compound tasks. The problem is I am not a VS Code pro, far from it, just an amateur. And I couldn't find any info about running extension commands from task, I have no idea how to do this exact thing, that's why I asked the second question. You can call me stupid or a noob, but don't call me blind.
     
  13. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    You realize how cynical that is?
    Running extension commands is exactly what is described on the page I linked.
    Since buildmap requires an input, you have to define it as an input and then reference that in your tasks.
    Code (Javascript):
     "inputs": [
        {
            "id": "wbuild",
            "type": "command",
            "command": "wurst.buildmap",
        }
    ]
    The only thing I didn't know, since I only built tasks for other extensions, is that it seems to throw an error because the command doesn't return a string or so. Could probably be addressed in the language server, I'm not sure if it prevents proper usage. However the build command was still executed in my tests.

    Another thing that will work anyway is just using
    grill
    via shell to build the map, as described in the most recent news post Best of the Wurst 10
    Then you don't need to call the extension command at all.
     
  14. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Ok, I didn't realise that. I'm stupid.

    I actually found the workaround for that error prompt.

    So I did ALMOST everything I needed.
    Here's how it looks:
    C:\Users\...\AppData\Roaming\Code\User\keybindings.json
    Code (vJASS):
    [
        {
            "key": "ctrl+f9",
            "command": "workbench.action.tasks.runTask",
            "args": "Release Build"
        }
    ]

    .vscode\tasks.json
    Code (vJASS):
    {
        "version": "2.0.0",
        "tasks": [
            {
                // this updates "imports\war3mapPreview.tga", "imports\war3mapSkin.txt", "wurst.build" and does some other stuff
                "label": "Prepare Build",
                "type": "shell",
                "command": ".\\toolchain\\PrepareBuild.bat",
                "problemMatcher": []
            },
            {
                // takes the "Buildmap.w3x", does some after-stuff with it, then runs Vex-optimizer, and then throws it into my "_released" folder and names the map file properly with version
                "label": "Release Build",
                "type": "shell",
                "command": ".\\toolchain\\ReleaseBuild.bat",    // (3) executed right after "wurst.buildmap", perfect
                "args": [
                    "${input:wbuild}"//,                        // (2) executed second, but need to confirm the mapfile by hitting "Enter"
                    // "${input:mapfilename}" // ???
                ],
                "problemMatcher": [],
                "dependsOn": [ "Prepare Build" ]                // (1) executed first, perfect
            }
        ],
        "inputs": [
            {
                "id": "wbuild",
                "type": "command",
                "command": "wurst.buildmap",
                "args": {
                    "someShit": ".\\ExampleMap.w3x" // ??? (I'm not sure how to pass this into the command input)
                }
            }
        ]
    }

    So I press "CTRL + F9", wait 1 sec, press "Enter", then everything is done.
    No error prompt or anything.
    But I can't figure out how to pass "ExampleMap.w3x" file path into "wurst.buildmap" command automatically.
    Tried as arg for task, tried as arg for input command, no success.
     
  15. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    I found out this works:
    Code (Javascript):
    {

        "type": "shell",
        "command": "echo ${input:wbuild}",
        "problemMatcher": [],
        "label": "Example"
    }
    Which is neat for composing.

    Input arg works, but you need the right name and probably an absolute path:
    Code (Javascript):
    "args": {
        "mappath": "${workspaceFolder}\\_build\\MyMap.w3x"
    }
     
  16. BizzaroFukuro

    BizzaroFukuro

    Joined:
    Dec 11, 2009
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Doesn't work. Tried with different paths, but it seems to me that it completely ignores this, and still shows the map list to choose.