Posted 02 March 2014 - 12:44 PM
I keep getting "bios:395: Expected string when I run :
which calls this function:
--BarAPI Test
os.loadAPI(BarAPI)
local Current = 24
local Total = 54
local ActiveColor = "red"
local InactiveColor = "yellow"
local CursorX = 5
local CursorY = 5
local Mon = peripheral.wrap("left")
local Percent = BarAPI.Percentage(Current, Total)
terms.clear()
BarAPI.PercentBar(CursorX ,CursorY, InactiveColor, ActiveColor, Percent, Mon)
which calls this function:
--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 --TBD Round to a Decimal place
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, InActiceColor, ActiveColor, n, Mon)
local FormdN = Round(n, 0)
local i = 0
local Paste = Mon or terms
Paste.setCursorPos(CursorX,CursorY)
Paste.setBackgroundColor(InActiceColor)
Paste.write("[ ]")
Paste.setCursorPos(CursorX,CursorY)
for i < FormdN do
Paste.setBackgroundColor(ActiveColor)
Paste.write(" ")
i + 1
end
end
Edited on 02 March 2014 - 11:45 AM