Posted 02 March 2014 - 03:14 PM
I've been trying to print a Bar from a function but keep running into issues
it just prints the back ground bar atm How can I fix it?
Heres the code:
it just prints the back ground bar atm How can I fix it?
Heres the code:
os.loadAPI("BarAPI")
local Mon = peripheral.wrap("Right")
BarAPI.PercentBar(1, 1, 2, 1, 25, Mon)
--bar API
--BgColor = bar unused
--BColor = Bar Color
--Percent = Percentage that needs to be filled
--CX, Cursor X pos
--CY, Cursor Y pos
--
-- Made By SteamPunk_Devil -- CCfourm Name Makeme -- Ingame Name SteamPunk_Angel
function Percentage(current,total) --returns One number as a percentage of the second one, use Round() to round
local No1 = current
local No2 = total
local Percent = (No1 / No2) * 100
return Percent
end
function Round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function PercentBar(CursorX, CursorY, InActiveColor, ActiveColor, n, Mon)
local n10 = n/10
local FormdN = Round(n10, 0)
local i = 1
local Paste = Mon or term
Paste.setCursorPos(CursorX, CursorY)
Paste.setBackgroundColor(InActiveColor)
Paste.write("[ ]")
Paste.setCursorPos(CursorX, CursorY)
while FormdN <= i do
Paste.setBackgroundColor(ActiveColor)
Paste.write(" ")
i = i + 1
end
end
Edited on 02 March 2014 - 04:51 PM