This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
doodle9008's profile picture

plz help!

Started by doodle9008, 02 January 2013 - 05:41 PM
doodle9008 #1
Posted 02 January 2013 - 06:41 PM
http://pastebin.com/upNsut8z
im trying to make a clock to turn on rp lights at certain times
zekesonxx #2
Posted 02 January 2013 - 07:12 PM
You need another end at the end of the file.
doodle9008 #3
Posted 02 January 2013 - 07:13 PM
the code runs just never turns the lamp on at 12
remiX #4
Posted 02 January 2013 - 07:59 PM
Try changing it to if time == 12 then
doodle9008 #5
Posted 02 January 2013 - 08:14 PM
nope the program runs but when the clock hits 12 it doesn't turn the light on
brett122798 #6
Posted 02 January 2013 - 09:41 PM
Try putting quotes around 12:00.
remiX #7
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
brett122798 #8
Posted 02 January 2013 - 10:05 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
Woah. I just learned something new with strings in that if statement you made there. Never really bothered learning the.. String API, is it?
remiX #9
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/>
brett122798 #10
Posted 02 January 2013 - 10:10 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/>
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/>