Integer not changing??

tork

New Member
Reaction score
2
So i have this trigger and ever 10 seconds he pick all player and see if that player has enough food to supply for him/her unit but the integer (Temp_Integer) never change between when the trigger is fired up.

Here my trigger:
Trigger:
  • FoodUse
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) controller) Equal to User)) and do (Actions)
        • Loop - Actions
          • Set Temp_Integer = 0
          • Set Temp_Group = (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to False))
          • Set Temp_Integer = (Number of units in Temp_Group)
          • Custom script: call DestroyGroup (udg_Temp_Group)
          • Set Temp_Integer = (Temp_Integer x 3)
          • Game - Display to (Player group((Picked player))) the text: (String(Temp_Integer))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Integer Less than or equal to Food[(Player number of (Picked player))]
            • Then - Actions
              • Set Food[(Player number of (Picked player))] = (Food[(Player number of (Picked player))] - Temp_Integer)
              • Multiboard - Set the text for (Last created multiboard) item in column 4, row (Integer(Multiboard_Spots[(Player number of (Picked player))])) to (String(Food[(Player number of (Picked player))]))
            • Else - Actions
              • Game - Display to (Player group((Picked player))) the text: |CFFFF0303Warning|R...
              • Set Food[(Player number of (Picked player))] = 0
              • Multiboard - Set the text for (Last created multiboard) item in column 4, row (Integer(Multiboard_Spots[(Player number of (Picked player))])) to (String(Food[(Player number of (Picked player))]))
              • Set Temp_Group = (Units in (Playable map area) owned by (Picked player))
              • Unit Group - Pick every unit in Temp_Group and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Not equal to True
                    • Then - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (Random real number between 32.00 and 61.00))
                    • Else - Actions
              • Custom script: call DestroyGroup (udg_Temp_Group)
          • Set Temp_Integer = 0


Thank you for any help you can give:)

+rep to people who give an good answer:shades:
 

Icyculyr

I'm a Mac
Reaction score
68
So TempInteger never displays anything but 0?

Well, I'd say it's possible your unit group has no units in it.
Try replacing the action you set Temp_Group to a unit group with:
Trigger:
  • Set Temp_Group = (Units owned by (Picked player)

Is there any change?

Kind Regards
 

tork

New Member
Reaction score
2
no it only displays the first integer it is set to which in this care for my test of the tigger is 54
 

ZakkWylde-

New Member
Reaction score
14
Are you sure you want to DESTROY the temporary group...?
I have a feeling that may be the root of your problems...hrmmm

And why destroy the group when you're going to reset it for the next player anyways...?
 

cleeezzz

The Undead Ranger.
Reaction score
268
>And why destroy the group when you're going to reset it for the next player anyways...?

because it'll leak

>Are you sure you want to DESTROY the temporary group...?

should be fine, the value is set before it was destroyed

my guess is he has 50 something units and when they die, its still getting counted because theres no Unit is alive condition
 

Justice-BR

New Member
Reaction score
8
>And why destroy the group when you're going to reset it for the next player anyways...?

because it'll leak

No
it wont. otherwise any variable change would cause a leak

Anyway, you got a looping playergroup leak that's more serious.
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
You've added two times this code:
Trigger:
  • Set Temp_Integer = 0

It makes no sense, remove it.

And why your code isn't working well, try some more debugging messages in each if else statement. The code seems alright but I don't know if any conditions may return "false" while you think it returns true.

And GUI uses alternate functions to return unit groups, those groups are newly created and MUST be destroyed after use. Otherwise it will leak.
 

cleeezzz

The Undead Ranger.
Reaction score
268
>No
>it wont.

Yes it will, anyway, this problem won't be solved until poster provides more info after doing some debug tests + adding in the Matching unit is alive condition
 

Justice-BR

New Member
Reaction score
8
OMG cleeeeez

please, learn something
ask anyone if you want

integers DO NOT LEAK



his problem is simple

he is destroying an integer that he will use again.
simple.
 

cleeezzz

The Undead Ranger.
Reaction score
268
but its not an integer, its a unit group...

>Are you sure you want to DESTROY the temporary group...?
>I have a feeling that may be the root of your problems...hrmmm

if you havent noticed, we're talking about the Temp_Group, not the Temp_Integer
please, read
 

cleeezzz

The Undead Ranger.
Reaction score
268
>picked player = useless without Pick every player in (...) and so on...

its solved plus, he does use a "Pick every player in" loop
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top