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: 87

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top