HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help with a small script

07-30-2008, 09:39 PM#1
crayz
Collapse JASS:
local integer y = -1
local integer rows = 0

    loop
        set y = y + 1
        exitwhen y > 12
        if ( udg_itemData[y] > 0 ) then
           set rows = rows + 1
        endif
    endloop

    call MultiboardSetRowCount( udg_Multiboard[c], rows )
    set y = -1

    loop
        exitwhen y > rows
        set y = y + 1
        if ( udg_itemData[y] > 0 ) then
           call MultiboardSetItemValueBJ( udg_Multiboard[c], 1, y, udg_dataName[y] +I2S(udg_itemData[y]) )
           call MultiboardSetItemWidthBJ( udg_Multiboard[c], 1, y, 10.00 )
        endif
    endloop

It detects the correct amount of rows for that multiboard, but functions wrong once setting the text in the right row.

Here is the list format of my item attributes:
Collapse JASS:
        set udg_itemData[0] = 7 // Armor Bonus
        set udg_itemData[1] = 12 // Damage Bonus
        set udg_itemData[2] = 0 // Sight Range
        set udg_itemData[3] = 0 // Mana Regeneration
        set udg_itemData[4] = 0 // Health Regeneration
        set udg_itemData[5] = 5 // Strength Bonus
        set udg_itemData[6] = 6 // Agility Bonus
        set udg_itemData[7] = 7 // Intelligence Bonus
        set udg_itemData[8] = 50 // Health Bonus
        set udg_itemData[9] = 100 // Mana Bonus
        set udg_itemData[10] = 0 // What kind of item
        set udg_itemData[11] = 0 // Level Requirement
        set udg_itemData[12] = 0 // Str Requirement
        set udg_itemData[13] = 0 // Name of item

Using that list, the multiboard outputs the following:

Damage: 12
Armor: 7
Armor: 7
Armor: 7
Health: 50
Mana: 100

It errors in two places. First, the Armor bonus should be listed above the Damage bonus. Second, it outputs armor 3 times :X

Any suggestions?
07-31-2008, 12:11 AM#2
Anitarf
What you need is something more like this:
Collapse JASS:
    local integer y = 0
    local integer rows = 0
    local integer r = 0

    loop
        if ( udg_itemData[y] > 0 ) then
           set rows = rows + 1
        endif
        set y = y + 1
        exitwhen y > 12
    endloop

    call MultiboardSetRowCount( udg_Multiboard[c], rows )

    set y = 0
    loop
        if ( udg_itemData[y] > 0 ) then
           set r = r + 1
           call MultiboardSetItemValueBJ( udg_Multiboard[c], 1, r, udg_dataName[y] +I2S(udg_itemData[y]) )
           call MultiboardSetItemWidthBJ( udg_Multiboard[c], 1, r, 10.00 )
        endif
        set y = y + 1
        exitwhen y > 12
    endloop
The reason yours didn't work correctly was because you only displayed the first 6 stats, instead of the first 6 non-zero stats. Those of the first 6 stats that weren't non-zero were simply skipped, leaving a blank line; the reason the line didn't end up being blank as it should was because you displayed the first stat in the "zeroth" row, which in fact tells the game to display it in all the rows, so Armor actualy did come before Damage as you thought it should.
07-31-2008, 12:47 AM#3
crayz
Quote:
Originally Posted by Anitarf
What you need is something more like this:
The reason yours didn't work correctly was because you only displayed the first 6 stats, instead of the first 6 non-zero stats. Those of the first 6 stats that weren't non-zero were simply skipped, leaving a blank line; the reason the line didn't end up being blank as it should was because you displayed the first stat in the "zeroth" row, which in fact tells the game to display it in all the rows, so Armor actualy did come before Damage as you thought it should.

Ohh I see now
The new code works great, thanks much!

+rep to you