function fetchPeripheral()
local names = peripheral.getNames()
local i, name
for i, name in pairs(names) do
if peripheral.getType(name) == "monitor" then
return peripheral.wrap(name)
else
return "FAILED"
end
end
end
Positions = {
"TOP_LEFT",
"TOP_RIGHT",
"BOTTOM_LEFT",
"BOTTOM_RIGHT",
"CENTER"
}
function writeText(xPos, yPos, bgd_color, txt_color, text, mon)
mon.setCursorPos(xPos, yPos)
mon.setBackgroundColor(bgd_color)
mon.setTextColor(txt_color)
mon.write(text)
end
function easyWrite(position, bgd_color, txt_color, text, mon)
xPos, yPos = mon.getSize()
textLen = string.len(text)
halfText = textLen / 2
if position == Positions[5] then
centerX = xPos/2 - halfText
centerY = yPos/2
writeText(centerX, centerY, bgd_color, txt_color, text, mon)
end
end
function drawBars(color, yPos, mon)
monX, monY = mon.getSize()
mon.setBackgroundColor(color)
mon.setCursorPos(1, yPos)
mon.write(string.rep(" ", monX))
mon.setBackgroundColor(colors.black)
end
function clearScreen(ccolor,ecolor, mon)
mon.setBackgroundColor(ccolor)
mon.clear()
mon.setBackgroundColor(ecolor)
end
function toggleRedstone(side)
if redstone.getOutput(side) then
redstone.setAnalogOutput(side, 0)
else
redstone.setAnalogOutput(side, 15)
end
end
Comments