HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Multiboards in JASS

03-12-2009, 06:20 PM#1
Blacktastic
Alright, I usually do multiboards in GUI since I have never messed with them in vJass but I converted it today and saw a bunch of red in my face so I figured I'd learn how to Jass a multiboard.

Alright, fixed one problem but the names still arn't showing up. Anything I place in the string field isn't showing up at all.

Collapse JASS:
scope EquipSystem initializer init

globals
    private integer array ItemID
    private integer array MyItemID
    private multiboard EquipScreen
endglobals

function GetEquippedItem takes integer slot, unit who returns nothing
    local item FromMB
    //Check for the item
    if ItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + slot)] == 0 then
    else
        //Remove Stats
        call ModStats(MyItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + slot)], who, true)
        //Modify the Multiboard
        //Add the Item to Inventory (Upon completing the inventory system, this will change.)
        set FromMB = CreateItem(ItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + slot)], GetUnitX(who), GetUnitY(who))
        call UnitAddItem(who, FromMB)
        set ItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + slot)] = 0
        set MyItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + slot)] = 0
    endif
    set FromMB = null
endfunction

function EquipItem takes item whatitem, unit who returns nothing
    local integer Slot = GetItemLevel(whatitem)
    //Check if slot is full
    if ItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + Slot)] != 0 then
        call GetEquippedItem(Slot, who)
    endif
    set ItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + Slot)] = GetItemTypeId(whatitem)
    set MyItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + Slot)] = R2I(GetWidgetLife(whatitem))
    //Apply Stats
    call ModStats(MyItemID[((13 * GetPlayerId(GetOwningPlayer(who))) + Slot)], who, false)
    //Modify Multiboard
    //Remove Item (Upon completing the inventory system, this wil change.)
    call RemoveItem(whatitem)
endfunction

function setMultiboard takes nothing returns nothing
    local integer i = 0
    local integer l = 0
    set EquipScreen = CreateMultiboard()
    call MultiboardSetRowCount(EquipScreen, 14)
    call MultiboardSetColumnCount(EquipScreen, 6)
    call MultiboardSetTitleText(EquipScreen, "Equipment Menu")
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 1), "|CFFFF0303" + GetPlayerName(Player(0)) + "|r" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 2), "|CFF0042FF" + GetPlayerName(Player(1)) + "|r" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 3), "|CFF1CE6B9" + GetPlayerName(Player(2)) + "|r" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 4), "|CFF540081" + GetPlayerName(Player(3)) + "|r" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 5), "|CFFFFFF01" + GetPlayerName(Player(4)) + "|r" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 0, 6), "|CFFFE8A0E" + GetPlayerName(Player(5)) + "|r" ) 
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 1, 0), "Mainhand" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 2, 0), "OffHand" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 3, 0), "Chest" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 4, 0), "Helm" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 5, 0), "Gloves" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 6, 0), "Sleeves" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 7, 0), "Pants" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 8, 0), "Boots" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 9, 0), "Necklace" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 10, 0), "R Ring" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 11, 0), "L Ring" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 12, 0), "R Earring" )
    call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 13, 0), "L Earring" )
    loop
        exitwhen i > 6
        loop
            exitwhen l > 14
            call MultiboardSetItemWidth(MultiboardGetItem(EquipScreen, l, i),  5.00 )
            call MultiboardSetItemStyle(MultiboardGetItem(EquipScreen, l, i), true, false )
            set l = l + 1
        endloop
        set i = i + 1
        set l = 0
    endloop
    call MultiboardDisplay(EquipScreen, true )
    call ReleaseTimer(GetExpiredTimer())
endfunction

function init takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, .1, false, function setMultiboard)
endfunction

endscope
03-12-2009, 06:31 PM#2
xombie
Arrays and other indexes should start at 0, not 1.

In this case, multiboard item values start at item index 0, not item index 1, so...

Collapse JASS:
call MultiboardSetItemValue( MultiboardGetItem(EquipScreen, 1, 2), "|CFFFF0303" + GetPlayerName(Player(0)) + "|r" )

You have no value for the index of 0, and as such it will produce a column on the far left. Its simply because you did not assign it anything.
03-12-2009, 06:35 PM#3
Blacktastic
I tried using 0 and nothing happened though.. hmm I will try it again.

Any idea why the player names are not showing?
03-12-2009, 06:40 PM#4
xombie
I'm not very experienced with using multiboards, but it could be because there is not enough room to display them. I don't know.
03-13-2009, 01:29 AM#5
Blacktastic
No, it's not too big. Not even a string of 1 character shows up.
03-13-2009, 01:38 AM#6
Blackroot
Multiboards are the least intuitive point in jass. Examine the BJ functions; you will see there is an array value for multiboards that starts at 1 (+0) and one that starts at 0 (-1). There's other unwieldy things; it's absolutely retarded. It took me two weeks to make a small multiboard system; and it's still incredibly unwieldy. Someone really needs to make an API for jass based multiboards; because blizzard screwed up bad with them.

Enough of that rant; BJ functions work because they take into account the different array values. There's other things that are strange, try making a GUI multiboard and reverse engineering the BJ functions; then dissolve thoes into more rational calls. It's the only sane way to do it.

Let me iterate this one more time; you will never get this working without examining BJ functions; they are totally irrashional.
03-13-2009, 01:48 AM#7
Blacktastic
Well I did examine them and the text DOES show up on the board EXCEPT the first six.

Why would 14 of them work and 6 would not? o.O
03-13-2009, 02:02 AM#8
Blackroot
Quote:
Originally Posted by Blacktastic
Well I did examine them and the text DOES show up on the board EXCEPT the first six.

Why would 14 of them work and 6 would not? o.O

I've had the same problem.

I'll dump some comments I wrote well attempting (and failing) to write a multiboard API attempting to debug it:

Expand JASS:

I couldn't figure out the problem and gave up. I don't know if SetRow/ColumnCount actually works off +1/+1. Give it a try. I did alot of work debugging them; this is a small cutout; but most of it was fruitless. This is the most relevant, the other possibility is that multiboards display a maximum number of items and push old content out.
03-13-2009, 02:32 AM#9
Blacktastic
Well when I had it in GUI it worked perfectly. I converted it to JASS to get rid of all the nonsensicals and to get a better idea of multiboard JASS.

Guess that was a bad choice >.<

Checking out what you got here.

Edit: Ok, it seems like anything beyond Column 0 does not want to work. Column 0 works just fine. Column 1/2/3/4/5/6 don't do shit o.O

Edit2: Found the culprit.

Collapse JASS:
call MultiboardSetItemWidth(mbitem, width/100.0)
Turns out I was setting column 1 to 500% of the screen width. How annoying.

[thumbnail](Why did thumbnail stop working?)[/thumbnail]

On another note, how would I check if a player is currently playing so I can set the column number equal to number of players + 1
03-13-2009, 03:15 AM#10
PurplePoot
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
You can also use GetPlayerController(p) == MAP_CONTROL_COMPUTER to check for computers.

Quote:
Originally Posted by Blackroot
Multiboards are the least intuitive point in jass. Examine the BJ functions; you will see there is an array value for multiboards that starts at 1 (+0) and one that starts at 0 (-1). There's other unwieldy things; it's absolutely retarded.
Seeing as I have seen no evidence for this, I'd be interested in seeing what exactly you are referring to (as starting at 1). If you mean the multiboard size, of course - that's standard programming convention. An array of size n is [0..n-1].
03-13-2009, 03:25 AM#11
xombie
Quote:
Originally Posted by xombie
but it could be because there is not enough room to display them. I don't know.