percentage bar -> |||||||||

Menelaus

New Member
Reaction score
9
ok in shopping maul they have this bar that shows a percentage of how many lives you have and looks like this ||||||||||||||||||

how would i make something like this?? i tried for about an hour and then i searched the forums but couldnt find anything except something i posted that was sort of similar
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
Use Floating Text?
EDIT: The only way I can think of is using a lot of If/Then/Else
 

Menelaus

New Member
Reaction score
9
well i know how to display it i just dont know how to make it display the right thing...it always has the wrong number of bars
 

Mittsies

New Member
Reaction score
24
if you have a variable like, INTEGER_LIVES = 5, and you want to make 5 bars to represent 5 life:
Make a variable "string" array with the maximum amount of lives (let's just say 10 for this case)

set_bar[1] = |
set_bar[2] = ||
set_bar[3] = |||
set_bar[4] = ||||
and so on...


Display a Floating Text as...

(string: set_bar[INTEGER_LIVES])
set last created floating text to a floating text variable "Team1_LifeDisplay"

This way it will show a specific string based off your current lives. Everytime you gain or lose a life, destroy Team1_LifeDisplay and remake a new one with the proper amount of lives.

Simple.. right? :D
 

Menelaus

New Member
Reaction score
9
would there be a way to gage it so that i always have the same number of bars every time but not necessarily the same number of lives? probably some weird math stuff that im not good at. i say this cuz i was goin to put this in a multiboard, not floating text, and so 50 bars might be a little much.
 
T

Tubba

Guest
You mean like it drops every 5 lives or something? Yeah, do something like this...

Code:
*Life event and condition*
If Lives / 5 * 5 = Lives (This shows if it's divisible by 5 since integers always round down; If it's say, 31, it will return 30.) then do *Set Multiboard text* else Do Nothing
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
If someone can convert this to GUI...
(It's been too long...)

Basically:
totalBars = Amount of bars in your counter (e.g.: 55)
barSymbol = The symbol you use
represents = the TOTAL the bar represents (e.g.: 100)
progress = the CURRENT amount you got (e.g.: 55 out of 100)
fullColor = the HEX code of your "full" symbols (e.g.: FF0000)
emptyColor = the HEX code of your "empty" symbols (e.g.: 880000)

At the end of the function: bar is the string that represents your bar.

JASS:
function CreateBar takes nothing returns nothing
    local integer i = 0

    local real totalBars
    local string barSymbol = "I"
    local real represents
    local real progress

    local string fullColor
    local string emptyColor
    local string bar

    set bar = "|cFF" + fullColor
    loop
    exitwhen i > R2I(totalBars / (represents/progress))
        set bar = bar + barSymbol
        set i = i + 1
    endloop

    set bar = bar + "|r|cFF" + emptyColor
    loop
    exitwhen i > totalBars
        set bar = bar + barSymbol
        set i = i + 1
    endloop

    set bar = bar + "|r"
endfunction



With the examples given above it would do this:

Calculate your percental progress: 100/55 = 55%
Divide the total amount of bars by this to get the amount of "full bars" (= 50 * 55/100)
Untill that amount of bars, it adds "full" bar symbols.
After that amount of bars, it continues untill it reached the max amount of bars and fills those with "empty" symbols.
 

Mittsies

New Member
Reaction score
24
Magentix if you just took my system and put in a dividing factor(such as how Tubba showed how it could be done), it would work perfectly. No need to pull out this fancy JASS stuff for such a simple trigger.
 

Romek

Super Moderator
Reaction score
964
Magentix if you just took my system and put in a dividing factor(such as how Tubba showed how it could be done), it would work perfectly. No need to pull out this fancy JASS stuff for such a simple trigger.

But it wouldn't show the lives lost...
Your one would just show
|
||
|||
etc

his would do
||||
||||
||||

That function could be copied to the map header, and called when needed.
 

Mittsies

New Member
Reaction score
24
set multiboard to:
|cff00ff00 + bar_string[integer_lives] + |r|cffff0000 + bar_string[max_lives - integer_lives] + |r

To make it in intervals of 5, set
for each Integer A 1 through 5
bar_string[Integer A] = |
for each Integer A 6 through 10
bar_string[Integer A] = ||

and so on.

(Maybe it's just me but this seems a lot more simple.)
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
1) Create a string global named bar

2) Put this into your map header:
JASS:
function CreateBar takes real current, real maximum returns string
    local integer i = 0

    local real totalBars = 50
    local string barSymbol = "I"

    local string fullColor = "00FF00"
    local string emptyColor = "FF0000"
    local string bar

    set bar = "|cFF" + fullColor
    loop
    exitwhen i > R2I(totalBars / (maximum/current))
        set bar = bar + barSymbol
        set i = i + 1
    endloop

    set bar = bar + "|r|cFF" + emptyColor
    loop
    exitwhen i > totalBars
        set bar = bar + barSymbol
        set i = i + 1
    endloop

    set bar = bar + "|r"
    
    return bar
endfunction


3) Use this code to create a bar:
Code:
Custom Script: set udg_bar = CreateBar(0,1)
Replace the 0 with the current progress (e.g.: 5 out of 10)
Replace the 1 with the maximum progress (e.g.: 5 out of 10)



Note:
"bar" can be an array if you need multiple bars.
Then you'd have to use:
Code:
Custom Script: set udg_bar[X] = CreateBar(0,1)
Replacing X with the array index


4) Edit the script variables to suit your liking.
 

Menelaus

New Member
Reaction score
9
i ended up with something sort of like magentix' except in gui... but it still doesnt work!!!

the first time a live is lost, a lot of bars get taken off but then its fine... any ideas?


Code:
Initialization
    Events
        Player - Player 1 (Red) types a chat message containing -lives as An exact match
    Conditions
    Actions
        Set lives1 = 30
        Set numtotalbars = 40
        Set livesforbar = lives1
        Set origlives = livesforbar
        Set n = (Real(livesforbar))
        Set d = (Real(origlives))
        Set n = (n x (100.00 / d))
        Set d = (d x (100.00 / d))
        Set n = (n / (100.00 / (Real(numtotalbars))))
        Set d = (d / (100.00 / (Real(numtotalbars))))
        Set livesforbar = (Integer(n))
        Set barsstring[1] = <Empty String>
        Set barsstring[2] = <Empty String>
        For each (Integer A) from 1 to livesforbar, do (Actions)
            Loop - Actions
                Set barsstring[1] = (barsstring[1] + /)
        For each (Integer B) from 1 to (numtotalbars - livesforbar), do (Actions)
            Loop - Actions
                Set barsstring[2] = (barsstring[2] + -)
        Game - Display to (All players) for 30.00 seconds the text: ((|cff00ff00 + (barsstring[1] + |r|cffff0000)) + (barsstring[2] + |r))

Code:
Life is Lost
    Events
        Player - Player 1 (Red) types a chat message containing - as An exact match
    Conditions
    Actions
        Set lives1 = (lives1 - 1)
        Set livesforbar = lives1
        Set n = (Real(livesforbar))
        Set n = (n x (100.00 / d))
        Set n = (n / (100.00 / (Real(numtotalbars))))
        Set livesforbar = (Integer(n))
        Set barsstring[1] = <Empty String>
        Set barsstring[2] = <Empty String>
        For each (Integer A) from 1 to livesforbar, do (Actions)
            Loop - Actions
                Set barsstring[1] = (barsstring[1] + /)
        For each (Integer B) from 1 to (numtotalbars - livesforbar), do (Actions)
            Loop - Actions
                Set barsstring[2] = (barsstring[2] + -)
        Game - Display to (All players) for 30.00 seconds the text: ((|cff00ff00 + (barsstring[1] + |r|cffff0000)) + (barsstring[2] + |r))





heres the map: type "-lives" to start and "-" to lose a life
 

Attachments

  • shopping bar.w3x
    17.3 KB · Views: 88

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
fricking explain what you are talking about. You mean that if you have 100 lives, and fifty bars, then every 2 lives lost loses you a bar?
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
I think that he wants a proportion, like this (not what you want, but...):

40/100 = X/40
 

Menelaus

New Member
Reaction score
9
I want to have a total of 40 bars every time. There is an option to randomize the number of lives. Therefore the number of liver per bar will change from game to game. In the code I posted, i used a numerator and denominator to make a percent (out of a hundred). Then i divided by 4 (out of 25 [bars])

Does that make sense?
EDIT:
I think that he wants a proportion, like this (not what you want, but...):

40/100 = X/40
exactly
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
Ok. So what do you need help with?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top