[Solved] Failing to load (or save?) certain values from hashtable

Status
Not open for further replies.
Level 9
Joined
Jul 7, 2007
Messages
229
I'm setting up this system that saves a bunch of destructibles in a hashtable, and then also sets the corresponding coordinate in another hashtable to true or false depending on if there was a destructible there to save.

  • Tile Indexer
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to TB2D_MapSize_Y, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to TB2D_MapSize_X, do (Actions)
            • Loop - Actions
              • Destructible - Pick every destructible within (TB2D_TileSize / 2.00) of TB2D_TileIndexerPoint and do (Actions)
                • Loop - Actions
                  • Hashtable - Save Handle Of(Picked destructible) as (Integer A) of (Integer B) in TB2D_Table_of_Tiles
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Integer A) is stored as a Handle of (Integer B) in TB2D_Table_of_Tiles) Equal to True
                • Then - Actions
                  • Hashtable - Save True as (Integer A) of (Integer B) in TB2D_Table_of_Booleans
                • Else - Actions
              • Set TB2D_TileIndexerPoint = (TB2D_TileIndexerPoint offset by (TB2D_TileSize, 0.00))
          • Set TB2D_TileIndexerPoint = (TB2D_TileIndexerPoint offset by ((0.00 - (TB2D_TileSize x (Real(TB2D_MapSize_X)))), (0.00 - TB2D_TileSize)))
But when I use this debugging trigger...:

  • issaved
    • Events
      • Player - Player 1 (Red) types a chat message containing show as A substring
    • Conditions
    • Actions
      • Game - Display to (All players) the text: ----------
      • Game - Display to (All players) the text: (Name of (Load (Integer((Substring((Entered chat string), 6, 6)))) of (Integer((Substring((Entered chat string), 8, 8)))) in TB2D_Table_of_Tiles))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Integer((Substring((Entered chat string), 6, 6)))) of (Integer((Substring((Entered chat string), 8, 8)))) from TB2D_Table_of_Booleans) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: true
        • Else - Actions
          • Game - Display to (All players) the text: false
      • Game - Display to (All players) the text: ----------
      • Animation - Play (Load (Integer((Substring((Entered chat string), 6, 6)))) of (Integer((Substring((Entered chat string), 8, 8)))) in (Last created hashtable))'s stand animation
...it reports every coordinate as false, even those that should be true. It correctly loads the corresponding destructible name, and when debugging I found that the if/then/else bit in the first trigger for determining if something is saved to that coordinate is firing correctly, so I can't find the problem. I posted both triggers since I'm not sure where the problem lies.

P.S. I know the first trigger leaks, it is work in progress.
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
In the second trigger, you use (Last created hashtable)

In the first trigger you save at the position (Y,X). (X,Y) is how you usually do it. Anyway in the second trigger you have to use "show Y X" as chat message. Are you sure that you have used the right order in your tests?

I would not only print the name of the dsetructible (because a lot of them will have the same name), but also create a flying unit at the position of the destructible to confirm it is the right one.

In your first trigger print whenever a boolean is stored as true to check whether the condition works correctly.

Have you created both hashtables?
 
Level 9
Joined
Jul 7, 2007
Messages
229
In the second trigger, you use (Last created hashtable)

In the first trigger you save at the position (Y,X). (X,Y) is how you usually do it. Anyway in the second trigger you have to use "show Y X" as chat message. Are you sure that you have used the right order in your tests?

I would not only print the name of the dsetructible (because a lot of them will have the same name), but also create a flying unit at the position of the destructible to confirm it is the right one.

In your first trigger print whenever a boolean is stored as true to check whether the condition works correctly.

Have you created both hashtables?

Of course it turns out to be a trivial detail, I had not created the second hashtable :) Thank you, for the solution, and for the detail about X-Y-order, I was testing on a symmetrical grid so I hadn't noticed.
 
Status
Not open for further replies.
Top