1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'Triggers & Scripts' started by Argus, Jul 22, 2017.

  1. Argus

    Argus

    Joined:
    Jul 7, 2007
    Messages:
    215
    Resources:
    4
    Models:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    4
    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.
     
  2. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,285
    Resources:
    0
    Resources:
    0
    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?
     
  3. Argus

    Argus

    Joined:
    Jul 7, 2007
    Messages:
    215
    Resources:
    4
    Models:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    4
    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.