• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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