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

[Trigger] Playing with Multiboards

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2021
Messages
89
Greetings people of the Hive Community!

Once again i have found myself in need of your help, i am as many others making a map, where i would like a multiboard, or something that does the same atleast, to show "players" and 3 different currencies (currencies are based on variables so it should be easy enough to get those to show, but i have made this and i feel like its made very poorly, but alas it is my first ever multiboard :)

My Questions:
1. Does any of this leak if i change the values in the multiboard ? (Updating "currencies?")
2. I tried "checking" for computer players and kind of overwrite it if anything but a user comes up?
3. Any ideas for improvement?

  • Window
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Multiboard - Create a multiboard with 4 columns and (NumberOfPlayers + 1) rows, titled Titel Melodi.
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Heroes
      • Multiboard - Set the text for (Last created multiboard) item in column 2, row 1 to Gold
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 1 to Silver
      • Multiboard - Set the text for (Last created multiboard) item in column 4, row 1 to Copper
      • For each (Integer MultiboardInteger1) from 1 to (NumberOfPlayers + 1), do (Actions)
        • Loop - Actions
          • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
          • Multiboard - Set the display style for (Last created multiboard) item in column 1, row MultiboardInteger1 to Show text and Hide icons
          • Multiboard - Set the display style for (Last created multiboard) item in column 2, row MultiboardInteger1 to Show text and Hide icons
          • Multiboard - Set the display style for (Last created multiboard) item in column 3, row MultiboardInteger1 to Show text and Hide icons
          • Multiboard - Set the display style for (Last created multiboard) item in column 4, row MultiboardInteger1 to Show text and Hide icons
          • Multiboard - Set the width for (Last created multiboard) item in column 1, row MultiboardInteger1 to 8.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 2, row MultiboardInteger1 to 5.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 3, row MultiboardInteger1 to 5.00% of the total screen width
          • Multiboard - Set the width for (Last created multiboard) item in column 4, row MultiboardInteger1 to 5.00% of the total screen width
      • For each (Integer MultiboardInteger2) from 2 to (NumberOfPlayers + 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(MultiboardInteger2)) controller) Equal to User
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((MultiboardInteger2 - 1))) controller) Not equal to User
                • Then - Actions
                  • Multiboard - Set the text for (Last created multiboard) item in column 1, row (MultiboardInteger2 - 1) to (Name of (Player(MultiboardInteger2)))
                  • Set VariableSet MultiboardInteger2 = (MultiboardInteger2 - 1)
                • Else - Actions
                  • Multiboard - Set the text for (Last created multiboard) item in column 1, row MultiboardInteger2 to (Name of (Player(MultiboardInteger2)))
            • Else - Actions
      • Multiboard - Show (Last created multiboard)
 
Level 19
Joined
Feb 27, 2019
Messages
582
2,3:

Set (Last created multiboard) to a variable and use that to reference the multiboard instead of using GetLastCreatedMultiboard() each time.

Youll need a simple system to remember the position of each player in the mutliboard when its time to update the multiboard. What about.

Set List = 1
---
For each MultiboardInteger2 from 1 to NumberOfPlayers do
If
(Player(MultiboardInteger2)) controller) Equal to User
then
Set List = List + 1
Set ListPos(MultiboardInteger2) = List
Multiboard - Set the text for Multiboard item in column 1, row ListPos(MultiboardInteger2) to (Name of (Player(MultiboardInteger2)))
Add Player(MultiboardInteger2) to PlayingPlayers
else
endif
---
 
Level 5
Joined
Feb 5, 2021
Messages
89
2,3:

Set (Last created multiboard) to a variable and use that to reference the multiboard instead of using GetLastCreatedMultiboard() each time.

Youll need a simple system to remember the position of each player in the mutliboard when its time to update the multiboard. What about.

Set List = 1
---
For each MultiboardInteger2 from 1 to NumberOfPlayers do
If
(Player(MultiboardInteger2)) controller) Equal to User
then
Set List = List + 1
Set ListPos(MultiboardInteger2) = List
Multiboard - Set the text for Multiboard item in column 1, row ListPos(MultiboardInteger2) to (Name of (Player(MultiboardInteger2)))
Add Player(MultiboardInteger2) to PlayingPlayers
else
endif
---

This seems pretty good, sadly i am unable to fully comprehend what i am supposed to do? :)

Im guessing
List = Integer Variable?
ListPos = Is this another integer variable?
Add Player to "PlayingPlayers" = Player Group Variable?
 
Level 19
Joined
Feb 27, 2019
Messages
582
I was thinking you can replace:
  • For each (Integer MultiboardInteger2) from 2 to (NumberOfPlayers + 1), do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((MultiboardInteger2 - 1))) controller) Not equal to User
            • Then - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row (MultiboardInteger2 - 1) to (Name of (Player(MultiboardInteger2)))
              • Set VariableSet MultiboardInteger2 = (MultiboardInteger2 - 1)
            • Else - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row MultiboardInteger2 to (Name of (Player(MultiboardInteger2)))
        • Else - Actions
With this:
  • Set VariableSet List = 1
  • For each (Integer MultiboardInteger2) from 1 to NumberOfPlayers, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • Set VariableSet List = (List + 1)
          • Set VariableSet ListPos[MultiboardInteger2] = List
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row List to (Name of (Player(MultiboardInteger2)))
          • Player Group - Add (Player(MultiboardInteger2)) to PlayingPlayers
        • Else - Actions
Then you can use the PlayerGroup and ListPos() when updating the multiboard
  • Update Multiboard
    • Events
      • Time - Every 1.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in PlayingPlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet Int = (Player number of (Picked player))
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row ListPos[Int] to (String(((Player(Int)) Current gold)))
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
I was thinking you can replace:
  • For each (Integer MultiboardInteger2) from 2 to (NumberOfPlayers + 1), do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((MultiboardInteger2 - 1))) controller) Not equal to User
            • Then - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row (MultiboardInteger2 - 1) to (Name of (Player(MultiboardInteger2)))
              • Set VariableSet MultiboardInteger2 = (MultiboardInteger2 - 1)
            • Else - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row MultiboardInteger2 to (Name of (Player(MultiboardInteger2)))
        • Else - Actions
With this:
  • Set VariableSet List = 1
  • For each (Integer MultiboardInteger2) from 1 to NumberOfPlayers, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • Set VariableSet List = (List + 1)
          • Set VariableSet ListPos[MultiboardInteger2] = List
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row List to (Name of (Player(MultiboardInteger2)))
          • Player Group - Add (Player(MultiboardInteger2)) to PlayingPlayers
        • Else - Actions
Then you can use the PlayerGroup and ListPos() when updating the multiboard
  • Update Multiboard
    • Events
      • Time - Every 1.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in PlayingPlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet Int = (Player number of (Picked player))
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row ListPos[Int] to (String(((Player(Int)) Current gold)))
Thank you very much! this is incredibly helpful, i feel enlightened and i will try to dabble with this as soon as i get the opportunity :)
 
Level 5
Joined
Feb 5, 2021
Messages
89
I was thinking you can replace:
  • For each (Integer MultiboardInteger2) from 2 to (NumberOfPlayers + 1), do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((MultiboardInteger2 - 1))) controller) Not equal to User
            • Then - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row (MultiboardInteger2 - 1) to (Name of (Player(MultiboardInteger2)))
              • Set VariableSet MultiboardInteger2 = (MultiboardInteger2 - 1)
            • Else - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row MultiboardInteger2 to (Name of (Player(MultiboardInteger2)))
        • Else - Actions
With this:
  • Set VariableSet List = 1
  • For each (Integer MultiboardInteger2) from 1 to NumberOfPlayers, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(MultiboardInteger2)) controller) Equal to User
        • Then - Actions
          • Set VariableSet List = (List + 1)
          • Set VariableSet ListPos[MultiboardInteger2] = List
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row List to (Name of (Player(MultiboardInteger2)))
          • Player Group - Add (Player(MultiboardInteger2)) to PlayingPlayers
        • Else - Actions
Then you can use the PlayerGroup and ListPos() when updating the multiboard
  • Update Multiboard
    • Events
      • Time - Every 1.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in PlayingPlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet Int = (Player number of (Picked player))
          • Multiboard - Set the text for (Last created multiboard) item in column 2, row ListPos[Int] to (String(((Player(Int)) Current gold)))
Update: Worked like a charm, just thought you should know! much obliged!
 
Level 19
Joined
Feb 27, 2019
Messages
582
Good to hear! I thought Id add another thing now that you got that in order.
  • ((Player(MultiboardInteger2)) controller) Equal to User
This condition checks if the player is a user and not if they are playing or have left the game. If you dont want to show players who are not playing anymore you should add an and condition that checks if the player is playing and destroy and recreate the multiboard when a player leaves. You could also grey out their name, add Left: to their name or something like that.

Dont forget to set the multiboard to a variable if you havnt done that. I try to avoid using repeat call functions if possible since it adds extra steps for the game to handle.

1: I am unsure and would also like to know about a couple of things that relate to your first question.
Does using this action create a leak?
Conversion - Convert Player Index To Player
  • Player - Set (Player(1)).Current gold to 750
Should one set strings to variables and destroy them after displaying something on a multiboard or game message to remove leaks? Does the text in the multiboard or game messages leak at all?
 
Level 5
Joined
Feb 5, 2021
Messages
89
Good to hear! I thought Id add another thing now that you got that in order.
  • ((Player(MultiboardInteger2)) controller) Equal to User
This condition checks if the player is a user and not if they are playing or have left the game. If you dont want to show players who are not playing anymore you should add an and condition that checks if the player is playing and destroy and recreate the multiboard when a player leaves. You could also grey out their name, add Left: to their name or something like that.

Dont forget to set the multiboard to a variable if you havnt done that. I try to avoid using repeat call functions if possible since it adds extra steps for the game to handle.

1: I am unsure and would also like to know about a couple of things that relate to your first question.
Does using this action create a leak?
Conversion - Convert Player Index To Player
  • Player - Set (Player(1)).Current gold to 750
Should one set strings to variables and destroy them after displaying something on a multiboard or game message to remove leaks? Does the text in the multiboard or game messages leak at all?
I thought about adding something like that aswell and might experiment with it in the future but for now om happy with it and can move on with other sides of it :)

If it leaks or not i still have No idea, and i am unsure of how i would check it i am guessing that it does not leak, also the currencies i am updating are all integer variables which i believe in itself does not leak :)

This is as good an answer i can come up with, with my current knowledge :)
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
Does using this action create a leak?
Conversion - Convert Player Index To Player
No. Players are constant handles; it's impossible to 'leak' a player. A player index is an integer.
Should one set strings to variables and destroy them
No. Strings, while not really the same as the other primitive types, behave as though they are. They are definitively not handles.

 
Status
Not open for further replies.
Top