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

More Efficient Way of Setting Playing Colors

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
The Idea is that the player will always receive their correct player color (they are allowed to pick in the lobby) this is how its done right now

is there a way to make it go thru the players and set their color as the one they picked in lobby without having to write it out that long way

  • Set The Strings Variables
    • Events
    • Conditions
    • Actions
      • -------- Colors Array --------
      • Set colorcode[1] = |cffff0000
      • Set colorcode[2] = |cff0000ff
      • Set colorcode[3] = |cff00ffff
      • Set colorcode[4] = |cffa020f0
      • Set colorcode[5] = |cffffff00
      • Set colorcode[6] = |cffee9a00
      • Set colorcode[7] = |cff00cd00
      • Set colorcode[8] = |cffdb7093
      • Set colorcode[9] = |cff7f7f7f
      • Set colorcode[10] = |cff87ceeb
      • Set colorcode[11] = |cff006400
      • Set colorcode[12] = |cff804000
      • 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
              • (Color of (Player((Integer A)))) Equal to Red
            • Then - Actions
              • Set colorrealpercent1[(Integer A)] = 100.00
              • Set colorrealpercent2[(Integer A)] = 0.00
              • Set colorrealpercent3[(Integer A)] = 0.00
              • Set colorcodeplayer[(Integer A)] = |cffff0000
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Color of (Player((Integer A)))) Equal to Blue
                • Then - Actions
                  • Set colorrealpercent1[(Integer A)] = 0.00
                  • Set colorrealpercent2[(Integer A)] = 0.00
                  • Set colorrealpercent3[(Integer A)] = 100.00
                  • Set colorcodeplayer[(Integer A)] = |cff0000ff
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Color of (Player((Integer A)))) Equal to Teal
                    • Then - Actions
                      • Set colorrealpercent1[(Integer A)] = 0.00
                      • Set colorrealpercent2[(Integer A)] = 100.00
                      • Set colorrealpercent3[(Integer A)] = 100.00
                      • Set colorcodeplayer[(Integer A)] = |cff00ffff
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Color of (Player((Integer A)))) Equal to Purple
                        • Then - Actions
                          • Set colorrealpercent1[(Integer A)] = 60.00
                          • Set colorrealpercent2[(Integer A)] = 0.00
                          • Set colorrealpercent3[(Integer A)] = 60.00
                          • Set colorcodeplayer[(Integer A)] = |cffa020f0
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Color of (Player((Integer A)))) Equal to Yellow
                            • Then - Actions
                              • Set colorrealpercent1[(Integer A)] = 100.00
                              • Set colorrealpercent2[(Integer A)] = 100.00
                              • Set colorrealpercent3[(Integer A)] = 0.00
                              • Set colorcodeplayer[(Integer A)] = |cffffff00
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Color of (Player((Integer A)))) Equal to Orange
                                • Then - Actions
                                  • Set colorrealpercent1[(Integer A)] = 100.00
                                  • Set colorrealpercent2[(Integer A)] = 50.00
                                  • Set colorrealpercent3[(Integer A)] = 0.00
                                  • Set colorcodeplayer[(Integer A)] = |cffee9a00
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Color of (Player((Integer A)))) Equal to Green
                                    • Then - Actions
                                      • Set colorrealpercent1[(Integer A)] = 0.00
                                      • Set colorrealpercent2[(Integer A)] = 100.00
                                      • Set colorrealpercent3[(Integer A)] = 0.00
                                      • Set colorcodeplayer[(Integer A)] = |cff00cd00
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Color of (Player((Integer A)))) Equal to Pink
                                        • Then - Actions
                                          • Set colorrealpercent1[(Integer A)] = 100.00
                                          • Set colorrealpercent2[(Integer A)] = 50.00
                                          • Set colorrealpercent3[(Integer A)] = 50.00
                                          • Set colorcodeplayer[(Integer A)] = |cffdb7093
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Color of (Player((Integer A)))) Equal to Gray
                                            • Then - Actions
                                              • Set colorcodeplayer[(Integer A)] = |cff7f7f7f
                                              • Set colorrealpercent1[(Integer A)] = 50.00
                                              • Set colorrealpercent2[(Integer A)] = 50.00
                                              • Set colorrealpercent3[(Integer A)] = 50.00
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Color of (Player((Integer A)))) Equal to Light Blue
                                                • Then - Actions
                                                  • Set colorrealpercent1[(Integer A)] = 50.00
                                                  • Set colorrealpercent2[(Integer A)] = 50.00
                                                  • Set colorrealpercent3[(Integer A)] = 100.00
                                                  • Set colorcodeplayer[(Integer A)] = |cff87ceeb
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Color of (Player((Integer A)))) Equal to Dark Green
                                                    • Then - Actions
                                                      • Set colorrealpercent1[(Integer A)] = 0.00
                                                      • Set colorrealpercent2[(Integer A)] = 50.00
                                                      • Set colorrealpercent3[(Integer A)] = 0.00
                                                      • Set colorcodeplayer[(Integer A)] = |cff006400
                                                    • Else - Actions
                                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                        • If - Conditions
                                                          • (Color of (Player((Integer A)))) Equal to Brown
                                                        • Then - Actions
                                                          • Set colorrealpercent1[(Integer A)] = 50.00
                                                          • Set colorrealpercent2[(Integer A)] = 0.00
                                                          • Set colorrealpercent3[(Integer A)] = 0.00
                                                          • Set colorcodeplayer[(Integer A)] = |cff804000
                                                        • Else - Actions
      • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
You could try to set it into Player Color array before hand and then just call the array index.
  • Actions
    • Set Player_Color[1] = Red
    • Set Player_Color[2] = Blue
    • Set Player_Color[3] = Teal
    • etc.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Color of Player[(Integer A)]) Equal to Player_Color[(Integer B)]
    • Then - Actions
    • Else - Actions
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Then you also need an array with the presets of the colors...
I dont think that there is a solution that reduces code a lot.
There is a solution (which Nichilus meant) that reduces the loop to 6 lines but you have to add 12*5 (4 because you already have one) at the top that sets data.
Player_Color[1] = red
Player_Color_String[1] = |cffff0000
Player_Color_Percent_R[1] = 100
Player_Color_Percent_G[1] = 0
Player_Color_Percent_B[1] = 0
Player_Color[2] = blue (etc etc etc)

Loop A from 1 to 12:
Loop B from 1 to 12:
if player color(A) is equal to Player_Color
then Set colorcodeplayer[A] = Player_Color_String
Set colorrealpercent1[A] = Player_Color_Percent_R
Set colorrealpercent2[A] = Player_Color_Percent_G
Set colorrealpercent3[A] = Player_Color_Percent_B

Thats it... but it wont reduce code a lot. It will look cleaner though.
 
Level 6
Joined
Feb 10, 2011
Messages
188
You guys sure??? Im like 90 percent positive there is a better way to do it, I feel i seen it before (but that was a year and a half ago)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
It could be possible that you only saw the loop which is exacly as I posted. (Only 6 lines of code.)

As far as I know, there is no option to convert a player color to a string or RGB code so you have to check them anyway.
You could make a function that converts "|cffff0000" to 100/0/0 (or the other way around) which would reduce code and be more easy to use... but then you are making performance worse.
 
Status
Not open for further replies.
Top