• 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.

Another jass question:

Status
Not open for further replies.
This function is supposed to return a string when called, a so called bar to be used inside my multiboard. The real taken is how many bars remaining out of 100.

An example could be:

JASS:
call MultiboardSetItemValueBJ( udg_StatusBoard[udg_PlayerNR], 1, 2, ConfigureBars(50.) )
This would return an 50% green bar in the multiboard.
Example of example: [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||]
This would of cause be shorter as the editor don put space between "|"

However doing this currently returns not only nothing, it removes all lines beneath the appropiate line in the multiboard.
I would suspect this to be because it loops a lot of "empty spaces", but I have no clue to fix it.

The function is as follows:

JASS:
function ConfigureBars takes real barcurrent returns string
local integer size = 2 // 2 = half
local real barmax = 100.
local integer greenbars = R2I(barcurrent) / size
local integer redbars = R2I(barmax - barcurrent) / size
local integer counter
local string bar = ""


loop
set counter = counter +1
if counter <= greenbars then
set bar = ( bar + "|c0000FF00||r " )
else
set bar = ( bar + "|c00FF0000||r " )
endif

exitwhen counter >= 100 / size
endloop

set bar = ( "[" + bar + "]" )


return bar
endfunction
 
Status
Not open for further replies.
Top