Post by Will11690 on Nov 21, 2014 9:17:41 GMT -5
I have been working on a program that can show me the power in an EnderIO Capacitor Bank but I have run into a snag. I can't display a 10 digit long number. I need a way to allow me to display up to atleast a 15 digit number. Any help is appreciated and here is the script I am using:
local upper = 0.90
local lower = 0.10
isError=0
function detectDevice(DeviceName)
DeviceSide="none"
for k,v in pairs(redstone.getSides()) do
if peripheral.getType(v)==DeviceName then
DeviceSide = v
break
end
end
return(DeviceSide)
end
cell="none"
monitor="none"
local peripheralList = peripheral.getNames()
CellSide=detectDevice("cofh_thermalexpansion_energycell")
if CellSide~="none" then
cell=peripheral.wrap(CellSide)
print ("Thermal Expansion Energy Cell on the " .. CellSide .. " connected.")
else
CellSide=detectDevice("tile_enderio_blockcapacitorbank_name")
if CellSide~="none" then
cell=peripheral.wrap(CellSide)
print ("EnderIO Capacitor Bank on the " .. CellSide .. " connected.")
else
for Index = 1, #peripheralList do
if string.find(peripheralList[Index], "cofh_thermalexpansion_energycell") then
cell=peripheral.wrap(peripheralList[Index])
print ("Thermal Expansion Energy Cell on wired modem: "..peripheralList[Index].." connected.")
elseif string.find(peripheralList[Index], "tile_enderio_blockcapacitorbank_name") then
cell=peripheral.wrap(peripheralList[Index])
print ("EnderIO Capacitor Bank on wired modem: "..peripheralList[Index].." connected.")
end
end
if cell == "none" then
print("No Energy storage found. Halting Program!")
return
end
end
end
MonitorSide=detectDevice("monitor")
if MonitorSide~="none" then
monitor=peripheral.wrap(MonitorSide)
print ("Monitor on the " .. MonitorSide .. " connected.")
else
for Index = 1, #peripheralList do
if string.find(peripheralList[Index], "monitor") then
monitor=peripheral.wrap(peripheralList[Index])
print ("Monitor on wired modem: "..peripheralList[Index].." connected.")
end
end
if monitor == "none" then
print ("Warning - No Monitor attached, continuing without.")
end
end
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.clear()
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
while true do
eNow = cell.getEnergyStored("unknown")
eMax = cell.getMaxEnergyStored("unknown")
fill = (eNow / eMax)
if monitor ~= "none" then
monitor.setCursorPos(11,2)
monitor.write(" Current Power:")
monitor.setCursorPos(11,3)
monitor.write(tostring(eNow))
monitor.setCursorPos(11,4)
monitor.write(" Out Of:")
monitor.setCursorPos(11,5)
monitor.write(tostring(eMax))
end
monitor.setCursorPos(1,2)
monitor.write("UNDER HALF")
monitor.setCursorPos(1,3)
monitor.write("OR LESS?")
end
if fill > upper then
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
elseif fill < lower then
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
sleep(1)
end
local upper = 0.90
local lower = 0.10
isError=0
function detectDevice(DeviceName)
DeviceSide="none"
for k,v in pairs(redstone.getSides()) do
if peripheral.getType(v)==DeviceName then
DeviceSide = v
break
end
end
return(DeviceSide)
end
cell="none"
monitor="none"
local peripheralList = peripheral.getNames()
CellSide=detectDevice("cofh_thermalexpansion_energycell")
if CellSide~="none" then
cell=peripheral.wrap(CellSide)
print ("Thermal Expansion Energy Cell on the " .. CellSide .. " connected.")
else
CellSide=detectDevice("tile_enderio_blockcapacitorbank_name")
if CellSide~="none" then
cell=peripheral.wrap(CellSide)
print ("EnderIO Capacitor Bank on the " .. CellSide .. " connected.")
else
for Index = 1, #peripheralList do
if string.find(peripheralList[Index], "cofh_thermalexpansion_energycell") then
cell=peripheral.wrap(peripheralList[Index])
print ("Thermal Expansion Energy Cell on wired modem: "..peripheralList[Index].." connected.")
elseif string.find(peripheralList[Index], "tile_enderio_blockcapacitorbank_name") then
cell=peripheral.wrap(peripheralList[Index])
print ("EnderIO Capacitor Bank on wired modem: "..peripheralList[Index].." connected.")
end
end
if cell == "none" then
print("No Energy storage found. Halting Program!")
return
end
end
end
MonitorSide=detectDevice("monitor")
if MonitorSide~="none" then
monitor=peripheral.wrap(MonitorSide)
print ("Monitor on the " .. MonitorSide .. " connected.")
else
for Index = 1, #peripheralList do
if string.find(peripheralList[Index], "monitor") then
monitor=peripheral.wrap(peripheralList[Index])
print ("Monitor on wired modem: "..peripheralList[Index].." connected.")
end
end
if monitor == "none" then
print ("Warning - No Monitor attached, continuing without.")
end
end
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.clear()
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
while true do
eNow = cell.getEnergyStored("unknown")
eMax = cell.getMaxEnergyStored("unknown")
fill = (eNow / eMax)
if monitor ~= "none" then
monitor.setCursorPos(11,2)
monitor.write(" Current Power:")
monitor.setCursorPos(11,3)
monitor.write(tostring(eNow))
monitor.setCursorPos(11,4)
monitor.write(" Out Of:")
monitor.setCursorPos(11,5)
monitor.write(tostring(eMax))
end
monitor.setCursorPos(1,2)
monitor.write("UNDER HALF")
monitor.setCursorPos(1,3)
monitor.write("OR LESS?")
end
if fill > upper then
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
elseif fill < lower then
redstone.setOutput("back", false)
if monitor ~= "none" then
monitor.setBackgroundColour((colours.green))
monitor.setCursorPos(1,4)
monitor.write(" YES ")
monitor.setBackgroundColour((colours.grey))
monitor.setCursorPos(5,4)
monitor.write(" NO ")
monitor.setBackgroundColour((colours.black))
end
sleep(1)
end