- Joined
- Jan 25, 2020
- Messages
- 6
I could not find this done before so I thought I might leave this here if anyone else also wants to store a lot of regions in a hashtable. With one custom script line you can store all your regions if you give them all a systematic name.
In my case I wanted a checkerboard of regions that is 14x14, so I simply named them "Region 0 0", "Region 0 1", ... "Region 13 13". Then they can all be store with this simple trigger:
Now a similar loop can be used to check what coordinates a unit is in without using any custom scripts. In my case I want to check what regions there is a neutral unit in, so it looks like this:
Edit:
Just changed to Bribe's better reference to the loop
In my case I wanted a checkerboard of regions that is 14x14, so I simply named them "Region 0 0", "Region 0 1", ... "Region 13 13". Then they can all be store with this simple trigger:
-
Regions in hashtable
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Hashtable - Create a hashtable
-
Set VariableSet Regions_Hashtable = (Last created hashtable)
-
For each (Integer A) from 0 to 13, do (Actions)
-
Loop - Actions
-
For each (Integer B) from 0 to 13, do (Actions)
-
Loop - Actions
-
Custom script: SaveRectHandleBJ(_G["gg_rct_Region_"..bj_forLoopAIndex.."_"..bj_forLoopBIndex], bj_forLoopAIndex, bj_forLoopBIndex, udg_Regions_Hashtable)
-
-
-
-
-
-
Now a similar loop can be used to check what coordinates a unit is in without using any custom scripts. In my case I want to check what regions there is a neutral unit in, so it looks like this:
-
test
-
Events
-
Player - Player 1 (Red) types a chat message containing -test as An exact match
-
-
Conditions
-
Actions
-
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is in (Units owned by Neutral Passive.).) Equal to True
-
-
Then - Actions
-
For each (Integer A) from 0 to 13, do (Actions)
-
Loop - Actions
-
For each (Integer B) from 0 to 13, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Load (Integer A) of (Integer B) in Regions_Hashtable.) contains (Picked unit)) Equal to True
-
-
Then - Actions
-
Game - Display to (All players) the text: ((String((Integer A))) + (, + (String((Integer B)))))
-
-
Else - Actions
-
-
-
-
-
-
-
Else - Actions
-
-
-
-
-
Edit:
Just changed to Bribe's better reference to the loop
Last edited: