• Math problem attempting to make a hud bar that resets every 700?
3 replies, posted
Hey there, im trying to make a bar that will reset it self then it hits 700, and then start over again. The problem is that i can't figure a way out, and i tried to make this work in 3 hours now, and i just can't get it right... Anyone, who got an idea? [code] local L = 700 local LA = (math.floor(plyXP/700) * 700) local len = (LA - plyXP) / L * 148 [/code]
local Width = 700 -- The max width of the bar when at 100% local DrawWidth = plyXP * ( Width / 100 ) -- So basically you get 1% of the max width and just multiply it by plyXP, real simple and easy [editline]15th November 2013[/editline] Oh i think thats not what you wanted? Can you explain better what you need?
If you're looking to have it jump back to zero each time it reaches 700, just set up your bar as suggested above, but use an intermediate variable that is reset when the value is >= 700: [code] --Somewhere else: currentXP = 0 -- This will be the intermediate currentXP = plyXP if currentXP >= 700 then currentXP = (currentVal - 700) --If you want the excess to be added if 700 is overstepped -- or -- currentXP = 0 -- If you want the bar to reset to zero even if 700 is overstepped end local MaxBarWidth = 700 local L = (currentXP / MaxBarWidth) * <max width of the graphic bar> [/code]
[code]x % 700[/code] % means modulo, It does x / 700 and gives you the remainder :P