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

Saving Triggers in Hashtables

Status
Not open for further replies.
Level 2
Joined
May 21, 2010
Messages
10
How do I save one trigger in a hashtable?
I mean, I am making one hero choose system and it is currenlty like this:
There are 2 classes, and 2 players, so...

First Trigger:
Name: Hashtable
Events:
Map Initialization
Actions:
Hashtable - Create Hashtable
---------------------------------
Second Trigger:
Name: Player 1 Trigger 1
Events:
Player - Player 1 (Red) types a chat message containing -adventurer1 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 1 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer1 for Player 1 (Red) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 1 of 4 in (Last created hashtable))
Trigger - Turn off (Load 2 of 4 in (Last created hashtable))
-------------------------------------------------------------
Third Trigger:
Name: Player 1 Trigger 2
Events:
Player - Player 1 (Red) types a chat message containing -adventurer2 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 2 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer2 for Player 1 (Red) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 1 of 4 in (Last created hashtable))
Trigger - Turn off (Load 2 of 4 in (Last created hashtable))
-------------------------------------------------------------
Fourth Trigger:
Name: Player 2 Trigger 1
Events:
Player - Player 2 (Blue) types a chat message containing -adventurer1 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 3 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer1 for Player 2 (Blue) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 3 of 4 in (Last created hashtable))
Trigger - Turn off (Load 4 of 4 in (Last created hashtable))
---------------------------------------------------------------------
Fifth Trigger:
Name: Player 2 Trigger 2
Events:
Player - Player 2 (Blue) types a chat message containing -adventurer2 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 4 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer2 for Player 2 (Blue) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 3 of 4 in (Last created hashtable))
Trigger - Turn off (Load 4 of 4 in (Last created hashtable))
------------------------------------------------------------

Well, it is obvious I get an error, because the trigger is only saved in the hashtable after I run it, so, I get the 2 heroes, how do I save those 4 triggers in a hashtable without running them once?
 
There are two ways of achieving this:

1)
  • Trigger0
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (IntegerA) from 1 to 12, do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger <gen> the event (Player - Player(IntegerA) types a message containing -adventurer as A substring
        • Player Group - Add (Player(IntegerA)) to TempForce
  • Trigger
  • Events
  • Conditions
    • ((Triggering player) is in TempForce) Equal to True //Boolean comparison
  • Actions
    • Set String = (Substring((Entered chat string), 12, (Length of (Entered chat string)))
    • Set Point1 = ((Triggering player)'s Start Location)
    • Player Group - Remove (Triggering player) from TempForce
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (String) Equal to 1 //String comparison
      • Then - Actions
        • Unit - Create 1 Adventurer1 for (Triggering player) at (Point1) facing Default buildings facing degrees
      • Else - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (String) Equal to 2
          • Then - Actions
            • Unit - Create 1 Adventurer2 for (Triggering player) at (Point1) facing Default buildings facing degrees
          • Else - Actions
    • Custom script: call RemoveLocation (udg_Point1)
String is a String variable.
TempForce is a Player Group variable.

References:
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Status
Not open for further replies.
Top