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

[General] Problem with multiboard

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,852
I have a trigger to create a multiboard:
  • Tabla
    • Events
    • Conditions
    • Actions
      • Set Grupo_Jugador_Variable[3] = (All players matching (((Matching player) slot status) Equal to Is playing))
      • Multiboard - Create a multiboard with 5 columns and (1 + (Number of players in Grupo_Jugador_Variable[3])) rows, titled Statistics
      • Custom script: call DestroyForce(udg_Grupo_Jugador_Variable[3])
      • Set Tabla = (Last created multiboard)
      • Multiboard - Hide Tabla
      • Multiboard - Set the width for Tabla item in column 1, row 0 to 1.45% of the total screen width
      • Multiboard - Set the width for Tabla item in column 2, row 0 to 6.50% of the total screen width
      • Multiboard - Set the display style for Tabla item in column 0, row 0 to Show text and Hide icons
      • Multiboard - Set the text for Tabla item in column 0, row 0 to 0
      • Multiboard - Set the text for Tabla item in column 1, row 0 to <Empty string>
      • Multiboard - Set the text for Tabla item in column 0, row 2 to <Empty string>
      • Multiboard - Set the text for Tabla item in column 1, row 2 to |cffff0000Drae|r
      • Multiboard - Set the text for Tabla item in column 2, row 2 to |cffff0000 nei|r
      • Multiboard - Set the text for Tabla item in column 2, row 1 to Player
      • Multiboard - Set the text for Tabla item in column 3, row 1 to Kills
      • Multiboard - Set the text for Tabla item in column 4, row 1 to Deaths
      • Multiboard - Set the text for Tabla item in column 5, row 1 to Assists
      • Multiboard - Set the color for Tabla item in column 0, row 0 to (41.00%, 41.00%, 41.00%) with 0.00% transparency
      • Multiboard - Set the color for Tabla item in column 0, row 1 to (100.00%, 83.00%, 0.00%) with 0.00% transparency
      • Trigger - Run Jugadores Orden <gen> (checking conditions)
      • Multiboard - Mostrar Tabla
      • Multiboard - Maximizar Tabla
But I passed it to Jass:
JASS:
function IsPlaying takes nothing returns boolean
    return GetPlayerSlotState(GetFilterPlayer())==PLAYER_SLOT_STATE_PLAYING
endfunction

function Trig_Tabla_Actions takes nothing returns nothing
    local force f=GetPlayersMatching(Condition(function IsPlaying))
    set udg_Row[0]=100
    set udg_Tabla=CreateMultiboard()
    call MultiboardSetColumnCount(udg_Tabla,5)
    call MultiboardSetRowCount(udg_Tabla,1+CountPlayersInForceBJ(f))
    call MultiboardSetTitleText(udg_Tabla,"Statistics")
    call DestroyForce(f)
    call MultiboardDisplay(udg_Tabla,false)
    call MultiboardSetItemWidthMejor(udg_Tabla,1,0,1.45/100)
    call MultiboardSetItemWidthMejor(udg_Tabla,2,0,6.50/100)
    call MultiboardSetItemStyleMejor(udg_Tabla,0,0,true,false)
    call MultiboardSetItemValueMejor(udg_Tabla,0,0,"0")
    call MultiboardSetItemValueMejor(udg_Tabla,1,0,"")
    call MultiboardSetItemValueMejor(udg_Tabla,0,2,"")
    call MultiboardSetItemValueMejor(udg_Tabla,1,2,"|cffff0000Drae|r")
    call MultiboardSetItemValueMejor(udg_Tabla,2,2,"|cffff0000 nei|r")
    call MultiboardSetItemValueMejor(udg_Tabla,2,1,"Player")
    call MultiboardSetItemValueMejor(udg_Tabla,3,1,"Kills")
    call MultiboardSetItemValueMejor(udg_Tabla,4,1,"Deaths")
    call MultiboardSetItemValueMejor(udg_Tabla,5,1,"Assists")
    call MultiboardSetItemColorMejor(udg_Tabla,0,0,105,105,105,255)
    call MultiboardSetItemColorMejor(udg_Tabla,0,1,255,212,0,255)
    call ConditionalTriggerExecute(gg_trg_Jugadores_Orden)
endfunction

//===========================================================================
function InitTrig_Tabla takes nothing returns nothing
    set gg_trg_Tabla=CreateTrigger()
    call TriggerAddAction(gg_trg_Tabla,function Trig_Tabla_Actions)
endfunction
I remade the BJs functions because they have a reference leak and to reduce the number of steps and adding an exception
JASS:
function MultiboardSetItemValueMejor takes multiboard mb, integer col, integer row, string val returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set curCol=0
    else
        set numCols=col-1
        set curCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=0
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemValue(mbitem,val)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemIconMejor takes multiboard mb, integer col, integer row, string myitem returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set curCol=0
    else
        set numCols=col-1
        set curCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=0
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemIcon(mbitem,myitem)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemStyleMejor takes multiboard mb, integer col, integer row, boolean showValue, boolean showIcon returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set curCol=0
    else
        set numCols=col-1
        set curCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=0
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemStyle(mbitem,showValue,showIcon)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemWidthMejor takes multiboard mb, integer col, integer row, real width returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set curCol=0
    else
        set numCols=col-1
        set curCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=0
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemWidth(mbitem,width)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemColorMejor takes multiboard mb, integer col, integer row, integer red, integer green, integer blue, integer alpha returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set curCol=0
    else
        set numCols=col-1
        set curCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=0
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemValueColor(mbitem,red,green,blue,alpha)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction
But now the multiboard doesn't display properly
Before:
upload_2021-2-7_18-28-52.png

Now:
upload_2021-2-7_18-30-9.png

What is happening?
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
Ok, I realize in the part set curCol=0 was the problem, because I'm doing the loop run always a lot of times, only you will understand what I'm saying of you understood that functions, but well, I fixed them.
JASS:
function MultiboardSetItemValueMejor takes multiboard mb, integer col, integer row, string val returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local integer initCol
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set initCol=0
    else
        set numCols=col-1
        set initCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=initCol
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemValue(mbitem,val)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemIconMejor takes multiboard mb, integer col, integer row, string myitem returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local integer initCol
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set initCol=0
    else
        set numCols=col-1
        set initCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=initCol
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemIcon(mbitem,myitem)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemStyleMejor takes multiboard mb, integer col, integer row, boolean showValue, boolean showIcon returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local integer initCol
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set initCol=0
    else
        set numCols=col-1
        set initCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=initCol
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemStyle(mbitem,showValue,showIcon)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemWidthMejor takes multiboard mb, integer col, integer row, real width returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local integer initCol
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set initCol=0
    else
        set numCols=col-1
        set initCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=initCol
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemWidth(mbitem,width)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction

function MultiboardSetItemColorMejor takes multiboard mb, integer col, integer row, integer red, integer green, integer blue, integer alpha returns nothing
    local integer curRow
    local integer curCol
    local integer numRows
    local integer numCols
    local integer initCol
    local multiboarditem mbitem=null
    if row-1>MultiboardGetRowCount(mb) or col-1>MultiboardGetColumnCount(mb) or row<0 or col<0 then
        return
    endif
    if row==0 then
        set numRows=MultiboardGetRowCount(mb)
        set curRow=0
    else
        set numRows=row-1
        set curRow=row-1
    endif
    if col==0 then
        set numCols=MultiboardGetColumnCount(mb)
        set initCol=0
    else
        set numCols=col-1
        set initCol=col-1
    endif
    loop
        exitwhen curRow>numRows
        set curCol=initCol
        loop
            exitwhen curCol>numCols
            set mbitem=MultiboardGetItem(mb,curRow,curCol)
            call MultiboardSetItemValueColor(mbitem,red,green,blue,alpha)
            call MultiboardReleaseItem(mbitem)
            set curCol=curCol+1
        endloop
        set curRow=curRow+1
    endloop
    set mbitem=null
endfunction
 
Status
Not open for further replies.
Top