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

[Solved] Dialogue Hashtables Don't Work

Status
Not open for further replies.
Level 9
Joined
Feb 24, 2018
Messages
342
The idea is to create a dialog with two buttons for each human player at the beginning of the game.
I figured I'd use hashtables, since that would let me adapt the trigger for variable number of players.
Here's what I came up with:

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set intPlayerCount = 1
      • Hashtable - Create a hashtable
      • Set Player_Hashtable = (Last created hashtable)
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle Of(Picked player) as intPlayerCount of 1 in Player_Hashtable
          • Set intPlayerCount = (intPlayerCount + 1)
      • Hashtable - Create a hashtable
      • Set DialogB_Hashtable = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set Dialog_Hashtable = (Last created hashtable)
  • CharacterCreation1
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to intPlayerCount, do (Actions)
        • Loop - Actions
          • Dialog - Clear (Load (Integer A) of 1 in Dialog_Hashtable)
          • Dialog - Change the title of (Load (Integer A) of 1 in Dialog_Hashtable) to Character
          • Dialog - Create a dialog button for (Load (Integer A) of 1 in Dialog_Hashtable) labelled Create New Character
          • Hashtable - Save Handle Of(Last created dialog Button) as (Integer A) of 1 in DialogB_Hashtable
          • Dialog - Create a dialog button for (Load (Integer A) of 1 in Dialog_Hashtable) labelled Load Save Code
          • Hashtable - Save Handle Of(Last created dialog Button) as (Integer A) of 2 in DialogB_Hashtable
          • Dialog - Show (Load (Integer A) of 1 in Dialog_Hashtable) for (Load (Integer A) of 1 in Player_Hashtable)
          • Trigger - Add to CharacterCreation2a <gen> the event (Dialog - A dialog button is clicked for (Load (Integer A) of 1 in Dialog_Hashtable))
However, in game it does nothing. No dialog windows appear, nothing.
Where have I made a mistake?
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,013
Are you sure both triggers are successfully running? (debug messages, init thread isn't crashing, etc.) Are you certain you're not near the hashtable limit (255) and thus trying to create at least one of them fails?

It doesn't appear that you're assigning/saving anything to the dialog hashtable, yet you're trying to load from it in the second trigger. You'd be loading a null object in that case and then trying to clear it/add shit to it/show it. You need to do something like 1. create an empty dialog in the first trigger, 2. save that dialog into the hashtable under the right keys, 3. then load the dialogs in the second trigger and change them as you wish.

You're leaking a player group in the first trigger.
 
Level 9
Joined
Feb 24, 2018
Messages
342
First trigger is definitely running. It has some unrelated actions that definitely occur.
I don't use hashtables as much as I should, so there's probably less than a dozen of them.

Aha, that makes sense! I'll try it as soon as I get home. Thanks a lot!
 
Level 9
Joined
Feb 24, 2018
Messages
342
Hm, good point. Even though I don't use many of those yet, I think I'll put Dialogs and Buttons into a single hashtable so I don't have an extra hashtable for no reason.

UPDATE: Yeah, creating Dialogs first, loading them into Hashtable and using only after that worked (obviously). The only thing to consider was that I originally tried creating those empty dialogs right at initialization, and they didn't visually show up, although the buttons could still be clicked with Enter. Fixed that too, obviously.
 
Last edited:
Status
Not open for further replies.
Top