Hi Hive,
I'm looking for some pointers with picking up Wurst syntax.
How to iterate over all players in the game and spawn starting units for them?
I've read most of the documentation on WurstScript • Home including WurstScript • Manual (#for-loops) however I'm still painfully stuck.
Here's a pastebin of my current typical problems (wurstbin) and here's an example from it
I know C++ (UnrealEngine) and web development (JavaScript), so I know what a variable is, how to loop, and other general programming concepts and I'm a diehard unit tester. But I've never used Java or Python, so Wurst is pretty foreign.
I have no idea how Jass works, but am somewhat ok with GUI triggers (see for yourself below).
Wurst is really pretty, so I would indeed like to pick it up.
Generally, I belive if I could retype what I've done thusfar in GUI I would be ok.
E.g. below is my creep wave spawner.
Cheers
I'm looking for some pointers with picking up Wurst syntax.
How to iterate over all players in the game and spawn starting units for them?
I've read most of the documentation on WurstScript • Home including WurstScript • Manual (#for-loops) however I'm still painfully stuck.
Here's a pastebin of my current typical problems (wurstbin) and here's an example from it
Code:
@test function testUnitTesting()
let a = 5 * 2
a.assertEquals(10) // passes
@test function testGetPlayersUnitTest()
let a = GetPlayers() + 100
a.assertGreaterThan(0)
// fails with compiler errors!
// where to put that @compiletime ?
init
for player p in players
print(p.getName()) // compiler error
I know C++ (UnrealEngine) and web development (JavaScript), so I know what a variable is, how to loop, and other general programming concepts and I'm a diehard unit tester. But I've never used Java or Python, so Wurst is pretty foreign.
- I'm looking for code examples and other resources (I'm not really used to coding without the glorious stackoverflow...)
- Specifically answers to questions from that wurstbin (9 questions in total). Also, I'll buy you a cup of coffee for some chat time via some IM.
I have no idea how Jass works, but am somewhat ok with GUI triggers (see for yourself below).
Wurst is really pretty, so I would indeed like to pick it up.
Generally, I belive if I could retype what I've done thusfar in GUI I would be ok.
E.g. below is my creep wave spawner.
-
-------- Wave Increment --------
-
Actions
-
-------- Run wave --------
-
Trigger - Run Wave Load <gen> (checking conditions)
-
-------- Increment for next wave to total or reset to WaveDifficulty --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Wave Less than WavesTotal
-
-
Then - Actions
-
Set Wave = (Wave + 1)
-
-
Else - Actions
-
Set Wave = (Min(WaveDifficulty, WavesTotal))
-
Set WaveDifficulty = (WaveDifficulty + 1)
-
-
-
-------- Start timer --------
-
Countdown Timer - Start Timer as a One-shot timer that will expire in TimerDuration seconds
-
-
-------- Trigger Wave Load --------
-
Actions
-
-------- Type A --------
-
Set SpwnCount = (SpwnCountA[Wave] + WaveDifficulty)
-
Set SpwnUnitType = SpwnUnitTypeA[Wave]
-
Trigger - Run Wave Spawn <gen> (checking conditions)
-
-------- Type B and C (nested if statements) --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
SpwnCountB[Wave] Greater than 0
-
-
Then - Actions
-
-------- Type B --------
-
Set SpwnCount = (SpwnCountB[Wave] + WaveDifficulty)
-
Set SpwnUnitType = SpwnUnitTypeB[Wave]
-
Trigger - Run Wave Spawn <gen> (checking conditions)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
SpwnCountC[Wave] Greater than 0
-
-
Then - Actions
-
-------- Type C --------
-
Set SpwnCount = (SpwnCountC[Wave] + WaveDifficulty)
-
Set SpwnUnitType = SpwnUnitTypeC[Wave]
-
Trigger - Run Wave Spawn <gen> (checking conditions)
-
-
Else - Actions
-
-
-
Else - Actions
-
-
-------- Finish --------
-
Unit Group - Remove all units of SpwndGroups[0] from SpwndGroups[0]
-
Unit Group - Add all units of SpwnGroup to SpwndGroups[0]
-
Hashtable - Save Handle OfSpwndGroups[0] as 1 of 1 in Camps
-
Unit Group - Remove all units of SpwnGroup from SpwnGroup
-
-------- Testing --------
-
Game - Display to (All players) the text: (array + (String((Number of units in SpwndGroups[0]))))
-
Game - Display to (All players) the text: (single + (String((Number of units in SpwnGroup))))
-
Trigger - Run All Camps to Red <gen> (checking conditions)
-
-
-------- Trigger Wave Spawn --------
-
Actions
-
Unit - Create SpwnCount SpwnUnitType for Player 9 (Gray) at (Center of (Load 0 of 1 in Camps)) facing 0.00 degrees
-
Unit Group - Add all units of (Last created unit group) to SpwnGroup
-
Cheers
Last edited: