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

(Question) How do I make a solar power setup? (Read for info)

Started by Klitri, 11 April 2013 - 10:57 AM
Klitri #1
Posted 11 April 2013 - 12:57 PM
I'm Klitri, I have a quick question, I'm trying to make a little game but I need help making a solar power setup..
So basically, I want to make it so that in the day, daylight sensors will turn redstone on which gets plugged into a computer and THAT will "charge" the computer, so that at night the station will still stay lit up until the next day..

Or, to simplify that.
Daylight sensors > Redstone > Computer displays info, etc > Computer turns redstone on > Redstone turns on lights.

Sorry, I'm new to this forum, but help is greatly appretiated!
SadKingBilly #2
Posted 11 April 2013 - 01:40 PM

while true do
	os.pullEvent("redstone")
	if rs.getInput("left") then
		rs.setOutput("right", true)
	elseif not rs.getInput("left") then
		rs.setOutput("right", false)
	end
end
You'll have to change the sides to whatever sides you're using, but that should work.
Spongy141 #3
Posted 11 April 2013 - 01:48 PM
^
If your making a game, don't put that code in, since it will only detect redstone, the best (that I can think of) to do is to make that all but the while true do part into a function called what ever you want (I usually call it something like rsDetect() ) then call it at the start of the program so it will change the time to day, and have the program set an alarm until it should be minecraft night time, so that it will make the game night.
SadKingBilly #4
Posted 11 April 2013 - 01:54 PM
Wouldn't you still have to use os.pullEvent("alarm") to find out when os.setAlarm() fires its event?

Actually, I think I'm misunderstanding either you or OP.
Klitri #5
Posted 11 April 2013 - 01:55 PM
Thanks guys, it worked! :D/> CASE CLOSED