I have built a little house that on the ceiling there are pistons that move the ceiling and lights around.
I wanted to make it that when it's day a certain program will run, that turns the lights on and when it is night I want them to be turned off. Now see if you keep up with me as it gets a bit messy…
I have made the on and off programs and they will make the lights go on and off. The Program names are called: "on" and "off".
My computer has 3 transmitter blocks 1 on the left, 1 on the back, and 1 on the right, that the on/off programmes use to control the pistons on the house. I then have a day light sensor on the top of the computer. Now I wanted to know how to make a program that will use the daylights sensors input ("true"/"false") to control the lights. I have made a simple test program which is as follows:
local solar = rs.getInput("top")
print(solar)
if solar == true then
shell.run("off")
else
shell.run("on")
end
Now this works…to an extent. I have to keep restarting it at day/night for it to do it automatically.The problem is if the "on" or "off" programmes run more than once and its the same value:
EXAMPLE:
If you run the "on" program twice then it will keep moving the pistons around then when it's set to on, if the program is run again it will reset the pistons then set them to on again, which makes lots of noise.
I want the program to literally say, hey guess what?! It's daytime, lets turn off the lights! but then the program keeps running until night time comes and then it literally says, hey guess what?! it's night time, lets turn the lights on!. And this will run forever and ever! but it just can't keep making the "on"/"off" programs constantly running, and it needs to run it once in the day to turn off and once in the night to turn the lights on.
If anyone can help I will be hugely thankful!!
If you don't understand it then I will give you my IP so you can connect :D/>
Just email me as it will come straight to my phone:
danny.smc95@gmail.com
Thanks :)/>