1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Hashtables and MUI

Discussion in 'Trigger (GUI) Editor Tutorials' started by wyrmlord, Jun 26, 2009.

  1. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    The 2D arrays in vJass
    a) are not bugged
    b) are faster than hashtables

    Hashtables can have an infinite number of indices, however, which is more than you can say for vJass 2D arrays.
     
  2. SlayerII

    SlayerII

    Joined:
    Aug 21, 2008
    Messages:
    526
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    So if i have a item table should i use a 2d array or a hastable(the array should save lvl and type of item exemple a 13(lvl) 3(type) gives a helm wich i gave a lvl 13 armor bonus
     
  3. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    hashtables would be better I think, because then you could store values to the huge numbers of item rawcodes.
     
  4. Yixx

    Yixx

    Joined:
    Oct 12, 2008
    Messages:
    1,492
    Resources:
    3
    Spells:
    3
    Resources:
    3
    The tutorial is very nice. Not extremely usefull to me because i already kinda figured it out, but very usefull to new people and people who are just new to hashtables.

    This way gives a much easier MUI way for GUI, and not to forget, spells stack much easier this way! You can just set the duration back to 10, or add 10 to the duration, whatever is your preference.

    Good job!

    BTW: When will THW support GUI hashtable actions? (Now it gives a question mark, as you can all see)
     
  5. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    I will never use them, where should I need them for, if I can do my vJASS stuff with structs...
     
  6. SlayerII

    SlayerII

    Joined:
    Aug 21, 2008
    Messages:
    526
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Cause you also use strings for the keys of the hashtables, making it easier to use em(if you need 30 keys its easier if you name instaed of having the numbers 1-30)
     
  7. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    But, the same thing is what I can do with structs, but structs are older and work without any bugs.
     
  8. Michael Jackson

    Michael Jackson

    Joined:
    Jul 8, 2009
    Messages:
    12
    Resources:
    0
    Resources:
    0
    I still don't get this...as to why this is useful.
     
  9. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    There are some things which are quite hard to do with just structs, for example if you need a separate timer for each instance of the spell. These things are much easier to do with hashtables.
     
  10. Lightstalker

    Lightstalker

    Joined:
    Jul 8, 2008
    Messages:
    150
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Well I was trying to create a hashtable per unit every time it casted the spell so a spell is MUI and SUI (Same Unit Instanceable).

    How would you create only 1 hashtable per spell??? Explain everything! :grin:
     
  11. SlayerII

    SlayerII

    Joined:
    Aug 21, 2008
    Messages:
    526
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    lol are you tottally retarded:grin:

    hashtables in the examplas are using the ID of units so the only way to make a bug is that a unit cast the same spell more than one time. But this should be also easy to solve.

    So:read the tutorial esatly before asking this :thumbs_up:
     
  12. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    You could try storing new hashtables in one main hashtable, but I guess you'd need an indexing system to organise it so... it's a very hard thing to achieve.
     
  13. wyrmlord

    wyrmlord

    Joined:
    Oct 13, 2005
    Messages:
    252
    Resources:
    5
    Tools:
    1
    Maps:
    1
    Tutorials:
    3
    Resources:
    5
    This would be a rather simple problem in JASS since timers can be created dynamically while timers in GUI need to be created at map init. In GUI, I would probably prefer to use an approach with arrays that used some careful indexing. I recommend asking for help in the Triggers and Scripts forum since it isn't entirely about hashtables.
     
  14. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Ok since this is gonna be dealing hashtables (and I must say very easy-to-understand tutorial, GOOD JOB!) there's one thing on efficiency I think should have been mentioned since all users that want to make MUI spells using hashtables are gonna be reading this tutorial from now on.

    You know how using indexing GUI'ers turn the periodic event on and off, yupp something like that.

    Here's a very fast draft I did (it's just a draft so don't tell me there's something wrong :p):
    Main Trigger
    • Main
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Animate Dead
      • Actions
        • -------- bla bla bla --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in DT) Equal to 0
          • Then - Actions
            • Trigger - Turn on Loop <gen>
          • Else - Actions
        • Unit Group - Add (Triggering unit) to DT

    Looping (Periodic) Trigger
    • Loop
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in DT and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • -------- bla bla bla --------
              • Then - Actions
                • -------- bla bla bla --------
              • Else - Actions
                • -------- Clearing hashtables and all --------
                • Unit Group - Remove (Triggering unit) from DT
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Number of units in DT) Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                  • Else - Actions


    Makes sense eh?

    Umm anyways, about hashTables, gotta make things a piece of cake, specially since now GUI users can basically use their arrays to loop through variables instead of using them to index.

    I guess that could be useful for those Jassers who don't use vJass, although I doubt anyone would prefer hashtables over structs, 'cause that's just absurd...

    Good job on this tutorial :)
     
  15. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    There are things which require attachment systems, and it seems to me that hashtables would make an ideal way of attaching things in vJass.
     
  16. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Huh? You can increase the index by X and save it in the SpellHashtable, and after the instance shut down, you decrease it? Whats so hard about it?

    Anyway, I would prefer structs, as already told.
     
  17. Rmx

    Rmx

    Joined:
    Aug 27, 2007
    Messages:
    1,088
    Resources:
    18
    Icons:
    3
    Spells:
    15
    Resources:
    18
    When you do indexing system in GUI ... the spell will be MUI SUI ext..

    But hashtables if you want it SUI ( Same Unit Insta... ) you have to index that unit bla bla .

    Anyway Hashtable is easy to use but still same as indexing if Indexing is recycled right ^^
     
  18. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Ok we are here to discuss the tutorial I guess rather than commenting on what's better and what's not, so I think closing this thread would be appropriate by now as the tutorial got enough comments (in my opinion).
     
  19. Lightstalker

    Lightstalker

    Joined:
    Jul 8, 2008
    Messages:
    150
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Yeah what I said was pretty dumb lol. Must have been tired when I wrote it.

    Anyway, what I meant to say was this: how could you make hashtables SUI? Seeing as how when you cast the spell again, the previous values for that unit will be overwritten.

    It seems everyone has suggested indexing system. How would that work? Could it be done in GUI?
     
  20. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    Use Paladon's indexing system. Simplez.