Multiboard Shenanigans

tommerbob

Minecraft. :D
Reaction score
110
I am using the Board system for my multiboards. It works great and all, but because its local, how can I access it to update in a separate function?

I feel like an idiot asking this, because it seems simple enough, but I can't figure it out. Maybe its because I'm over-thinking it. Anyway, I tried making the Multiboard a global instead of local, but then I started getting all sorts of syntax errors.

Tl;DR: How to do a multiboard that can be easily accessed/manipulated from outside the function it is created in? Here's my code:

JASS:
library Multiboard requires Board, ARGB

globals
    private constant integer COLOR_GOLD = 0xD4A017
endglobals

function MB_Create takes nothing returns nothing
    local player P = GetTriggerPlayer()
    local Board MB = Board.create()
    local BoardItem it
    local BoardColumn col
    
    //Multiboard title
    set MB.title = "Hero Stats"
    set MB.titleColor = ARGB.fromPlayer(P)
    //Visible to only Local player
    set MB.visible[P] = true
    //Number of columns
    set MB.col.count = 4
    //Number of rows
    set MB.row.count = 5
    //Width for all columns/rows
    set MB.all.width = 0.04
    //Column 1
    set col = MB.col[0]
    set col.width = 0.08
    set col.color = COLOR_GOLD
    //Column 2
    set col = MB.col[1]
    set col.width = 0.04
    //Column 3
    set col = MB.col[2]
    set col.width = 0.08
    set col.color = COLOR_GOLD
    //Column 4
    set col = MB.col[3]
    set col.width = 0.04
    //Column 1 items
    set it = MB[0][0]
    set it.text = "Kills:"
    set it = MB[0][1]
    set it.text = "Deaths:"
    set it = MB[0][2]
    set it.text = "Critical Strike chance:"
    set it = MB[0][3]
    set it.text = "Dodge chance:"
    set it = MB[0][4]
    set it.text = "Spell Power:"
    //Column 3 items
    set it = MB[2][0]
    set it.text = "Magic Resist:"
    set it = MB[2][1]
    set it.text = "Move Speed:"
    set it = MB[2][2]
    set it.text = "Quests Completed:"
    set it = MB[2][3]
    set it.text = "Reputation:"
endfunction

endlibrary
 

lep

Active Member
Reaction score
8
You can have a global Multiboard, but you can't initialize it inside of the globals block.
JASS:

globals
    Board m=Board.create() //Error

    Board n //works
endglobals

Then you can acces n in your functions. You create the actual multiboard inside of an init function
JASS:

library bla initializer init

    private function init takes nothing returns nothing
        set n=Board.create()
    endfunction
endlibrary
 

tommerbob

Minecraft. :D
Reaction score
110
Okay, so if I use a global for my Multiboard, I can create several multiboards (one for each player) without the data being overwritten, because it creates a new struct instance, correct?
 

Hatebreeder

So many apples
Reaction score
381
Okay, so if I use a global for my Multiboard, I can create several multiboards (one for each player) without the data being overwritten, because it creates a new struct instance, correct?

You have to use
JASS:
 if getlocalPlyer() == YOURPLAYER
call DisplayMultiboard(true)
endif


To show the Multiboard to a specific Player ONLY. However, you have to sync all Multiboards so that the other players don't desync.
 

luorax

Invasion in Duskwood
Reaction score
67
Board has the proper operators to do it.

Also, Hatebreeder, you, here? :D I did not think that you're still alive :D
 

luorax

Invasion in Duskwood
Reaction score
67
Yea, exactly that easy. I love that API too, my QuestStruct is based on that API :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top