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

[Trigger] Are Undefined Loops possible in GUI?

Status
Not open for further replies.
Level 2
Joined
Nov 18, 2005
Messages
17
Ok so I'm trying to make an item spawn on Fall Grass only. I want it to create at a random point and check if the item is on terrain type Fall Grass: if not, move it again and check again (until it's on the grass) and if it is on the grass, skip remaining actions. I'm sure this would be much easier to do in JASS just using some kind of do while loop or something but I haven't taken the time to learn JASS quite yet. My question is, are undefined for loops possible? Is there any way to re-enter a for loop in GUI without putting that for loop inside another for loop? Lol. Any help or alternative ways to accomplish this will definitely recieve some rep :)
 
Level 4
Joined
Jan 9, 2010
Messages
89
I think this trigger sould do what you want. (Maybe not in the way asked for but it should do what you want).

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set point = (Random point in (Playable map area))
      • Item - Create Crown of Kings +5 at point
      • Custom script: call RemoveLocation(udg_point)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain type at (Position of (Last created item))) Equal to Lordaeron Fall - Grass
        • Then - Actions
          • Item - Remove (Last created item)
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
 
Level 2
Joined
Nov 18, 2005
Messages
17
o_O It's so simple...! That's much better than what I had for the meantime. I just had the For loop loop 100 times, and once it was found on the grass have it skip remaining actions. Yours is much better - it's cleaner and doesn't leak!! Thanks much, +rep!! :)
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
probably something like this (you will need a good way to find the next point with your tile-set though)
  • DropItem
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Set b = False
      • Custom script: loop
      • Custom script: exitwhen udg_b
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • True Equal to True
        • Then - Actions
          • Set b = True
          • -------- Loop will end --------
          • -------- Your final actions go here --------
        • Else - Actions
      • Custom script: endloop
you could also use a GUI loop which will run up to a very high number (but there is a limit in wc3 which prevents it from executing more then 2^16 or something functions per trigger run)

edit: nvm..
however a trigger execution is MUCH slower then calling a function :p
 
Status
Not open for further replies.
Top