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

Best of the Wurst 6

Status
Not open for further replies.
Level 23
Joined
Jan 1, 2009
Messages
1,609

Wurst goes 1.29 and beyond

As the new patch has hit earlier in April, we have implemented the necessary changes to support it in our toolchain, while still keeping backwards compatibility alive.

Updates
  • Increased maximum class instances to 32768 to match new array sizes in 1.29+
  • The new common.j and blizzard.j are now supplied by default
  • Implemented vararg function parameters - functions that take a variable amount of parameters of a certain type.
  • VSCode highlighting has been improved to match the language documentation, recognizing punctuation and operators
  • Deprecation warnings now also show for variables
  • Fixed two unusual exceptions related to extended unicode characters
  • Implemented additional natives for compiletime such as timers, triggers, rects and more, enabling those to be used in unit tests.
  • Modified standard units get printed into WurstExportedObjects again, for easier transfer to generated objects
  • The operator precedence of or in Wursts Jass parsing is now correct
Standard Library
  • Merged over 10 awesome pull requests regarding object editing, damage detection and the new Blz natives
  • Extension function wrappers for the new natives, such as effect.setColor and item.setName have been added
  • Packages affected by the new 24 player capability, such as Colors, have been updated accordingly
  • Fixed and unit tested several issues with typecasting and error handling
 
Level 23
Joined
Jan 1, 2009
Messages
1,609
Variable Argument Functions

Wurst now supports a limited variant of variable argument functions. Variable arguments can only be iterated over and not directly accessed, neither the amount.

Declaration:
Wurst:
function sum(vararg int ints)
    var result = 0
    for i in ints
        result += i
    print(result.toString())
Usage:
Wurst:
sum(1,2,3,4)
sum(14,22)
sum(23,52,5234,5,5)
Several functions in the standard library are now implemented via varargs, and as such, offer variable argument functionality, for example id-lists for object editing and groups:
Wurst:
@compiletime function genBuilder()
    new UnitObjDefinition('buil', 'hfoo')
    ..setNormalAbilities(asList(ID_FIREBALL, ID_FIRE_NOVA))
    ..setStructuresBuilt(asList(ID_GUARD_TOWER, ID_CANNON_TOWER))

init
    CreateGroup().addUnit(u1, u2, u3)
Additionally asList is now available to inline create LinkedLists of elements
Wurst:
asList("This", "will", "be", "a", "list")
asList(75., 125., 175.).add(250., 375.)
asList(players[0], players[1], players[2], players[3])

Protips

Want to be most efficient with wurst? Under the 'Protip' slogan we will regularly feature ways or products to improve your workflow:

  • Use Vector Tuples
    Instead of working with either locations, which leak and shouldn't be used, or x and y coordinates, which doubles the amount of code you have to write and the amount of mistakes you can make, Wurst provides vec2 and vec3 vector tuples which, unlike classes, don't have an identity and therefore are translated with zero overhead. This means you get the speed of using coordinates directly, but the comfort of class-like syntax and functionality. Some common uses:
    Wurst:
    // Event response
    getSpellTargetPos() // instead of GetSpellTargetX/Y
    getOrderPos() // instead of GetOrderPointX/Y
    getOrderTargetPos()  // instead of GetWidgetX(GetOrderTarget()) etc.
    
    // As class member, e.g. position, velocity
    class A
        vec2 position
    
    // Angle between points & Polar projection
    function onEvent()
        let casterPos = GetTriggerUnit().getPos()
        let angl = casterPos.angleTo(getSpellTargetPos())
        flashEffect(Objects.impaleTargetDust, casterPos.polarOffset(angl, 256.))
    You will notice that many extension functions also expect vector tuples as arguments, making them even more seamless to use.

  • VSCode extension: vscode-icons
    Adds meaningful icons to the folder tree view, improving visual recognition and fidelity. Wurst code files don't get recognized yet, but most other files do, which helps to distinguish them.
    JDz9btd.png


    Cheers
    Frotty
 
Last edited:
Level 2
Joined
Dec 31, 2017
Messages
8
Trivia: The motivation was that it's easier to search and ask about a function signature with vararg keyword written in it. Since the programming experience in the mapping community is wildly varied.
 
Level 23
Joined
Jan 1, 2009
Messages
1,609
Trivia: The motivation was that it's easier to search and ask about a function signature with vararg keyword written in it. Since the programming experience in the mapping community is wildly varied.
Well it was one :)

Is it possible to use WurstScript on linux with a wine installation of Wc3?
Yes, and you can also use it without wine/wc3 if you just want to develop and build, but not run the map. But you need to supply the "-noPJass" arg.
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,609
Oh, wow - works like a charm! Though, I didnt need to add -noPjass (I'm guessing its on by default)
Great to hear :thumbs_up:
The normal editor will work - but no, noPJass is not default, pjass is only executed on run/build and if the .exe cannot be run, you should get an error, or at least some message in the Output->wurstlangServer tab.
If you have wine installed, it will automatically be used to runn pjass.
 

Deleted member 219079

D

Deleted member 219079

Variadic arguments in JASS, damn :D

Nice work, as always
 
Status
Not open for further replies.
Top