• 🏆 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!

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

Status
Not open for further replies.
Level 10
Joined
Dec 11, 2009
Messages
234
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:
Level 23
Joined
Jan 1, 2009
Messages
1,608
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.
 
Level 10
Joined
Dec 11, 2009
Messages
234
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...
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
JNGP "debug" keyword approach.
Also usage of "debug" keyword doesn't give any errors

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.
 
Level 10
Joined
Dec 11, 2009
Messages
234
The only way it could work, would be inside a ".jurst"-file, which mimics vJass behavior.
Yes, this is exactly what I did.

vscode's task mechanic allows you to build compeltely custom tasks you can execute like wurst tasks.
Ok, this is probably the best way.
I will look into it.
Thank you for the help.
 
Level 10
Joined
Dec 11, 2009
Messages
234
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:

JASS:
// 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.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Last edited:
Level 10
Joined
Dec 11, 2009
Messages
234
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.
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.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
You can call me stupid or a noob, but don't call me blind.

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.
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.
 
Level 10
Joined
Dec 11, 2009
Messages
234
Since buildmap requires an input, you have to define it as an input and then reference that in your tasks.
Ok, I didn't realise that. I'm stupid.

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.
I actually found the workaround for that error prompt.

So I did ALMOST everything I needed.
Here's how it looks:
JASS:
[
    {
        "key": "ctrl+f9",
        "command": "workbench.action.tasks.runTask",
        "args": "Release Build"
    }
]
JASS:
{
    "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.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
I found out this works:
JavaScript:
{

    "type": "shell",
    "command": "echo ${input:wbuild}",
    "problemMatcher": [],
    "label": "Example"
}

Which is neat for composing.

But I can't figure out how to pass "ExampleMap.w3x" file path into "wurst.buildmap" command automatically.

Input arg works, but you need the right name and probably an absolute path:
JavaScript:
"args": {
    "mappath": "${workspaceFolder}\\_build\\MyMap.w3x"
}
 
Status
Not open for further replies.
Top