Posted 08 September 2012 - 01:12 AM
Hi im new to computercraft iv learned alot in the 2 days iv been using it but after these days of trawling tutorials and forums i still cant get my first real program to work i would greatly appreciate any help the pros's can offer.
What i am tying to accomplish is to have some redpower frame doors close over my solar arrays at night and open again during the day.
my day/night input is from a RP2 light sensor
i have wrote 2 simple programs to open and close the doors which both work when activated alone.
i have tryd 2 sets of code plz let me know which would/could work or if im totally off an example of how to do this would be nice
first code
loop = 1
while (loop == 1) do
input = rs.getInput ("top") – top is lightsensor true is day
if (input == "false") then
shell.run ("sdc") – doors close prog
loop = 2
else
shell.run ("sdo") – doors open prog
end
end
Second code
if rs.getInput ("top") == true then
shell.run ("sdo")
end
if rs.getinput ("top") == false then
shell.run ("sdc")
end
the second code works when i manually run it, so im thinking its my absolute noobishness when it comes to loops that is the problem
What i am tying to accomplish is to have some redpower frame doors close over my solar arrays at night and open again during the day.
my day/night input is from a RP2 light sensor
i have wrote 2 simple programs to open and close the doors which both work when activated alone.
i have tryd 2 sets of code plz let me know which would/could work or if im totally off an example of how to do this would be nice
first code
loop = 1
while (loop == 1) do
input = rs.getInput ("top") – top is lightsensor true is day
if (input == "false") then
shell.run ("sdc") – doors close prog
loop = 2
else
shell.run ("sdo") – doors open prog
end
end
Second code
if rs.getInput ("top") == true then
shell.run ("sdo")
end
if rs.getinput ("top") == false then
shell.run ("sdc")
end
the second code works when i manually run it, so im thinking its my absolute noobishness when it comes to loops that is the problem