im trying to make a clock to turn on rp lights at certain times
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
plz help!
Started by doodle9008, 02 January 2013 - 05:41 PMPosted 02 January 2013 - 06:41 PM
http://pastebin.com/upNsut8z
im trying to make a clock to turn on rp lights at certain times
im trying to make a clock to turn on rp lights at certain times
Posted 02 January 2013 - 07:12 PM
You need another end at the end of the file.
Posted 02 January 2013 - 07:13 PM
the code runs just never turns the lamp on at 12
Posted 02 January 2013 - 07:59 PM
Try changing it to if time == 12 then
Posted 02 January 2013 - 08:14 PM
nope the program runs but when the clock hits 12 it doesn't turn the light on
Posted 02 January 2013 - 09:41 PM
Try putting quotes around 12:00.
Posted 02 January 2013 - 10:00 PM
As brett says, try using quotes (it will work because time is a string, not a number) but you will also need to add AM or PM. if you want it to change at every 12 then try this:
-- You only need to wrap and set the scale of the monitor once
m = peripheral.wrap("left")
m.setTextScale(1)
m.clear()
while true do
m.setCursorPos(1,1)
m.clearLine()
time = textutils.formatTime (os.time(), false)
m.write(time)
if string.sub(time, 1, string.find(time, ":")-1) == "12" then
rs.setBundledOutput("back", 1)
end
sleep(1)
end
Posted 02 January 2013 - 10:05 PM
Woah. I just learned something new with strings in that if statement you made there. Never really bothered learning the.. String API, is it?As brett says, try using quotes (it will work because time is a string, not a number) but you will also need to add AM or PM. if you want it to change at every 12 then try this:-- You only need to wrap and set the scale of the monitor once m = peripheral.wrap("left") m.setTextScale(1) m.clear() while true do m.setCursorPos(1,1) m.clearLine() time = textutils.formatTime (os.time(), false) m.write(time) if string.sub(time, 1, string.find(time, ":")-1) == "12" then rs.setBundledOutput("back", 1) end sleep(1) end
Posted 02 January 2013 - 10:07 PM
Woah. I just learned something new with strings in that if statement you made there. Never really bothered learning the.. String API, is it?
Yeah, it's very, very useful :D/>
Posted 02 January 2013 - 10:10 PM
I see, but whenever I see someone use it, it looks so complicated. That's why I've never bothered looking at it. I should probably learn now, may come in handy for my Siri program I'm making. :P/>Woah. I just learned something new with strings in that if statement you made there. Never really bothered learning the.. String API, is it?
Yeah, it's very, very useful :D/>