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

Hashtables skips remaining actions... confused.

Status
Not open for further replies.
Level 6
Joined
Apr 4, 2010
Messages
74
I've always been able to use hashtables perfectly fine (GUI), however, I recently ran into a problem.
  • growing hashtables
    • Events
    • Conditions
    • Actions
      • Hashtable - Save ((Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) - 1) as (Key growtime) of (Key (Random unit from TempGroup)) in HerbHashtable
      • Set TempInteger = ((Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable) - (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable))
      • Set TempInteger2 = ((100 / (Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable)) x TempInteger)
      • Set TempInteger = (TempInteger2 + 0)
      • Game - Display to (All players) the text: growing hash
(Dont mind crappy coding, I just wrote alot of things wrong in idiotic arichmetic thingy, and did like this out of rage)

Basicly this trigger is called (runned) by another trigger (run trigger ignoring conditions), but the results are the same if i put the branch of code in another trigger, which I am SURE runs.

Basicly, nothing happens. The text message you see at the bottom won't be displayed. If i copy the text message and put it at the top, (or write something else) then it will be displayed.
So I ran to the conclusion that one of these causes some kind of skip remaining actions... yeah, idk either.

If I put the text message after the first hashtable action, it still does not show.

HOWEVER, if i put it after one of the set variables, and move the hashtable one to the bottom, it DOES show.


So in the end, its the save integer that F*cks up.

Any sulotion?
Btw, I'm using standard world editor, but tested it with Newgen as well, same problem.

+rep and cookie if solved!
(cookie not garaunteed)


EDIT:
Yes, there is only one unit in "Tempgroup", if you need to know.

EDIT2:
Hmm... woops. Maybe I should have posted it in "triggers and scripts", could someone move the thread...?

EDIT3:
God, sorry, I've been totally wrong.
I tried to change the trigger abit, trying to make it... smaller:
  • growing hashtables
    • Events
    • Conditions
    • Actions
      • Hashtable - Save ((Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) - 1) as (Key growtime) of (Key (Random unit from TempGroup)) in HerbHashtable
      • Game - Display to (All players) the text: growing hash set ha...
      • Set TempInteger = ((100 / (Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable)) x ((Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable) - (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable)))
      • Game - Display to (All players) the text: growing hash set var
I dont know how I maged before but...
IT IS NOT THE SAVE INTEGER, IT IS THE SET VARIABLE
growing hash set hash: displays
growing hash set var: does not

Basicly the set variable here causes the trigger to skip its remaining actions.
Setting a simple value like "2" doesent skip the rest, and as far as I know, all the TempIntegers in the other triggers works fine.

And for some reason, TempInteger always returns "1".
Probably doesent set at all, and the "1" is from another trigger using TempInteger, that ran earlier.
Probably refering to my player number somehow... "1". I use TempInteger alot.
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I see you edited post, and added information about tempgroup, great.

Now, at first: Have you created hashtable in map initialization trigger and set it to variable HerbHashtable?

Second: show other triggers.

Third: If you run this triger after creating tempgroup why dont put it into that trigger?

Text: growning hash is variable, or just a text?
 
Level 6
Joined
Apr 4, 2010
Messages
74

So you're saying that it won't work with this trigger but works in another trigger? If so, if you copy and paste triggers, sometimes the data within them tend not to work.


No, Im saying that in all triggers, remaining actions are skipped because of the save integer in hashtable.
Should i try creating the action again?

Now, at first: Have you created hashtable in map initialization trigger and set it to variable HerbHashtable?
Yes, it is created at 0.10 elapsed game time. Double... no, triple-checked.
Although there are 2 hashtables, is that a problem?
Second: show other triggers.
Sure.
I originally had the branch of code in this trigger, exactly where I ran the other trigger, and exact same thing, it skipped the rest of the trigger.
The reason for setting TempUnit is... well, because of testing, didnt understand exactly why the unit size didnt change until I figured out the hash thingy, thought it was cuz it didnt find (random unit from (tempgroup)).

When another action is runned which contains the feared hashtable line, the rest of this trigger runs fine, although TempInteger gets messed up, since it's skipped before it can be set.
  • Growiiiiiing
    • Events
      • Time - Every 2.50 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: grow start
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • For each (Integer B) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
                  • Set TempGroup = (Units in Region 016 <gen> matching ((Matching unit) Equal to No unit))
                  • Unit Group - Add HerbPlant[(((Integer B) x 10) + (Integer A))] to TempGroup
                  • Game - Display to (All players) the text: (Name of (Random unit from TempGroup))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • HerbPlantGrowing[(((Integer B) x 10) + (Integer A))] Equal to True
                      • (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) Greater than 0
                      • ((Random unit from TempGroup) is alive) Equal to True
                    • Then - Actions
                      • Game - Display to (All players) the text: growing
                      • Trigger - Run growing hashtables <gen> (ignoring conditions)
                      • Game - Display to (All players) the text: (String(TempInteger))
                      • Set TempUnit = (Random unit from TempGroup)
                      • Game - Display to (All players) the text: (Name of TempUnit)
                      • Animation - Change TempUnit's size to ((Real(TempInteger))%, (Real(TempInteger))%, (Real(TempInteger))%) of its original size
                    • Else - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
            • Else - Actions
Third: If you run this triger after creating tempgroup why dont put it into that trigger?
The trigger were actually for testing porpuses originally (the one that is runned), and I thought it would be better to post it, because it's easier to tell you problem without unnecessary information.

See above trigger for when TempGroup is created.

Text: growning hash is variable, or just a text?
Baka. A variable can't contain spaces. and im pretty sure it gets an ().
It was created for testing porpuses, and to explain what happens in trigger (see first comment) =)
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
  • Growiiiiiing
    • Events
      • Time - Every 2.50 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: grow start
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • For each (Integer B) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
                  • Set TempGroup = (Units in Region 016 <gen> matching ((Matching unit) Equal to No unit))
                  • Unit Group - Add HerbPlant[(((Integer B) x 10) + (Integer A))] to TempGroup
                  • Game - Display to (All players) the text: (Name of (Random unit from TempGroup))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • HerbPlantGrowing[(((Integer B) x 10) + (Integer A))] Equal to True
                      • (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) Greater than 0
                      • ((Random unit from TempGroup) is alive) Equal to True
                    • Then - Actions
                      • Game - Display to (All players) the text: growing
                      • Trigger - Run growing hashtables <gen> (ignoring conditions)
                      • Game - Display to (All players) the text: (String(TempInteger))
                      • Set TempUnit = (Random unit from TempGroup)
                      • Game - Display to (All players) the text: (Name of TempUnit)
                      • Animation - Change TempUnit's size to ((Real(TempInteger))%, (Real(TempInteger))%, (Real(TempInteger))%) of its original size
                    • Else - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
            • Else - Actions
At first i wasnt looking so carefully to see space between the text so thats why i asked about variable/text.
Did you run your testing trigger with or without conditions?

This trigger is total mess. I have never seen such way for creating groups.
better use:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit matching conditions ((Matching unit) Equal to YourherbUnitorWhatever) and do Actions
<here actions>
Remember torefer to given unit via Picked unit.

Pharaoh_ if you want to fix this go ahead, but i say: Tell what you wnat this triger to do, and leave rest to me.
 
Level 6
Joined
Apr 4, 2010
Messages
74
  • Growiiiiiing
    • Events
      • Time - Every 2.50 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: grow start
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • For each (Integer B) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
                  • Set TempGroup = (Units in Region 016 <gen> matching ((Matching unit) Equal to No unit))
                  • Unit Group - Add HerbPlant[(((Integer B) x 10) + (Integer A))] to TempGroup
                  • Game - Display to (All players) the text: (Name of (Random unit from TempGroup))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • HerbPlantGrowing[(((Integer B) x 10) + (Integer A))] Equal to True
                      • (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) Greater than 0
                      • ((Random unit from TempGroup) is alive) Equal to True
                    • Then - Actions
                      • Game - Display to (All players) the text: growing
                      • Trigger - Run growing hashtables <gen> (ignoring conditions)
                      • Game - Display to (All players) the text: (String(TempInteger))
                      • Set TempUnit = (Random unit from TempGroup)
                      • Game - Display to (All players) the text: (Name of TempUnit)
                      • Animation - Change TempUnit's size to ((Real(TempInteger))%, (Real(TempInteger))%, (Real(TempInteger))%) of its original size
                    • Else - Actions
                  • Custom script: call DestroyGroup (udg_TempGroup)
            • Else - Actions
At first i wasnt looking so carefully to see space between the text so thats why i asked about variable/text.
Did you run your testing trigger with or without conditions?

This trigger is total mess. I have never seen such way for creating groups.
better use:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit matching conditions ((Matching unit) Equal to YourherbUnitorWhatever) and do Actions
<here actions>
Remember torefer to given unit via Picked unit.

Pharaoh_ if you want to fix this go ahead, but i say: Tell what you wnat this triger to do, and leave rest to me.

Wantdestroygroup does pretty much the same, but I prefer my way, you got a problem with that?
Also, I can't create groups your "non-messy" way, because the unit is locust and can't be reffered to that way. Why would I do something like that without a reason?
Cant do pick all unit in group and do actions either, because as I said, it's a locust. Still, I know for sure it works this way, cause' I tested with text messages.

Don't say that you are the only one who has the rights to help me, so far pharao_ has said far more useful stuff than you.

And why do you even care if my trigger is "messy" or care about it what so ever? All I want to know is why hashtable thingy for some reason skips actions, and since there is nothing like "skip actions for that trigger", there is nothing which can interuppt it but that once it starts, which it does.

The other trigger got nothing to do with the problem, there is no need to critisise it or care about it at all if you wanna help me.

Offtopic: The qoute in your sig should be "because if there is one thing I know..."


EDIT:
Just so that dosesent interupt, the unit is without locust right now, I just coded it like this because im gonna make it locust once I solve this goddamn bug.

EDIT2:
Sorry, my computer has been annoying me, and I felt abit insulted when you said I was triggering the wrong way.
I apologize if I insulted you.
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Heh i didnt mean to hurt you or insult either. I'm a bit sleep, will work on this tomorrow if Pharaoh_ wont do it before.

I said messy because im not used to use such triggers and loops, they are inefficent and are pains to look at.
Appologizes anyways.

I never heard that you cant pick unit with locust. Slap me if im wrong but you should be able to do that. You need that unit only to refer via it to hashtable to get unique id.

Just to you information: Real & integers and things that you mentioned shouldnt skip remaining actions. It's impossible, without proper conditions ofcourse.
Tomorrow..
 
Level 6
Joined
Apr 4, 2010
Messages
74
I've been wrong, did some testing now. Read "Edit 3" In first post.

And no, a side-effect of locust is that it can't be picked by unit groups
three examples of people discussing that (one more than the other) if you read the entire threads:
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/locust-ability-36149/
http://www.thehelper.net/forums/showthread.php/42758-What-can-you-do-with-units-that-have-locust
http://www.hiveworkshop.com/forums/triggers-scripts-269/very-strange-locust-related-problem-154950/
 
Okay, so the problem is that it keeps picking a new random unit from the group when you are using the hashtable.

Each time you use "Random unit from (Unit Group)", it will choose a random unit. If you use it again immediately afterward, it might be the same unit, or it might not. It is randomized again.
  • Hashtable - Save ((Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable) - 1) as (Key growtime) of (Key (Random unit from TempGroup)) in HerbHashtable
  • Set TempInteger = ((Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable) - (Load (Key growtime) of (Key (Random unit from TempGroup)) from HerbHashtable))
  • Set TempInteger2 = ((100 / (Load (Key growtimemax) of (Key (Random unit from TempGroup)) from HerbHashtable)) x TempInteger)
When you are saving these, you are saving it most likely to a different unit each time. The fix is to store a unit as the random unit, and then use the key of that.
  • Set TempUnit = Random unit from TempGroup
The reason why it is not performing the functions afterward is because the thread is crashing. It tries to load data that does not exist (because it is not loading it from the correct "random unit"), so it returns 0. You are setting TempInteger2 to 100/0, which, as you can tell from calculators, leaves a divide-by-zero error. :)

So then the thread crashes in game and the functions afterward can't be performed. Basically, assign the random unit to a variable and use it for the hashtable functions, and it should work fine.
 
Level 6
Joined
Apr 4, 2010
Messages
74
Im sorry, im really emberrassed.
The key string was supposed to be "maxgrowtime" not "growtimemax"
For some reason this skipped the actions below it.
It works now.
Im really sorry for wasting your time ::goblin_cry::goblin_cry:

EDIT:
Yeah purge was right, the key string returned 0 and therefore it crashed. Very close, so I'll +rep ya.
 
Status
Not open for further replies.
Top