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 The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!

      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