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

[Release] WurstScript - A Wurst to Jass Compiler & IDE

Status
Not open for further replies.
I agree that a change is probably not needed. I'm better off changing my current items and adding item stats by ingame-scripts instead of automaticly creating more item stat objects. It's way more elegant and efficient that way.

Gonna be fun updating almost 400 item objects manually. :/

I will report back my experiences with muzzel's code once I am done cleaning up the mess that is the object data right now.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Well, if wurst would allow you to read the object data and write to files, you could write a small script to convert your 400 objects ;)

The idea of putting the data into the map is not so bad, maybe.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
You could still export the items using an mpq editor and write a small converter script, the itemdefinitions look like this:

Code:
[I026:ckng]
comment=Crown of Kings +5
scriptname=CrownofKings5
version=0
class=Artifact
Level=8
oldLevel=10
abilList=A04U,AId1,AIa1,AItg
cooldownID=AIx5
ignoreCD=0
uses=-
prio=126
usable=0
perishable=0
droppable=1
pawnable=1
sellable=1
pickRandom=1
powerup=0
drop=0
stockMax=1
stockRegen=120
stockStart=0
goldcost=200
lumbercost=0
HP=75
morph=0
armor=Wood
file=war3mapImported\bag.mdl
scale=1.30
selSize=0
colorR=255
colorG=255
colorB=255
InBeta=1
Art=war3mapImported\BTNINV_Helmet_28.blp
Name=|cff00cc00Bandit Bandana|
Hotkey=
Tip=Buy |cff00cc00Bandit Bandana|
Ubertip=|cffccccccHelmet|r|n|n|ccc00cc00Type:|r |cffffcc00Leather|r|nHP: +10|nAr: +1|nAp: +1|nAgi: +1|nCr: +1
Description=|cffccccccHelmet|r|n|n|ccc00cc00Type:|r |cffffcc00Leather|r|nHP: +10|nAr: +1|nAp: +1|nAgi: +1|nCr: +1

The most difficult thing would be to extract the items stats from the tooltip. Everything else is very simple (name, raw, icon, cost, level).
 
The most difficult thing would be to extract the items stats from the tooltip. Everything else is very simple (name, raw, icon, cost, level).
Why should I extract the item stats from the tooltip? I applied those vanilla item stats via abilities anyway, so I only need a small translation table that knows which ability rawcode applies which stat to what extend. ;)
Everything else is already code only.

Too bad WC3 doesn't allow the creation of object data at runtime. I could get rid of the object data completely that way. But compiletime is the next best thing.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Nice! Do you have your project on GitHub? I am currently adding Wurst projects from GitHub to my CI-server. So when we change something in the language which breaks one of those projects I will know directly and can send a pull request to the project or fix the breaking change.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Hm then i should probably fix momentum
Build stability: All recent builds failed.
151697-albums6077-picture80083.gif
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Hm then i should probably fix momentum

151697-albums6077-picture80083.gif

Well, I have not had the time to set up all the projects, so most of them fail to compile currently. For some of them it is just a missing war3map.j which I need to compile the script on the CI-server.

For Momentum you can see the error here: http://peeeq.de/hudson/job/Momentum/1/console (Error in File MParticle.wurst line 4: The import 'Lists' could not be resolved.)
It is compiled with this command, if you want to test it locally. You'll just have to adjust the path to Wurstpack.

Code:
java -jar ../../Wurst/workspace/downloads/Wurstpack/wurstscript/wurstscript.jar \
	../../Wurst/workspace/downloads/Wurstpack/wurstscript/common.j \
	../../Wurst/workspace/downloads/Wurstpack/wurstscript/Blizzard.j \
	./wurst \
	-lib ../../Wurst/workspace/downloads/Wurstpack/wurstscript/lib
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Well frotty made 2 videos which explains how to install the eclispe plugin. Just take a look at the first post.
I wish I can, but my connection don't support it well :/

There is no eclipse distribution which comes with preinstalled Wurst plugin (like there is for Java EE, C++, etc.).
Just download the standard eclipse version for your platform:
https://www.eclipse.org/downloads/packages/eclipse-standard-432/keplersr2
(On the right side "Download Links" select your platform).

Then install the eclipse plugin by following these instructions:
http://peq.github.io/WurstScript/installation.html#installing_the_wurstplugin

Thanks for the help Muzzel!
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
I got some error reports of Wurst Crashes, but I cannot reproduce the problem and do not know who sent the report. (more info here)

If someone knows the person having problems or has the same error: Please contact me :>
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
sorry for my bad english

I have a problem with unicode character
1.png


Just only with Object Editing functions.
The print function do correct

I changed the encoding to UTF-8, so it should work now. Please update Wurst and try it again. Also make sure to have your wurst files encoded with UTF-8. Unfortunately the default setting for eclipse is sometimes different depending on which version you are using.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
To all Wurst users: There currently are a lot of open issues on GitHub. If you are interested in one of those issues being fixed, please add a simple :+1: comment on the issue, so that it is easier for us to prioritize the work.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Excuse me. How can I modify objects without create new one?

This is not possible because it would violate the principles of how object editing is supposed to work in Wurst:

If you remove or change object editing code the result should be the same as if the old code never was there.

Technically this is done by adding a hidden flag to all objects created by Wurst and deleting all old objects before creating the new ones.

You can however use and adjust the code for existing objects which is generated by Wurst.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
I think is is time to bump the version to 1.4, because the initalization order change is not completely backwards-compatible ...

Version 1.4.0.0 Changelog

Language Changes:
  • First version of Jurst (a Wurst dialect with a (v)jass-like syntax)
    • not documented yet, you can create *.jurst files in eclipse if you want to play with it
  • Modules can now be generic
  • Operator overloading: op_div must now be named op_divReal
  • Better warnings for unused parameters (Variables starting with an underscore will be ignored for this warning)
  • The initialization order no longer depends on the imports. Instead the compiler analyses which variables are read.

Standard library:
  • Many smaller changes
  • More unit testing functions

Tools:
  • The recommended download for the WurstPack is now the updater made by Crigges
  • Slightly better command line interface for the compiler
  • Injecting of compiletime generated objects into the map has been enabled again but is still broken, because of MPQ-lib problems
  • wurst config file is no longer used
  • The eclipse plugin no longer crashes when the Wurst nature is missing, instead the user is asked to add it
  • Removed the option for cohadars jasshelper from WurstPack, because it was causing problems for some users
  • Added a custom text field to auto error reports

Bugfixes:
  • Fixed bug #177 Remove FileIO dependency from Wurst.wurst
  • Interpreter: Comparing two reals for equality was broken
  • Fixed a bug in tuple assignment
  • Fixed bug #203 - could use type parameters in static places
  • fixed a bug with overrides of generic functions
  • fixed hanging compiler when recursive functions were used in certain ways
  • Fixed bug #220, class names could be used as expressions
  • Object-editing: Read and write strings as UTF-8.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Can we get some examples of Jurst? or a link or something

I'll try to write some documentation and do a small presentation on Jurst soon.

There are two main use cases for Jurst: 1. to make it easier to adapt vjass libraries. 2. For people who do not like the indentation based syntax of Wurst.

For example here would be a port of UnitDex in Jurst:

JASS:
library UnitDex uses GroupUtils, WorldBounds
/***************************************************************
*
*   v1.1.8, by TriggerHappy
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   An indexer assigns each unit an unique integer below the maximum array limit. This is useful for
*   associating that index with an array, struct, or set of variables corresponding to data related to the unit.
*
*   The default settings offer the best performance, however if you plan on having more than 8190 units
*   on your map you need to enable DEFAULT_HASHTABLE below.
*
*   _________________________________________________________________________
*   1. Installation
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   Copy the script to your map, save it, then restart the editor and comment out the line below.
*/
    //! external ObjectMerger w3a Adef uDex anam "Detect Leave" ansf "(UnitDex)" aart "" acat "" arac 0
/*  ________________________________________________________________________
*   2. Configuration
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/  
	module UnitDexConfig
   
        // The raw code of the leave detection ability.
        static constant integer DETECT_LEAVE_ABILITY = 'uDex'
       
        // Use a hashtable instead of a unit's custom value
        static constant boolean DEFAULT_HASHTABLE    = false
       
        // Allow debug messages (debug mode must also be on)
        static constant boolean ALLOW_DEBUGGING      = true
       
        static constant boolean DEBUG_MODE = true
       
        // Uncomment below to define a custom filter for indexing units
        
        static method onFilter takes unit u returns boolean
            return true
        endmethod
        
       
    end
/*  _________________________________________________________________________
*   3. Function API
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   Every function inlines except UnitRecycleId.
*
*       function GetUnitId takes unit whichUnit returns integer
*       function GetUnitById takes integer index returns unit
*    
*       function UnitDexEnable takes boolean flag returns nothing
*       function UnitDexReset  takes boolean flag returns nothing
*       function UnitRecycleId takes unit u, boolean runEvents returns nothing
*
*       function IsUnitIndexed takes unit u returns boolean
*       function IsIndexingEnabled takes nothing returns boolean
*
*       function GetIndexedUnit takes nothing returns unit
*       function GetIndexedUnitId takes nothing returns integer
*      
*       function RegisterUnitIndexEvent takes boolexpr func, integer eventtype returns indexevent
*       function RemoveUnitIndexEvent takes triggercondition c, integer eventtype returns nothing
*       function TriggerRegisterUnitIndexEvent takes trigger t, integer eventtype returns nothing
*
*   _________________________________________________________________________
*   4. Struct API
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*       UnitDex.Enabled = false // toggle the indexer
*       UnitDex.Initialized     // returns true if the preload timer has finished
*       UnitDex.Count           // returns the amount of units indexed
*       UnitDex.Unit[0]         // access the UnitDex array directly
*       UnitDex.Group           // a unit group containing every indexed unit (for enumeration)
*       UnitDex.LastIndex       // returns the last indexed unit's id
*   _________________________________________________________________________
*   5. Public Variables
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*       These are to be used with the "eventtype" argument of the event API:
*
*           constant integer EVENT_UNIT_INDEX     = 0
*           constant integer EVENT_UNIT_DEINDEX   = 1
*   _________________________________________________________________________
*   6. Examples
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*       1. Allocate an instance for a unit
*
*           local somestruct data = GetUnitId(unit)
*  
*       2. Detect when a unit leaves the map
*
*           function Exit takes nothing returns nothing
*               call BJDebugMsg(GetUnitName(GetIndexedUnit()) + " has left.")
*           endfunction
*
*           call RegisterUnitIndexEvent(Filter(function Exit), EVENT_UNIT_DEINDEX)
*
*   _________________________________________________________________________
*   7. How it works
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   UnitDex uses the TriggerRegisterEnterRegion native as well as enumerates all preplaced units on map initialization
*   to index them. However, De-indeixing isn't as simple. The leave region event doesn't work properly for de-indexing so we have to give all units
*   an ability based off of "Defend". When a unit dies, or are removed from the game they are issued the "undefend" order. So we catch that order and
*   de-index the unit accordingly.
*   _________________________________________________________________________
*   8. Notes
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   & This system is compatable with GUI because it utilizes UnitUserData (custom values for units).
*   & The object merger line should be commented out after saving and restarting.
*   & All public functions are inlined except UnitRecycleId.
*
*   [url]http://www.hiveworkshop.com/forums/submissions-414/unitdex-lightweight-unit-indexer-248209/[/url]
*
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/
   
        // Event types
        constant integer EVENT_UNIT_INDEX     = 0
        constant integer EVENT_UNIT_DEINDEX   = 1
       
        // System variables
        trigger array IndexTrig
        integer Index = 0
        integer E=-1
   
    function UnitDexEnable takes boolean flag returns nothing
        set UnitDex.Enabled = flag
    endfunction
   
    function GetUnitId takes unit whichUnit returns integer
        if (UnitDex.DEFAULT_HASHTABLE) then
            return LoadInteger(UnitDex.Hash, 0, GetHandleId(whichUnit))
        else
            return GetUnitUserData(whichUnit)
        endif
    endfunction
   
    function GetUnitById takes integer index returns unit
        if (UnitDex.DEFAULT_HASHTABLE) then
            return LoadUnitHandle(UnitDex.Hash, 0, index)
        else
            return UnitDex.Unit[index]
        endif
    endfunction
   
    function GetIndexedUnit takes nothing returns unit
        if (UnitDex.DEFAULT_HASHTABLE) then
            return LoadUnitHandle(UnitDex.Hash, 0, UnitDex.LastIndex)
        else
            return UnitDex.Unit[UnitDex.LastIndex]
        endif
    endfunction
   
    function GetIndexedUnitId takes nothing returns integer
        return UnitDex.LastIndex
    endfunction
   
    function IsUnitIndexed takes unit u returns boolean
        return (GetUnitById(GetUnitUserData(u)) != null)
    endfunction
   
    function IsIndexingEnabled takes nothing returns boolean
        return UnitDex.Enabled
    endfunction
   
    function RegisterUnitIndexEvent takes boolexpr func, integer eventtype returns triggercondition
        return TriggerAddCondition(IndexTrig[eventtype], func)
    endfunction
   
    function RemoveUnitIndexEvent takes triggercondition c, integer eventtype returns nothing
        call TriggerRemoveCondition(IndexTrig[eventtype], c)
    endfunction
   
//   TriggerVariableEvent not possible in Wurst/Jurst
//    function TriggerRegisterUnitIndexEvent takes trigger t, integer eventtype returns nothing
//        call TriggerRegisterVariableEvent(t, SCOPE_PRIVATE + "E", EQUAL, eventtype)
//    endfunction
   
    /****************************************************************/
   
	function UnitRecycleId takes unit u, boolean runEvents returns nothing
        local integer i = GetUnitId(u)
       
        if (i > 0 and u == GetUnitById(i)) then
            set UnitDex.List[i]= Index
            set Index = i
           
            call GroupRemoveUnit(UnitDex.Group, u)
           
            if (runEvents) then
                set UnitDex.LastIndex = i
                set E = EVENT_UNIT_DEINDEX
                call TriggerEvaluate(IndexTrig[EVENT_UNIT_DEINDEX])
                set E = -1
            endif
           
            set UnitDex.Unit[i] = null
        endif
    endfunction
   
   
    struct UnitDex
        static boolean Enabled = true
        static integer LastIndex // UnitRecycleId needs access
       
        static boolean Initialized=false
        static group Group=CreateGroup()
        static unit array Unit
        static integer Count = 0
        static integer array List
       
        use UnitDexConfig
       
        static hashtable Hash
       
   
        private static method runInitTriggers takes nothing returns nothing
            local integer i = 1
           
            loop
                exitwhen i == Count
               
                set LastIndex = i
               
                // run triggers
                call TriggerEvaluate(IndexTrig[EVENT_UNIT_INDEX])
                set E = EVENT_UNIT_INDEX
                set E = -1
               
                set i = i + 1
            endloop

            set LastIndex   = Count
            set Initialized = true
           
            call DestroyTimer(GetExpiredTimer())
        endmethod
       
        private static method onEnter takes nothing returns boolean
            local unit    u = GetFilterUnit()
            local integer i = GetUnitId(u)
            local integer t = Index
           
            if (i == 0 and Enabled) then
               
                // If a filter was defined pass the unit through it.
                if (not onFilter(u)) then
                    return false // check failed
                endif
               
                // Handle debugging
                if (DEBUG_MODE and ALLOW_DEBUGGING and not DEFAULT_HASHTABLE) then
                    if (t == 0 and Count+1 >= JASS_MAX_ARRAY_SIZE) then
                        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "UnitDex: Maximum number of units reached! (enable the DEFAULT_HASHTABLE option)")
                        set u = null
                        return false
                    endif
                endif
               
                // Add to group of indexed units
                call GroupAddUnit(Group, u)
               
                // Give unit the leave detection ability
                call UnitAddAbility(u, DETECT_LEAVE_ABILITY)
                call UnitMakeAbilityPermanent(u, true, DETECT_LEAVE_ABILITY)
               
                // Create new index
                if (Index != 0) then
                    set Index = List[t]
                else
                    set Count = Count + 1
                    set t = Count
                endif
               
                set List[t] = -1
                set LastIndex = t
                set Unit[t] = u
               
                // Set unit index
                if (DEFAULT_HASHTABLE) then
                    call SaveInteger(Hash, 0, GetHandleId(u), t)
                    call SaveUnitHandle(Hash, 0, t, u)
                else
                    call SetUnitUserData(u, t)
                endif
               
                if (Initialized) then
                    // Execute custom events registered with RegisterUnitIndexEvent
                    call TriggerEvaluate(IndexTrig[EVENT_UNIT_INDEX])
                   
                    // Handle TriggerRegisterUnitIndexEvent
                    set E = EVENT_UNIT_INDEX

                    // Reset so the event can occur again
                    set E = -1
                endif
               
            endif

            set u = null
           
            return false
        endmethod

        private static method onLeave takes nothing returns boolean
            local unit    u
            local integer i
           
            // Check if order is undefend. I could check the ability level only but
            // that would be a few function calls every time a unit is ordered instead
            // of one.
            if (GetIssuedOrderId() == 852056 and Enabled) then
               
                set u = GetTriggerUnit()
               
                // If unit was killed (not removed) then don't continue
                if (GetUnitAbilityLevel(u, DETECT_LEAVE_ABILITY) != 0) then
                    return false
                endif
               
                set i = GetUnitId(u)

                // If unit has been indexed then deindex it
                if (i > 0 and u == GetUnitById(i) and i <= Count) then
                   
                    // Recycle the index
                    set List[i]   = Index
                    set Index     = i
                    set LastIndex = i
                   
                    // Remove to group of indexed units
                    call GroupRemoveUnit(Group, u)
               
                    // Execute custom events without any associated triggers
                    call TriggerEvaluate(IndexTrig[EVENT_UNIT_DEINDEX])
                   
                    // Handle TriggerRegisterUnitIndexEvent
                    set E = EVENT_UNIT_DEINDEX
                   
                    // Remove entry
                    if (DEFAULT_HASHTABLE) then
                        call RemoveSavedHandle(Hash, 0, i)
                    else
                        set Unit[i] = null
                    endif
                   
                    // Reset so the event can occur again
                    set E = -1
                endif
               
                set u = null
            endif
           
            return false
        endmethod
       
        static method onInit takes nothing returns nothing
            local trigger t         = CreateTrigger()
            local integer i         = 0
            local boolexpr leave    = Filter(function onLeave)
            local boolexpr enter    = Filter(function onEnter)
            local player p
            local unit u
           
           
            // Begin to index units when they enter the map
            call TriggerRegisterEnterRegion(CreateTrigger(), WorldBounds.worldRegion, enter)
           
            call TriggerAddCondition(t, leave)
           
            set IndexTrig[EVENT_UNIT_INDEX] = CreateTrigger()
            set IndexTrig[EVENT_UNIT_DEINDEX] = CreateTrigger()
           
            loop
                set p = Player(i)
               
                // Detect "undefend"
                call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
               
                // Index preplaced units
                call GroupEnumUnitsOfPlayer(ENUM_GROUP, p, enter)
               
                // Hide the detect ability from players
                call SetPlayerAbilityAvailable(p, DETECT_LEAVE_ABILITY, false)
               
                set i = i + 1
                exitwhen i == bj_MAX_PLAYER_SLOTS
            endloop
           
            if (DEFAULT_HASHTABLE) then
                set Hash=InitHashtable()
            endif
           
            call TimerStart(CreateTimer(), 0, false, function runInitTriggers)
        endmethod
   
    endstruct
    
    init
    	UnitDex.onInit()
    end
   
endlibrary

The code above compiles as a Jurst file. I just had to remove the parts which use features not supported by Wurst: Optional imports, static ifs, strange module usages, thistype, and some other things. I have not tested, whether it still works. Probably a bit more effort is required to really port it, but I think it is far less effort than translating all the syntax to Wurst.

Jurst allows to omit some syntax like set or call and one can use the same nice for loops as in Wurst. For example the onInit method from the example above could be rewritten like so:

JASS:
        static method onInit()
            let t = CreateTrigger()
            let enter = Filter(function onEnter)         
           
            // Begin to index units when they enter the map
            TriggerRegisterEnterRegion(CreateTrigger(), WorldBounds.worldRegion, enter)
           
            TriggerAddCondition(t, Filter(function onLeave))
           
            IndexTrig[EVENT_UNIT_INDEX] = CreateTrigger()
            IndexTrig[EVENT_UNIT_DEINDEX] = CreateTrigger()
           
           	for p in bj_FORCE_ALL_PLAYERS
                // Detect "undefend"
                TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
               
                // Index preplaced units
                GroupEnumUnitsOfPlayer(ENUM_GROUP, p, enter)
               
                // Hide the detect ability from players
                SetPlayerAbilityAvailable(p, DETECT_LEAVE_ABILITY, false)
            end
           
            if DEFAULT_HASHTABLE
                Hash=InitHashtable()
            end
           
            TimerStart(CreateTimer(), 0, false, function runInitTriggers)
        end
 
This is really cool, maybe it could become the new standard if it's significantly backwards compatible with vJass (which seems to be close).

peq said:
For people who do not like the indentation based syntax of Wurst.

Like me :p

peq said:
Jurst allows to omit some syntax like set or call and one can use the same nice for loops as in Wurst.

Not sure I like that. I would prefer it require either or.

Any chance of this being changed?
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
This is really cool, maybe it could become the new standard if it's significantly backwards compatible with vJass (which seems to be close).

It is not very backwards compatible to vJass, it is just a very similar syntax. And it is not a goal of Jurst to be backwards compatible with vJass, as this would be very difficult.

Not sure I like that. I would prefer it require either or.

Any chance of this being changed?

Hm, I was not expecting that there is anyone who actually likes to write 'call' and 'set' everywhere :p But as Jurst is still in some kind of very early alpha phase, everything can be changed and discussed.

My idea was to allow 'call' and 'set' to make porting old libraries easier, but for writing new code the default would be the shorter style. There could even be an auto formatting feature to remove all the unnecessary syntax.
 
peq said:
It is not very backwards compatible to vJass, it is just a very similar syntax. And it is not a goal of Jurst to be backwards compatible with vJass, as this would be very difficult.

Well maybe not for Nestharus' resources, but for people who use simple libraries + initializers it seems pretty compatible.

peq said:
My idea was to allow 'call' and 'set' to make porting old libraries easier, but for writing new code the default would be the shorter style. There could even be an auto formatting feature to remove all the unnecessary syntax.

I see. Maybe throw a deprecation warning but still allow it?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
So "end" can be used instead of all endWhatever (v)jass reserved word ?
That's good :thumbs_up:

This, and getting rid of set and call, declaring init in the library header, and globals / locals variables, all the things which annoyed me in vJass at the end.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
So "end" can be used instead of all endWhatever (v)jass reserved word ?

Yes.

Well maybe not for Nestharus' resources, but for people who use simple libraries + initializers it seems pretty compatible.

There are some big differences in the handling of libraries and initializers. For example:

  • public/private have different defaults and semantics
  • imports work differently
  • (J|W)urst uses init blocks and the init order is different
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Sometimes imports are required only because types of the imported package are used (for variables, globals, ...), a cycle of these kinds of imports does not pose a problem.
-> in this case you would use the initlater keyword.

What does pose a problem are imports where one initializer calls code from another package which requires that package to be initialized. If you use these imports in a cycle you dont know which package to initialize first.
 
Status
Not open for further replies.
Top