Any way to use this variable faster?

unknown666

New Member
Reaction score
5
Hey,

I got a trigger here which uses some variable's, but since I need the same trigger kind 40x+ the same, is there anyway to make this faster?

Trigger:
  • Events
    • Unit - A unit enters house1
    • Conditions
    • Actions
    • If (All conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Owner of (Entering Unit)) Equal to (Owner of HousePermissionHouse1[1])
    • Then - Actions
      • Unit - Move (Entering unit) instantly to (Center of House1Enter <gen>)
    • Else - Actions

Is there a way I can make the trigger to read the variable HousePermissionHouse1[1] to HousePermissionHouse1[10] in 1 action?

Kind Regards,

unknown666
 

unknown666

New Member
Reaction score
5
how? I never used loops before..

EDIT:

I mean.. how can I make a unit variable an integer variable? Oo
 

Cookiemaster

New Member
Reaction score
36
Run an integer A loop from 1 to the highest value you want, and instead of using Variable[1], use Variable[Integer A].

So like:

Integer A loop from 1 to 10
-If/Then/Else
--If
---owner of entering unit = owner of HousePermissionHouse[IntegerA]
--then
---do actions
--else
---do actions

Basically it will run that part 10 times, and replace integer A with the integer values 1 to 10.


EDIT: see post below mine.
 

UndeadDragon

Super Moderator
Reaction score
447
Trigger:
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • (Owner of (Entering Unit)) Equal to (Owner of HousePermissionHouse1[Integer A])
        • Else - Actions
          • Do actions here.
 

unknown666

New Member
Reaction score
5
Trigger:
  • Events
    • Unit - a unit enters House1 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Entering unit) Equal to (Owner of Circle of Power 0027 <gen>)
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to (Center of HouseEnter <gen>)
        • Else - Actions
          • For each (Integer A) from 1 to 10, do (Actions
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Entering unit)) Equal to (Owner of HousePermissionHouse1[(Integer A)]
                • Then - Actions
                  • Unit - Move (Entering unit) instantly to (Center of houseEnter <gen>)
                • Else - Actions


Trigger:
  • Events
    • Player - (Owner of Circle of Power 0027 <gen>) types a chat message containing -grant blue as An exact match
    • Conditions
    • Actions
      • Set HousePermissionHouse1[2] = HeroPlayer[2]

It still doesn't work, maybe its the set variable trigger?
 

Exide

I am amazingly focused right now!
Reaction score
448
Do it like this:

Trigger:
  • -Trigger Name-
    • Events
      • Unit - A unit enters -Region Name- <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to -PlayerVariable-[(Integer A)]
            • Then - Actions
              • -Actions Here-
            • Else - Actions
 

unknown666

New Member
Reaction score
5
Trigger:
  • Events
    • Unit - A unit enters House1
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (Owner of HousePermissionHouse1[(Integer A)]
            • Then - Actions
              • Unit - Move (Triggering unit) instantly to (Center of houseEnter <gen>)
            • Else - Actions

I changed it but it still doesn't seem to work... maybe I could attach the map so you could maybe find out why?
 

Exide

I am amazingly focused right now!
Reaction score
448
Ok, attach the map. :p
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I think the problem is in the very start of the map initialization:

Code:
HeroPlayer
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is A Hero) Equal to True
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Owner of (Picked unit)) Equal to Player 1 (Red)
                            Then - Actions
                                Set HeroPlayer[1] = (Picked unit)
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Owner of (Picked unit)) Equal to Player 2 (Blue)
                                    Then - Actions
                                        Set HeroPlayer[2] = (Picked unit)
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                (Owner of (Picked unit)) Equal to Player 3 (Teal)
                                            Then - Actions
                                                Set HeroPlayer[3] = (Picked unit)
                                            Else - Actions
                                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    If - Conditions
                                                        (Owner of (Picked unit)) Equal to Player 4 (Purple)
                                                    Then - Actions
                                                        Set HeroPlayer[4] = (Picked unit)
                                                    Else - Actions
                                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                            If - Conditions
                                                                (Owner of (Picked unit)) Equal to Player 5 (Yellow)
                                                            Then - Actions
                                                                Set HeroPlayer[5] = (Picked unit)
                                                            Else - Actions
                                                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                    If - Conditions
                                                                        (Owner of (Picked unit)) Equal to Player 6 (Orange)
                                                                    Then - Actions
                                                                        Set HeroPlayer[6] = (Picked unit)
                                                                    Else - Actions
                                                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                            If - Conditions
                                                                                (Owner of (Picked unit)) Equal to Player 7 (Green)
                                                                            Then - Actions
                                                                                Set HeroPlayer[7] = (Picked unit)
                                                                            Else - Actions
                                                                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                    If - Conditions
                                                                                        (Owner of (Picked unit)) Equal to Player 8 (Pink)
                                                                                    Then - Actions
                                                                                        Set HeroPlayer[8] = (Picked unit)
                                                                                    Else - Actions
                                                                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                            If - Conditions
                                                                                                (Owner of (Picked unit)) Equal to Player 9 (Gray)
                                                                                            Then - Actions
                                                                                                Set HeroPlayer[9] = (Picked unit)
                                                                                            Else - Actions
                                                                                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                                                    If - Conditions
                                                                                                        (Owner of (Picked unit)) Equal to Player 10 (Light Blue)
                                                                                                    Then - Actions
                                                                                                        Set HeroPlayer[10] = (Picked unit)
                                                                                                    Else - Actions
                                                                                                        Do nothing
                    Else - Actions
                        Do nothing

are you sure it picks and stores the units properly in each of variable arrays?

there is an easier way though.... set each player owned unit into unit array variable and do this:

Code:
HeroPlayer Copy
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Set HeroPlayer[(Integer A)] = (stored_units[Integer A])
 

unknown666

New Member
Reaction score
5
I think so, cause I also used it to be in the car seller region, and it works properly there
 

Exide

I am amazingly focused right now!
Reaction score
448
Here's a suggestion: (Not a very good one, though, but it ought to work.)

First create 1 Boolean Type variable with array for each player. (10, I believe.)
Named: Permission1, Permission2, ..., Permission10.

Then change your permission triggers to:
Trigger:
  • give permission Copy 2
    • Events
      • Player - (Owner of Circle of Power 0027 <gen>) types a chat message containing -grant blue as An exact match
    • Conditions
    • Actions
      • Set Permission1[2] = True

-Which means Permission to house 1 is True for Player 2.

Then change your enter triggers:
Trigger:
  • house enter
    • Events
      • Unit - A unit enters House1 <gen>
    • Conditions
      • Permission1[(Player number of (Owner of (Triggering unit)))] Equal to True
    • Actions
      • Unit - Move (Triggering unit) instantly to (Center of HouseEnter <gen>)


-Should work, haven't tried it. :p

EDIT: Ps. The last trigger leaks a point.
 

unknown666

New Member
Reaction score
5
How do I need to create a boolean for a player.. the best I could come up with is

Trigger:
  • -Trigger-
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Permission 1[1] = (Player 1 (Red) is in Player Group - Player 1 (Red))
 

Exide

I am amazingly focused right now!
Reaction score
448
Open the Trigger Editor (F4) -> press Ctrl+B -> Ctrl+N -> The second field from above; Variable Type: -> Choose Boolean. Check the box saying Array -> click 'Ok'.
 

unknown666

New Member
Reaction score
5
noo... I know how to create a boolean variable but how to set a boolean variable to ie. player1 (red)?
 

Beetlebomb

New Member
Reaction score
43
Make it an array.

Boolean[*enter number here*]

To set a boolen to each player then do.

Pick every play in (all players) and do
loop
set boolean(Player number of(Trigger player) = true or false, whichever you want.


Then whenever you call that trigger, just refer the array to whatever player number it is.

Good luck! If you need more help, Just let me know and I"ll look through all the past posts al ittle more thoroughly.
 

unknown666

New Member
Reaction score
5
thanks for your help and time ;) +rep for Beetlebomb, Exide & Dinowc

EDIT:::

Darn it still doesn't work current trigger:

variable set:
Trigger:
  • Events
    • Player - (Owner of Circle of Power 0027 <gen>) types a chat message containing -grant player 2 as An exact match
    • Conditions
    • Actions
    • Set Permission1[2] = True


enter trigger:
Trigger:
  • Events
    • Unit - A unit enters House1 <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Permission1[(Player number of (owner of (Triggering unit)))] Equal to True
            • Then - ACtions
              • Unit - Move (Triggering unit) instantly to (Center of HouseEnter <gen>)
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: no permission
 

Beetlebomb

New Member
Reaction score
43
Ok, i see the problem.

Permission1[Integer A]. The reason why you're making it a 1 to 12 loop is so that you can supstitute the numbers for ur variable, I presume. So that means adding in the number (Number being Integer A in this case).

So change just that part, in the IF conditions. Let me know if it works.

Permission1[1] Should be player Reds thing, 2 being blue, 3 being teal, etc etc etc.

An easy way to trigger set this is to put it at the beginning of your map and do a loop form 1 to 12 and do Set Permission[Integer A(or B(depending on which u chose as ur loop))] = True(or false, if u want)

Good Luck!

Beetlebomb
 

unknown666

New Member
Reaction score
5
Still doesn't work.. if I use integer A every unit is still allowed to go in... so that doesn't change anything. :(
 
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