• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Muliboard multiple local multiboards

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
which method is more appropriate, Every player has a local leaderboard. Shall I destroy it and create a new one or just completly redo it's layout? (Some values are the same thought..)

This:
  • Custom script: call DestroyMultiboardBJ( udg_Multiboard[i] )
  • Custom script: set udg_Multiboard[i] = CreateMultiboardBJ(5,5, "Hello World!")
or this:
  • Multiboard - Clear (Multiboard[i])
  • Wait 0.00 seconds
  • Multiboard - Change the number of rows for (Multiboard[i]) to 5
  • Multiboard - Change the number of columns for (Multiboard[i]) to 5
  • Multiboard - Change the title of (Multiboard[i]) to Hello World!
My intuiton says the above so I'm sticking with it until someone says otherwise.

Here is the whole thing in it's current ugly state. And for some reason under the headline "-------- Enemy Town Revealed --------" the "if (udg_Town_revealed == true) then" can never return true? even though the variable is set so..?

The whole trigger can be seen below.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Edit: after reconsidering, yeah: just destroy and re-create the multiboard.
Anyway, if Town_revealed were indeed true, then the message would show. Therefore, it must be false somehow.

Also, why so many custom scripts? They're the exact same lines GUI uses. If you want the benefit of JASS, use the natives. Or use GUI.
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
Edit: after reconsidering, yeah: just destroy and re-create the multiboard.
Anyway, if Town_revealed were indeed true, then the message would show. Therefore, it must be false somehow.

Also, why so many custom scripts? They're the exact same lines GUI uses. If you want the benefit of JASS, use the natives. Or use GUI.


it was faster to copy and paste! ;) And I feel it is faster to copy-paste and write from there then use the interference even though the functionality is the same as GUI. (Someone should make a gui/customscript hybrid where you can write customscripts in the actionsm, it would be a option above value!:D)

I will be sticking to what I'm doing for now because after installing jngp I was litterly clueless... With this I atleast have some familiarity and I find working on this map more rewarding then smashing my head against a wall befor I can even start working. Perhaps I will regret it later but thats the way I feel right now.

as for the variable it is indeed set to true, here is the temporary spy trigger:
  • Spy on Grunt Town
    • Events
      • Player - Player 1 (Red) types a chat message containing spy as An exact match
      • Player - Player 2 (Blue) types a chat message containing spy as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Town_revealed[(Custom value of Great Hall 0003 <gen>)] Equal to False
        • Then - Actions
          • Set Town_revealed[(Custom value of Great Hall 0003 <gen>)] = True
          • Game - Display to (All players) the text: TRUE
        • Else - Actions
          • Set Town_revealed[(Custom value of Great Hall 0003 <gen>)] = False
          • Game - Display to (All players) the text: FALSE
And here is the setup:
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Town[0] = Town Hall 0000 <gen>
      • Set Town[1] = Town Hall 0001 <gen>
      • Set Town[2] = Town Hall 0002 <gen>
      • Set Town[3] = Great Hall 0003 <gen>
      • Set Town[4] = Town Hall 0017 <gen>
      • Set Town_name[0] = Tiagocity
      • Set Town_name[1] = Loapville
      • Set Town_name[2] = Generic Town
      • Set Town_name[3] = Grunt Town!
      • Set Town_name[4] = Another Silly Ally
      • Custom script: loop
      • Custom script: exitwhen udg_Town_i > 4
      • Custom script: call SetUnitUserData(udg_Town[udg_Town_i], udg_Town_i)
      • Custom script: call GroupAddUnitSimple(udg_Town[udg_Town_i], udg_Town_g)
      • Custom script: set udg_Town_i = udg_Town_i + 1
      • Custom script: endloop
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
Town_revealed[3] is set to true. This means that Teal must be the triggering player (Red, blue or anyone else and it will return false).

Tried playing teal same issue sadly, thanks for your effort tho.

In my atemt to fix it I decided to split it up into two functions the issue now is that it keeps repeating in infinity when I click once, what did I do wrong?

JASS:
function Trig_TownSelection_Conditions takes nothing returns boolean
   if (IsUnitInGroup(GetTriggerUnit(), udg_townGroup) == true or IsUnitInGroup(GetTriggerUnit(), udg_campGroup) == true) and GetTriggerUnit() != udg_playerSelectionUnit[GetConvertedPlayerId(GetTriggerPlayer())] and udg_triggerTownSelection_off[GetConvertedPlayerId(GetTriggerPlayer())] == false then
   return true
   endif
endfunction

function RevealedMultiboard takes integer i returns nothing
    call BJDebugMsg("Function: RevealedMultiboard")
endfunction

function HiddenMultiboard takes integer i returns nothing
    call BJDebugMsg("Function: HiddenMultiboard")
endfunction

function Trig_TownSelection_Actions takes nothing returns nothing

  local player p = GetTriggerPlayer()
  local unit u = GetTriggerUnit()
  local integer i = GetPlayerId(p)

    call BJDebugMsg("-------------------------------")

    // Turn OFF trigger for triggering player.
    set udg_triggerTownSelection_off[i] = true

    // Set Current Selection
    call SelectUnitForPlayerSingle(u,p)
    set udg_playerSelectionUnit[i] = u
      
    if IsUnitInGroup(u, udg_townGroup) == true or IsUnitInGroup(u, udg_campGroup) == true then

      if (udg_townRevealed[i] == true or IsPlayerEnemy(p, GetOwningPlayer(u)) != true ) then

        call RevealedMultiboard(i)

      else 

        call HiddenMultiboard(i)

      endif
    endif

  set u = null
  set p = null
  
    // Turn ON trigger again for triggering player.
    call TriggerSleepAction( 0.1 )
    set udg_triggerTownSelection_off[i] = false

    call BJDebugMsg("-------------------------------")

endfunction

//===========================================================================
function InitTrig_TownSelection takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(0), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(1), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(2), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(3), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(4), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(5), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(6), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(7), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(8), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(9), true )
    call TriggerAddCondition(t, Condition( function Trig_TownSelection_Conditions ) )
    call TriggerAddAction(t, function Trig_TownSelection_Actions )
  set t = null
endfunction

The trigger keeps running over and over again with the message

--------------------
Function ...
-------------------

The issue must be in the begining because its supposed to be FALSE so that it doesnt repeat with the SelectUnit action.
JASS:
function Trig_TownSelection_Conditions takes nothing returns boolean
   if (IsUnitInGroup(GetTriggerUnit(), udg_townGroup) == true or IsUnitInGroup(GetTriggerUnit(), udg_campGroup) == true) and GetTriggerUnit() != udg_playerSelectionUnit[GetConvertedPlayerId(GetTriggerPlayer())] and udg_triggerTownSelection_off[GetConvertedPlayerId(GetTriggerPlayer())] == false then
   return true
   endif
endfunction

Additional question, how "bad" is to create functions for readability? :>
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
I have solved this issue, but I'm out of range from my computer so i cannot check what I did. I don't destroy my multiboards, that I know of. You probably get an answer before tomorrow.

You must put multiboards in a local block when referring to only 1 player to show to only 1 play, since multiboards is global by default.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Additional question, how "bad" is to create functions for readability? :>
I guess some people won't like it that much, but I don't have a problem with it. As long as you make it more readable, because:
JASS:
function RevealedMultiboard takes integer i returns nothing
    call BJDebugMsg("Function: RevealedMultiboard")
endfunction

function HiddenMultiboard takes integer i returns nothing
    call BJDebugMsg("Function: HiddenMultiboard")
endfunction

// Inside a function:
    call RevealedMultiboard(i)
    call HiddenMultiboard(i)
// Endfunction
doesn't make anything more readable, it just adds useless lines of code.
I guess you're going to add stuff (because it takes an integer i which isn't used at the moment), but it doesn't look like it's going to actually be useful/more readable.

what did I do wrong?
JASS:
// Action:
call SelectUnitForPlayerSingle(u,p)

// Event:
call TriggerRegisterPlayerSelectionEventBJ(t, Player(0), true )
Unit is selected --> Actions run --> Events run --> Actions run --> (to infinity).
The problem is that I have no idea what you're trying to do, so I can only tell you what's wrong, not how you're supposed to do it.

TKF said:
You must put multiboards in a local block when referring to only 1 player to show to only 1 play, since multiboards is global by default.
Doesn't he do this already?
  • Custom script: call MultiboardDisplayBJ( false, udg_Multiboard[i] )
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
  • Custom script: call MultiboardDisplayBJ( true, udg_Multiboard[i] )
  • Custom script: endif
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
Okay I'll explain.

There are two groups Towns and camps. if you select it a multiboard with that perticular units information is revealed to the player. You can only have one of these units selected at a time.

So basically there are 4 types of multiboards that can be created.
1) All information (for friendly towns)
2) Most information (friendly camps and revealed enemy camps/towns)
3) Most information (for enemy town/camps)
4) No information (has never been revealed, displays hint)

Multiboard Information:

This can only be revealed if enemy has scouted the building, or if its a friendly Town/Camp
Stock:
Gold
Lumber
Iron

This can only be revealed if enemy has scouted the building, or if its a friendly Town. (Camps can't produce material.)
Local Production:
Gold
Lumer
Iron
Recruits
Food
Weapons

This can only be revealed if a friendly is clicking the building, you cant scout this.
Player Resources:
Gold
Lumber
Iron
Recruits
Food
Weapons


JASS:
function Trig_TownSelection_Conditions takes nothing returns boolean
  local integer pID = GetPlayerId(GetTriggerPlayer())
    if  GetTriggerUnit() != udg_playerSelectedBase[pID] and udg_triggerTownSelection_off[pID] == false and (IsUnitInGroup(GetTriggerUnit(), udg_townGroup) == true or IsUnitInGroup(GetTriggerUnit(), udg_campGroup) == true) then
      return true
    endif
endfunction


function Trig_TownSelection_Actions takes nothing returns nothing

  local player p         = GetTriggerPlayer()
  local unit u           = GetTriggerUnit()
  local integer pID      = GetPlayerId(p)
  local integer pID2     = GetPlayerId(GetOwningPlayer(u))
  local integer uID      = GetUnitUserData(u)
  local integer rows
  local integer columns

      // Turn OFF trigger for triggering player.
    set udg_triggerTownSelection_off[pID] = true

      // Set Current Selection
    call SelectUnitForPlayerSingle(u,p)
    set udg_playerSelectedBase[pID] = u

      // Clear Old Multiboard

    call MultiboardMinimizeBJ( false, udg_multiboard[pID] )
    call MultiboardClear( udg_multiboard[pID] )
    call TriggerSleepAction( 0.0 )

        // Set name to Unit Name or townName[uID]
      if IsUnitInGroup(u, udg_townGroup) == true and IsUnitInGroup(u, udg_campGroup) != true then
            call MultiboardSetTitleText( udg_multiboard[pID], udg_townName[uID])
          else
            call MultiboardSetTitleText( udg_multiboard[pID], GetUnitName(u))
      endif

      call MultiboardSetRowCount    ( udg_multiboard[pID], 22    )
      call MultiboardSetColumnCount ( udg_multiboard[pID], 5     )
      call MultiboardSetItemStyleBJ( udg_multiboard[pID], 0, 0, true, false)

      if (udg_baseRevealed[uID] == true or IsPlayerEnemy(p, GetOwningPlayer(u)) != true) then
            
            //Reveal Stock iformation
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 1, "Stock"     )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 2, "Recruits:" )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 3, "Food:"     )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 4, "Weapons:"  )
            // Something Wrong with these lines!
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 2, (I2S(udg_baseResourceRecruits [uID]) +  " / " + I2S(udg_baseResourceRecruits [uID + 1000]))) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 3, (I2S(udg_baseResourceFood     [uID]) +  " / " + I2S(udg_baseResourceFood     [uID + 1000])))
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 4, (I2S(udg_baseResourceWeapons  [uID]) +  " / " + I2S(udg_baseResourceWeapons  [uID + 1000])))
            set rows    = 4  
            set columns = 2

        else


          if udg_baseRevealedPreviously[uID] == true then

                //Reveal Old Stock information
              // Stuff...
            else

                //Reveal Hint
              call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 2, "No information avalible."         )
              call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 3, "Use a Spy to reveal information." )
              call MultiboardSetItemWidthBJ( udg_multiboard[pID], 1, 0, 13.00 )
                set rows    = 4
                set columns = 1

          endif

      endif 
      
      if (udg_baseRevealed[uID] == true or IsPlayerEnemy(p, GetOwningPlayer(u)) != true) and IsUnitInGroup(u, udg_townGroup) == true then
         
            // Reveal production information if the unit is townGroup.
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 6 ,  "Production" )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 7 ,  "Gold:"      )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 8 ,  "Lumber:"    )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 9 ,  "Iron:"      )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 10,  "Recruits:"  )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 11,  "Food:"      )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 12,  "Weapons:"   )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 7 , I2S(udg_baseResourceGold     [uID + 2000])) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 8 , I2S(udg_baseResourceLumber   [uID + 2000])) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 9 , I2S(udg_baseResourceIron     [uID + 2000])) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 10, I2S(udg_baseResourceRecruits [uID + 2000])) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 11, I2S(udg_baseResourceFood     [uID + 2000])) 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, 12, I2S(udg_baseResourceWeapons  [uID + 2000]))
          call MultiboardSetItemWidthBJ( udg_multiboard[pID], 1, 0, 6.00 )
          call MultiboardSetItemWidthBJ( udg_multiboard[pID], 2, 0, 6.00 )
            set rows    = 12
 
        else

          if IsUnitInGroup(u, udg_townGroup) == true and  udg_baseRevealedPreviously[uID] == true then
                //Reveal Old Production information.
              // Stuff...
          endif

      endif

      if IsPlayerEnemy(p, GetOwningPlayer(u)) != true then

            // Show Player resources to friendly players.
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 2 , GetPlayerName(GetOwningPlayer(u)) + " Resources" )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 3 , "Gold:"            )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 4 , "Lumber:"          )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 5 , "Iron:"            )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 6 , "Recruits:"        )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 7 , "Food:"            )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, rows + 8 , "Weapons:"         )
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 3, I2S(udg_playerResources[pID2     ]))  // Gold 
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 4, I2S(udg_playerResources[pID2 + 15]))  // Lumber
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 5, I2S(udg_playerResources[pID2 + 30]))  // Iron
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 6, I2S(udg_playerResources[pID2 + 45]))  // Recruits
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 7, I2S(udg_playerResources[pID2 + 60]))  // Food
          call MultiboardSetItemValueBJ( udg_multiboard[pID], 2, rows + 8, I2S(udg_playerResources[pID2 + 75]))  // Weapons
          call MultiboardSetItemWidthBJ( udg_multiboard[pID], 1, 0, 6.00 )
          call MultiboardSetItemWidthBJ( udg_multiboard[pID], 2, 0, 6.00 )
            set rows = rows + 8
      endif

        // Adjust the multiboard and show it to local player
      call MultiboardSetRowCount    ( udg_multiboard[pID], rows    )
      call MultiboardSetColumnCount ( udg_multiboard[pID], columns )

      if GetLocalPlayer() == p then
        call MultiboardDisplay(udg_multiboard[pID], true)
      endif

        // Return the min/max state of the multiboard to player choice
      if udg_multiboardMinimized[pID] == true then
        call MultiboardMinimizeBJ(true, udg_multiboard[pID])
          else
            set udg_multiboardMinimized[pID] = false
      endif

  set u = null
  set p = null
  
      // Turn ON trigger again for triggering player.
    set udg_triggerTownSelection_off[pID] = false

endfunction

//===========================================================================
function InitTrig_BaseSelection takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(0), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(1), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(2), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(3), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(4), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(5), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(6), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(7), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(8), true )
    call TriggerRegisterPlayerSelectionEventBJ(t, Player(9), true )
    call TriggerAddCondition(t, Condition( function Trig_TownSelection_Conditions ) )
    call TriggerAddAction(t, function Trig_TownSelection_Actions )
  set t = null
endfunction

Now all that is needed is to fix it running into infinity...
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
JASS:
native MultiboardSetItemsValue          takes multiboard lb, string value returns nothing

I dont understand this, can someone explain how to use this?

this desn't work so much I understand...
JASS:
          call MultiboardSetItemsStyle(udg_Multiboard[pID], 1, 1, "hello!")

Finally stopped it from running into infinity!

How do I refer to these parameters?

JASS:
function test takes integer i, unit u and returns boolean
return true
endfunction

    call TriggerAddCondition(t, Condition( function test(i, u) ) )

*Edit, damn it! One solves a issue only to have the joy ripped away by another issue...
It must be something with how I setup the arrays... because the arrays that have the value [0] are fine. Can someone tell me what I did wrong?


it should be:
1000/1000 (50% correct for red...)
1000/1000 50% correct for red...)
1000/1000 (50% correct for red...)

1000
1000
1000
1000
1000
1000

5000 (100% correct for red...)
5000
5000
5000
5000
5000

Could someone please take a look..? ;(


Edit* The issue was in the variable setup, I had it set to array of 1 when I changed it to 8000 the default value worked. I wonder if i set a variable to array of one but with a trigger change it like this: udg_integer[3] = 5 will it find a value? I guess so. So this must only effect default values.

Guess everything is solved then, apart from the natives oh well...

*Edit 2, Tested it with a friend and it revealed that the multiboard is destroyed when someone else opens theirs... :s fixed.
 

Attachments

  • Error.jpg
    Error.jpg
    442 KB · Views: 89
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
If you want those 4 multiboards, then why not create all 4 of them (for each player) and never destroy them?
Multiboard[0-15] --> "All Information"
Multiboard[16-31] --> "Most Information #1"
Multiboard[32-47] --> "Most Information #2"
Multiboard[48-63] --> "No Information"

Player X opened Multiboard N: show Multiboard[N*16 + X].
(Player X: regular PlayerId. This means that Player 0 is red, Player 1 Blue and so on.
Same goes for the multiboards: they range from 0 to 3).

This seems easier, as you never have to create/destroy anything, you only have to change some values when showing a multiboard.


JASS:
native MultiboardSetItemsValue          takes multiboard lb, string value returns nothing

I dont understand this, can someone explain how to use this?
That function sets all multiboard items in the multiboard to a certain string.
call MultiboardSetItemsValue( Multiboard, "Hello" ) for example, will set all the values in your multiboard to "Hello".

A more useful option is this:
JASS:
call MultiboardSetItemValue( MultiboardGetItem( Multiboard, row, column ), string )
This will set the multiboard item (row, column) to a certain string.
It's basically the same thing as a unit's ability panel; which looks like this:
(0, 0)(0, 1)(0, 2)(0, 3)
(1, 0)(1, 1)(1, 2)(1, 3)
(2, 0)(2, 1)(2, 2)(2, 3)
With multiboards, it doesn't have to end at (2, 3) of course.


Your line: call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 6 , "Production" )
Can be replaced with this: call MultiboardSetItemValue( udg_multiboard[pID], 0, 5 , "Production" )
A way better option than the BJ-counterpart (which unleashes a massive function, just so you have the "fill all columns/rows"-option).


How do I refer to these parameters?

JASS:
function test takes integer i, unit u and returns boolean
return true
endfunction

    call TriggerAddCondition(t, Condition( function test(i, u) ) )
Not with conditions :D.
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
If you want those 4 multiboards, then why not create all 4 of them (for each player) and never destroy them?
Multiboard[0-15] --> "All Information"
Multiboard[16-31] --> "Most Information #1"
Multiboard[32-47] --> "Most Information #2"
Multiboard[48-63] --> "No Information"

Player X opened Multiboard N: show Multiboard[N*16 + X].
(Player X: regular PlayerId. This means that Player 0 is red, Player 1 Blue and so on.
Same goes for the multiboards: they range from 0 to 3).

This seems easier, as you never have to create/destroy anything, you only have to change some values when showing a multiboard.

Hmm did you check the updated trigger? I create one for each player and change the labels. But I suppose even that is running more then needed as i could cut down on the labels with your method and only change the values, dunno if it is worth it though. Also it makes it even more extensive for me to make! :p



That function sets all multiboard items in the multiboard to a certain string.
call MultiboardSetItemsValue( Multiboard, "Hello" ) for example, will set all the values in your multiboard to "Hello".

A more useful option is this:
JASS:
call MultiboardSetItemValue( MultiboardGetItem( Multiboard, row, column ), string )
This will set the multiboard item (row, column) to a certain string.
It's basically the same thing as a unit's ability panel; which looks like this:
(0, 0)(0, 1)(0, 2)(0, 3)
(1, 0)(1, 1)(1, 2)(1, 3)
(2, 0)(2, 1)(2, 2)(2, 3)
With multiboards, it doesn't have to end at (2, 3) of course.


Your line: call MultiboardSetItemValueBJ( udg_multiboard[pID], 1, 6 , "Production" )
Can be replaced with this: call MultiboardSetItemValue( udg_multiboard[pID], 0, 5 , "Production" )
A way better option than the BJ-counterpart (which unleashes a massive function, just so you have the "fill all columns/rows"-option).



Not with conditions :D.

Ever so helpful thank you yet again!


Forgot to ask: I need a global function for updating these damn multiboards...

Could one do it like this...
set udg_temp_pID (ConvertPlayerId(GetTriggerPlayer())
trigger run trigger update UpdateMultiboard

and in that trigger
set local integer pID = udg_temp_pID
// Check for multiboard to update e.t.c..

there will be alot of triggers with update multiboard actions if opened... could I just run this trigger instead or is it more optimal to copy and paste the "update multiboard function" to all the triggers that need it?


Last question why do you even use conditions? when I could just use a if () then in the action instead?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hmm did you check the updated trigger? I create one for each player and change the labels. But I suppose even that is running more then needed as i could cut down on the labels with your method and only change the values, dunno if it is worth it though. Also it makes it even more extensive for me to make! :p
Oh yes, I've seen that you create 1 multiboard per player. I'm talking about 4 mulltiboards per player :D.
I thought it would be easier, as all multiboards have been created at the start that way. You just need to update them (and, of course, show/hide them).
Well, it does make it a bit harder at the start I guess, because you need to redo the damned thing. There's no problem at all if you wish to keep your current method :p.

Forgot to ask: I need a global function for updating these damn multiboards...

Could one do it like this...
set udg_temp_pID (ConvertPlayerId(GetTriggerPlayer())
trigger run trigger update UpdateMultiboard

and in that trigger
set local integer pID = udg_temp_pID
// Check for multiboard to update e.t.c..

there will be alot of triggers with update multiboard actions if opened... could I just run this trigger instead or is it more optimal to copy and paste the "update multiboard function" to all the triggers that need it?
Certainly!
I would recommended using a single core trigger to update all multiboards.
You may have different triggers with different events (like "Selects Unit", or something), but they can all run the same trigger.
That trigger will then parse the data (like "Oh, he clicked a unit --> Do stuff #1") and keeps the player number in mind.


Last question why do you even use conditions? when I could just use a if () then in the action instead?
Most people actually don't use actions :p.
They put all actions within the condition-block and make it always return false.

Here's an example:
JASS:
function DoStuff takes nothing returns boolean
    if GetTriggerUnit() != newUnit then
        set newUnit = CreateUnit( Player(0), 'hfoo', 0., 0., 0. )
        call BJDebugMsg( "Do Stuff" )
    endif
    
    return false
endfunction

function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterEnterRegion( t, Region, Condition( function DoStuff ) )
    
    set t = null
endfunction

The boolexpr in the event counts as a condition, but there's no real "actions"-block anymore (it's all been moved to the conditions-block).
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
Most people actually don't use actions :p.
They put all actions within the condition-block and make it always return false.

Here's an example:
JASS:
function DoStuff takes nothing returns boolean
    if GetTriggerUnit() != newUnit then
        set newUnit = CreateUnit( Player(0), 'hfoo', 0., 0., 0. )
        call BJDebugMsg( "Do Stuff" )
    endif
    
    return false
endfunction

function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterEnterRegion( t, Region, Condition( function DoStuff ) )
    
    set t = null
endfunction

The boolexpr in the event counts as a condition, but there's no real "actions"-block anymore (it's all been moved to the conditions-block).

Mind blown, but why? Some explanation is required! Because it can be a event and action in the same line?

Tried one myself and didnt get it to work, typicall!

JASS:
function hello takes nothing returns boolean
    if GetTriggerPlayer() == Player(0) then
      call BJDebugMsg("Sorry Red can't test this!")
       else
        call BJDebugMsg("This message is only for privileged people!")
    endif

return false
endfunction

function init takes nothing returns nothing 

  local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t, Player(0), "test", true,  condition (function hello ))
  set t = null
endfunction
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Mind blown, but why? Some explanation is required! Because it can be a event and action in the same line?

Tried one myself and didnt get it to work, typicall!

JASS:
function hello takes nothing returns boolean
    if GetTriggerPlayer() == Player(0) then
      call BJDebugMsg("Sorry Red can't test this!")
       else
        call BJDebugMsg("This message is only for privileged people!")
    endif

return false
endfunction

function init takes nothing returns nothing 

  local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t, Player(0), "test", true,  condition (function hello ))
  set t = null
endfunction
Good question, I don't really know. Maybe because it's faster to type? Maybe because that way it doesn't have any action/condition references and is therefore faster?
Could be all of those, but could also be none of those. I just know that some people do it like that :p.

"Condition" is with a capital C ;).
It's a native that links to a condition.
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
This is the current update trigger, the problem with it is that there is calls for stuff that might not have changed... Also I would have to create a separate trigger for other multiboard updates, for instance when the town goes from being revealed by a spy and unrevealed. Or when a town dies, e.t.c. In a perfect world the perhaps the create board and update would be in one and the same trigger.

JASS:
function UpdateMultiboard takes nothing returns nothing


  local integer pID      = udg_transferredData_pID
  local unit u           = udg_playerSelectedBase[pID]
  local integer uID      = GetUnitUserData(u)
  local integer pID2     = GetPlayerId(GetOwningPlayer(u))
  

    if IsUnitInGroup(u, udg_townGroup) == true and IsUnitInGroup(u, udg_campGroup) != true then

        // Town is in current Selection

        if IsPlayerEnemy(ConvertedPlayer(pID+1), GetOwningPlayer(u)) != true or udg_baseRevealed[uID] == true then
        
        // Friendly Town or revealed is in current selection

          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 1 ,1 ), (I2S(udg_baseResourceRecruits [uID]) +  " / " + I2S(udg_baseResourceRecruits [uID + 1000]))) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 2 ,1 ), (I2S(udg_baseResourceFood     [uID]) +  " / " + I2S(udg_baseResourceFood     [uID + 1000])))
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 3 ,1 ), (I2S(udg_baseResourceWeapons  [uID]) +  " / " + I2S(udg_baseResourceWeapons  [uID + 1000])))
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 6 ,1 ), I2S(udg_baseResourceGold     [uID + 2000])) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 7 ,1 ), I2S(udg_baseResourceLumber   [uID + 2000])) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 8 ,1 ), I2S(udg_baseResourceIron     [uID + 2000])) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 9 ,1 ), I2S(udg_baseResourceRecruits [uID + 2000])) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 10,1 ), I2S(udg_baseResourceFood     [uID + 2000])) 
          call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 11,1 ), I2S(udg_baseResourceWeapons  [uID + 2000]))

          if IsPlayerEnemy(ConvertedPlayer(pID+1), GetOwningPlayer(u)) != true then

            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 14,1 ), I2S(udg_playerResources[pID2     ]))  // Gold 
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 15,1 ), I2S(udg_playerResources[pID2 + 15]))  // Lumber
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 16,1 ), I2S(udg_playerResources[pID2 + 30]))  // Iron
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 17,1 ), I2S(udg_playerResources[pID2 + 45]))  // Recruits
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 18,1 ), I2S(udg_playerResources[pID2 + 60]))  // Food
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 19,1 ), I2S(udg_playerResources[pID2 + 75]))  // Weapons

          endif

          else

            // Not equal to friendly town or revealed

          endif


      else

        // Camp is in current Selection

          if IsPlayerEnemy(ConvertedPlayer(pID+1), GetOwningPlayer(u)) != true then

            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 6 ,1 ), I2S(udg_playerResources[pID2     ]))  // Gold 
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 7 ,1 ), I2S(udg_playerResources[pID2 + 15]))  // Lumber
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 8 ,1 ), I2S(udg_playerResources[pID2 + 30]))  // Iron
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 9 ,1 ), I2S(udg_playerResources[pID2 + 45]))  // Recruits
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 10 ,1 ), I2S(udg_playerResources[pID2 + 60]))  // Food
            call MultiboardSetItemValue( MultiboardGetItem( udg_multiboard[pID], 11,1 ), I2S(udg_playerResources[pID2 + 75]))  // Weapons

          endif

    endif

 // if (udg_baseRevealed[uID] == true or IsPlayerEnemy(p, GetOwningPlayer(u)) != true) and IsUnitInGroup(u, udg_townGroup) == true then

endfunction

//===========================================================================
function InitTrig_UpdateMultiboardValues takes nothing returns nothing
  local trigger t = CreateTrigger()
    set gg_trg_UpdateMultiboardValues = t
    call TriggerAddAction(t, function UpdateMultiboard)
  set t = null
endfunction

Also, here is the income trigger calling the update trigger:
JASS:
function PickAllTowns takes nothing returns nothing

  local integer pID = GetPlayerId(GetOwningPlayer(GetEnumUnit()))
  local integer uID = GetUnitUserData(GetEnumUnit())

      // Adds Global resources from Picked Town to Owning Player

    set udg_playerResources[pID]      = udg_playerResources[pID]      + udg_baseResourceGold   [uID + 2000] 
    set udg_playerResources[pID + 15] = udg_playerResources[pID + 15] + udg_baseResourceLumber [uID + 2000] 
    set udg_playerResources[pID + 30] = udg_playerResources[pID + 30] + udg_baseResourceIron   [uID + 2000]


      // Adds Local resources from picked Town to Stock and Player Count  
      // Check for breaches and adds appropriate amount if breached

      if udg_baseResourceRecruits [uID]      + udg_baseResourceRecruits [uID + 2000] < udg_baseResourceRecruits       [uID + 1000] then

          set udg_playerResources [pID + 45] = udg_playerResources      [pID         + 45] + udg_baseResourceRecruits [uID + 2000] 
          set udg_baseResourceRecruits [uID] = udg_baseResourceRecruits [uID]        + udg_baseResourceRecruits       [uID + 2000]

        else //Cap was Breached
 
          set udg_playerResources      [pID + 45] = udg_playerResources  [pID + 45] + (udg_baseResourceRecruits [uID + 1000] - udg_baseResourceRecruits [uID]) 
          set udg_baseResourceRecruits [uID]      = udg_baseResourceRecruits [uID + 1000]

      endif 

      if udg_baseResourceFood     [uID]      + udg_baseResourceFood  [uID + 2000] < udg_baseResourceFood [uID + 1000] then

          set udg_playerResources [pID + 60] = udg_playerResources   [pID + 60]   + udg_baseResourceFood [uID + 2000] 
          set udg_baseResourceFood[uID]      = udg_baseResourceFood  [uID]        + udg_baseResourceFood [uID + 2000]

        else //Cap was Breached

          set udg_playerResources  [pID + 60] = udg_playerResources [pID + 60] + (udg_baseResourceFood [uID + 1000] - udg_baseResourceFood [uID]) 
          set udg_baseResourceFood [uID]      = udg_baseResourceFood    [uID + 1000]

      endif 
    
      if udg_baseResourceWeapons  [uID     ] + udg_baseResourceWeapons  [uID + 2000] < udg_baseResourceWeapons  [uID + 1000] then

          set udg_playerResources      [pID + 75] = udg_playerResources      [pID + 75] + udg_baseResourceWeapons  [uID + 2000]
          set udg_baseResourceWeapons  [uID]      = udg_baseResourceWeapons  [uID]      + udg_baseResourceWeapons  [uID + 2000]

        else  //Cap was Breached 

          set udg_playerResources     [pID + 75] = udg_playerResources [pID + 75] + (udg_baseResourceWeapons [uID + 1000] - udg_baseResourceWeapons [uID]) 
          set udg_baseResourceWeapons [uID]      = udg_baseResourceWeapons [uID + 1000] 

      endif
endfunction

function Trig_GiveIncome_Actions takes nothing returns nothing
  local integer i = 0

    call BJDebugMsg("Income Recived...")
    call ForGroup( udg_townGroup, function PickAllTowns )

      // Update Multiboard if a Base is currently selected
    loop
      exitwhen i > 10
        if IsUnitInGroup(udg_playerSelectedBase[i], udg_townGroup) == true or IsUnitInGroup(udg_playerSelectedBase[i], udg_campGroup) == true then
          call BJDebugMsg("A multiboard selection was found!")
          set udg_transferredData_pID = i 
            call TriggerExecute( gg_trg_UpdateMultiboardValues )  
        endif
      set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_GiveIncome takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterTimerExpireEvent(t, udg_incomeTimer)
    call TriggerAddAction(t, function Trig_GiveIncome_Actions )
  set t = null
endfunction

All is working I'm just not sure if this is the way to go about this. or Actually, there is one thing that I don't know how to solve and that is when I press esc a boolean is set to true/false (if the multiboard should be opened or closed. however if it is set to false (closed) and I manually open the multiboard it will close everytime i open a new multiboard. How do I add the multiboard minimize/maximize event... can't find it.

The trigger looks like this currently:
JASS:
function Trig_Minimize_Actions takes nothing returns nothing
  local integer pID = GetPlayerId(GetTriggerPlayer())

    if udg_multiboardMinimized[pID] == true then
      call MultiboardMinimize(udg_multiboard[pID], false)
      set udg_multiboardMinimized[pID] = false
        else
          call MultiboardMinimize(udg_multiboard[pID], true)
          set udg_multiboardMinimized[pID] = true
    endif
endfunction

//===========================================================================
function InitTrig_PlayerPressEsc takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t, Player(0) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(1) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(2) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(3) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(4) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(5) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(6) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(7) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(8) )
    call TriggerRegisterPlayerEventEndCinematic(t, Player(9) )
    call TriggerAddAction(t, function Trig_Minimize_Actions )
  set t = null
endfunction

hmm found a condition called: IsMultiboardMinimized might use that one :p No event though...
 
Last edited:
Level 15
Joined
Nov 30, 2007
Messages
1,202
1) Okey, I have decided to go with your way, but are you sure its better to have 4 to 6 x Players multiboardsinstead of just changing everything in it?

2a) Is there a line to get strings from MultiboardItem ?
2b) if the answer to (a) is yes or I use variables for this, Speed wise, is it worth looping through the ItemValues and compare if the entering integer is different from the old item value and then changing it. Else do nothing. Or is it actually just better to simply override the Old Item values even if they are the same ... ? We are talking about 1 to 14 useless calls everytime it updates.

Another way to not run these updates so often would be to add the board to a pool and when enough updates are stacked the global update is run or something like that. Hehe, this is dumb. ;P

Here is my atemt at what you said, shame it keeps crashing the game :p


JASS:
//===========================================================================
// Multiboard Creation, Update Values, Reveal,
//===========================================================================

function PickedPlayers takes nothing returns nothing
  local integer pID = GetPlayerId(GetEnumPlayer())
  local integer i = 0

    if GetPlayerSlotState(GetEnumPlayer()) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_USER then
        loop
          exitwhen i > pID + 72
            set udg_mBoard[pID + i] = CreateMultiboard()
            call MultiboardDisplay(udg_mBoard[pID], false)
            set i = i + 12
        endloop

            // Board 0 - Allied Town
          call MultiboardSetRowCount    ( udg_mBoard[pID], 19    )
          call MultiboardSetColumnCount ( udg_mBoard[pID], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 3 ,0 ), "Weapons:"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 5 ,0 ), "Production"   )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 6 ,0 ), "Gold:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 7 ,0 ), "Lumber:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 8 ,0 ), "Iron:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 9 ,0 ), "Recruits"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 10,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 11,0 ), "Weapon:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 14,0 ), "Gold:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 15,0 ), "Lumber:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 16,0 ), "Iron:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 17,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 18,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID], 19,0 ), "Weapons:"     )
       
            // Board 1 - Enemy Town
          call MultiboardSetRowCount    ( udg_mBoard[pID + 12], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 12], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 3 ,0 ), "Weapons:"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 5 ,0 ), "Production"   )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 6 ,0 ), "Gold:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 7 ,0 ), "Lumber:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 8 ,0 ), "Iron:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 9 ,0 ), "Recruits"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 10,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 12], 11,0 ), "Weapon:"      )

            // Board 2 - Enemy Town Old Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 24], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 24], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 3 ,0 ), "Weapons:"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 5 ,0 ), "Production"   )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 6 ,0 ), "Gold:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 7 ,0 ), "Lumber:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 8 ,0 ), "Iron:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 9 ,0 ), "Recruits"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 10,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 24], 11,0 ), "Weapon:"      )

            // Board 3 - Allied Camp
          call MultiboardSetRowCount    ( udg_mBoard[pID + 36], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 36], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 3 ,0 ), "Weapons:"     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 6 ,0 ), "Gold:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 7 ,0 ), "Lumber:"      )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 8 ,0 ), "Iron:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 9 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 10,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 36], 11,0 ), "Weapons:"     )
     
            // Board 4 - Enemy Camp
          call MultiboardSetRowCount    ( udg_mBoard[pID + 48], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 48], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 48], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 48], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 48], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 48], 3 ,0 ), "Weapons:"     )

            // Board 5 - Enemy Camp Old Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 60], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 60], 2     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 60], 0 ,0 ), "Stock"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 60], 1 ,0 ), "Recruits:"    )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 60], 2 ,0 ), "Food:"        )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 60], 3 ,0 ), "Weapons:"     )
   
            // Board 6 - No Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 72], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 72], 1     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 72], 2 ,0 ), "No information avalible."                     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 72], 3 ,0 ), "Use a spy if you want to reveal information." )

    endif
endfunction

function makeBoard takes nothing returns nothing
    call ForForce(bj_FORCE_ALL_PLAYERS, function PickedPlayers)
endfunction 

//===========================================================================

function updateBoard takes integer current returns nothing
  local integer start = udg_mBoardStart[current]
  local integer end   = udg_mBoardEnd[current]
    loop
      exitwhen start > end
          //if udg_mBoardValue[start] != new value and udg_mBoardValue[start] > -1000 then
          //endif
        set start = start + 1
    endloop
endfunction

//===========================================================================

function revealBoard takes integer current, player p returns nothing
    
    call updateBoard(current)
  if p == GetLocalPlayer() then
    call MultiboardDisplay(udg_mBoard[current], true)
  endif
endfunction

//===========================================================================

Still not sure how I'm gonna update it... Basically i want to store the start of multiboard[x] and end of multiboard[x] and then just loop through the old values, compare them to the new values and update the changed ones.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Never remove the force "All Players"! You won't be able to use it again. You should just use "bj_FORCE_ALL_PLAYERS".

The first one isn't a good method.
The second one is better, you should use that one.

Another method would be this one:
JASS:
function makeBoard takes nothing returns nothing
    local integer i = 0
    local integer c
    
    loop
        exitwhen i == 12 // Players
        
        set c = 0
        loop
            exitwhen c == 5 // Boards
            set udg_mBoard[c*12+i] = CreateMultiboard()
            call MultiboardDisplay(udg_mBoard[c*12+i], false)
            call DisplayTextToPlayer( GetLocalPlayer(), 0., 0., "Player(" + I2S(i) + ") received multiboard: " + I2S(c*12+i) )
            
            set c = c+1
        endloop
        
        set i = i+1
    endloop
endfunction
The actual setup (setting text, icons, width, ...) will be about the same.
You can call a function like this: call setupBoard(i, c). With your method, that would be call setupBoard(pID, 1-5) (where 1-5 is set manually).
The setupBoard function could look like this:
JASS:
function setupBoard takes integer pId, integer board returns nothing
    if board == 1 then
        // Setup first board
    elseif board == 2 then
        // Setup second board
    // [...]
    else
        // Setup 5th board
    endif
endfunction

1) Okey, I have decided to go with your way, but are you sure its better to have 4 to 6 x Players multiboardsinstead of just changing everything in it?
I just thought it'd be easier for you :p. Performance-wise it won't matter.
2b) if the answer to (a) is yes or I use variables for this, Speed wise, is it worth looping through the ItemValues and compare if the entering integer is different from the old item value and then changing it. Else do nothing. Or is it actually just better to simply override the Old Item values even if they are the same ... ? We are talking about 1 to 14 useless calls everytime it updates.
You can use an ITE to filter it if you want. Though if it means you need to create more variables (for the check), then just override the old item values every time, no matter if it's the same or not.


Edit: oh, you edited your post... :/
 
Level 15
Joined
Nov 30, 2007
Messages
1,202
Never remove the force "All Players"! You won't be able to use it again. You should just use "bj_FORCE_ALL_PLAYERS".

The first one isn't a good method.
The second one is better, you should use that one.

Another method would be this one:
JASS:
function makeBoard takes nothing returns nothing
    local integer i = 0
    local integer c
    
    loop
        exitwhen i == 12 // Players
        
        set c = 0
        loop
            exitwhen c == 5 // Boards
            set udg_mBoard[c*12+i] = CreateMultiboard()
            call MultiboardDisplay(udg_mBoard[c*12+i], false)
            call DisplayTextToPlayer( GetLocalPlayer(), 0., 0., "Player(" + I2S(i) + ") received multiboard: " + I2S(c*12+i) )
            
            set c = c+1
        endloop
        
        set i = i+1
    endloop
endfunction
The actual setup (setting text, icons, width, ...) will be about the same.
You can call a function like this: call setupBoard(i, c). With your method, that would be call setupBoard(pID, 1-5) (where 1-5 is set manually).
The setupBoard function could look like this:
JASS:
function setupBoard takes integer pId, integer board returns nothing
    if board == 1 then
        // Setup first board
    elseif board == 2 then
        // Setup second board
    // [...]
    else
        // Setup 5th board
    endif
endfunction


I just thought it'd be easier for you :p. Performance-wise it won't matter.

You can use an ITE to filter it if you want. Though if it means you need to create more variables (for the check), then just override the old item values every time, no matter if it's the same or not.


Edit: oh, you edited your post... :/

IT WAS NOT EASIER!!!! (spent many hours clueless!) and how long did you diddle with that post? ;P

I guess I will just override it then.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
IT WAS NOT EASIER!!!! (spent many hours clueless!) and how long did you diddle with that post? ;P
It still seems easier to me D:
Think about it: you only need to set up all the multiboards once :O. Then still update it, of course, but update-triggers are usually a lot easier.

And you edited your post about 10 minutes before I posted >__>.
I also postpone my posts a lot :D. I open a thread, then I wait for half an hour, then I write whatever I wanted to write. Not a good habit, I know :(.
 
I have a question myself.
Would it seem easier to arrange a function like this or be more or less efficient?
No means to hijack this thread or anything..
JASS:
//===========================================================================
// Multiboard Creation, Update Values, Reveal,
//===========================================================================

function StockRepeat takes multiboard m, integer i returns nothing
    call MultiboardSetItemValue( MultiboardGetItem(m, 0     , 0 ), "Stock"        )
    call MultiboardSetItemValue( MultiboardGetItem(m, i + 1 , 0 ), "Recruits:"    )
    call MultiboardSetItemValue( MultiboardGetItem(m, i + 2 , 0 ), "Food:"        )
    call MultiboardSetItemValue( MultiboardGetItem(m, i + 3 , 0 ), "Weapons:"     )
endfunction

function RecruitsRepeat takes multiboard m, integer i returns nothing
    call MultiboardSetItemValue( MultiboardGetItem(m, i     , 0 ), "Recruits:"    )
    call MultiboardSetItemValue( MultiboardGetItem(m, i + 1 , 0 ), "Food:"        )
    call MultiboardSetItemValue( MultiboardGetItem(m, i + 2 , 0 ), "Weapons:"     )
endfunction

function ProductionRepeat takes multiboard m returns nothing
    local integer i = 5
    call MultiboardSetItemValue( MultiboardGetItem( m, i     ,0 ), "Production"   )
    call MultiboardSetItemValue( MultiboardGetItem( m, i + 1 ,0 ), "Gold:"        )
    call MultiboardSetItemValue( MultiboardGetItem( m, i + 1 ,0 ), "Lumber:"      )
    call MultiboardSetItemValue( MultiboardGetItem( m, i + 1 ,0 ), "Iron:"        )
endfunction

function GoldRepeat takes multiboard m, integer i returns nothing
    call MultiboardSetItemValue( MultiboardGetItem( m, i     ,0 ), "Gold:"        )
    call MultiboardSetItemValue( MultiboardGetItem( m, i + 1 ,0 ), "Lumber:"      )
    call MultiboardSetItemValue( MultiboardGetItem( m, i + 2 ,0 ), "Iron:"        )
endfunction

function PickedPlayers takes nothing returns nothing
  local integer pID = GetPlayerId(GetEnumPlayer())
  local integer i = 0

    if GetPlayerSlotState(GetEnumPlayer()) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_USER then
        loop
          exitwhen i > pID + 72
            set udg_mBoard[pID + i] = CreateMultiboard()
            call MultiboardDisplay(udg_mBoard[pID], false)
            set i = i + 12
        endloop

            // Board 0 - Allied Town
          call MultiboardSetRowCount    ( udg_mBoard[pID], 19    )
          call MultiboardSetColumnCount ( udg_mBoard[pID], 2     )
          call StockRepeat( udg_mBoard[pID], 0 )
          call ProductionRepeat( udg_mBoard[pID] )
          call RecruitsRepeat( udg_mBoard[pID], 9 )
          call GoldRepeat( udg_mBoard[pID], 14 )
          call RecruitsRepeat( udg_mBoard[pID], 17 )
       
            // Board 1 - Enemy Town
          call MultiboardSetRowCount    ( udg_mBoard[pID + 12], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 12], 2     )
          call StockRepeat( udg_mBoard[pID + 12], 0 )
          call ProductionRepeat( udg_mBoard[pID + 12] )
          call RecruitsRepeat( udg_mBoard[pID + 12], 9 )

            // Board 2 - Enemy Town Old Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 24], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 24], 2     )
          call StockRepeat( udg_mBoard[pID + 24], 0 )
          call ProductionRepeat( udg_mBoard[pID + 24] )
          call StockRepeat( udg_mBoard[pID + 24], 9 )

            // Board 3 - Allied Camp
          call MultiboardSetRowCount    ( udg_mBoard[pID + 36], 11    )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 36], 2     )
          call StockRepeat( udg_mBoard[pID + 36], 0 )
          call GoldRepeat( udg_mBoard[pID + 36], 6 )
          call StockRepeat( udg_mBoard[pID + 36], 9 )
     
            // Board 4 - Enemy Camp
          call MultiboardSetRowCount    ( udg_mBoard[pID + 48], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 48], 2     )
          call StockRepeat( udg_mBoard[pID + 48], 0 )

            // Board 5 - Enemy Camp Old Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 60], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 60], 2     )
          call StockRepeat( udg_mBoard[pID + 60], 0 )
   
            // Board 6 - No Info
          call MultiboardSetRowCount    ( udg_mBoard[pID + 72], 3     )
          call MultiboardSetColumnCount ( udg_mBoard[pID + 72], 1     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 72], 2 ,0 ), "No information avalible."                     )
          call MultiboardSetItemValue( MultiboardGetItem( udg_mBoard[pID + 72], 3 ,0 ), "Use a spy if you want to reveal information." )

    endif
endfunction
 
Status
Not open for further replies.
Top