Posted 01 December 2013 - 07:24 AM
Hej i would like to update my monitor every 3 seconds
I have copied some code:
But it don't work i don't see anything
My complete code:
I have copied some code:
os.startTimer(1)
while true do
term.setCursorPos(3,8)
term.clearLine()
m.write("Hitze: ")
m.write(nR.getHeat())
sleep(2)
os.pullEvent("timer")
os.startTimer(1)
end
But it don't work i don't see anything
My complete code:
local function padLeft(str, w)
return string.rep(" ", w - #str) .. str
end
local function findPeripheral(_type)
for _,name in pairs(peripheral.getNames()) do
if peripheral.getType(name) == _type then
return peripheral.wrap(name)
end
end
error("Fehler: ".._type.." Kann nicht gefunden werden!", 0)
end
term.clear()
m = peripheral.wrap("left")
nR = findPeripheral("nuclear_reactor")
term.redirect(m)
m.setTextScale(1)
term.setCursorPos(3,1)
m.setBackgroundColor(colors.green)
print("Ein")
term.setCursorPos(3,2)
m.setBackgroundColor(colors.red)
print("Aus")
m.setBackgroundColor(colors.black)
term.setCursorPos(3,8)
m.write("Hitze: ")
m.write(nR.getHeat())
term.setCursorPos(3,9)
m.write("Von: ")
m.write(nR.getMaxHeat())
while true do
event,side,x,y = os.pullEvent()
if event == "monitor_touch" then
if y == 1 then
term.setCursorPos(3,4)
term.clearLine()
m.setBackgroundColor(colors.green)
print(" ")
redstone.setOutput("back",true)
end
if y == 2 then
term.setCursorPos(3,4)
term.clearLine()
m.setBackgroundColor(colors.red)
print(" ")
redstone.setOutput("back",false)
end
term.setBackgroundColor(colors.black)
end
end
os.startTimer(1)
while true do
term.setCursorPos(3,8)
term.clearLine()
m.write("Hitze: ")
m.write(nR.getHeat())
sleep(2)
os.pullEvent("timer")
os.startTimer(1)
end