Automatic night lighting
You need: a computer, a Network Repeater, a Weather Station named sky and a Redstone Controller named lamps,
linked through the repeater, plus some redstone lamps.
- Place the Redstone Controller and put a redstone lamp directly south of it. Press F3 to see which way is south, or look at the arrow on the controller’s top, which points north.
- Chain more lamps with redstone dust if you like.
- Place the Weather Station anywhere nearby.
- Link both devices to the repeater and name them
skyandlampsin their forms.
Program
Section titled “Program”This is the Night lights starter:
// Starter: Night lights (computer)// Turns lamps on at night and off in the morning. Devices: a Weather Station "sky" and a Redstone Controller// "lamps" with lamps on its south side.const sky = weather.named("sky")const lamps = redstoneControllers.named("lamps")
on startup { // The south side sends power out instead of reading it in. lamps.setMode(Direction.SOUTH, PortMode.OUTPUT)}
on sky.nightStart { lamps.set(Direction.SOUTH, 15) // 15 is full power}
on sky.dayStart { lamps.set(Direction.SOUTH, 0)}How it works
Section titled “How it works”- At startup,
setModemakes the south side an output. All sides start as inputs. sky.nightStartruns at nightfall and sends full power, 15, out of the south side.sky.dayStartturns it off.
Lights for dark places
Section titled “Lights for dark places”Inside a cave or under a roof it can be dark during the day too. An Environment Sensor
measures the light itself. Name one probe, place it where the lights should help, and use:
const probe = environment.named("probe")const lamps = redstoneControllers.named("lamps")
on startup { lamps.setMode(Direction.SOUTH, PortMode.OUTPUT)}
on probe.darkened(light) { lamps.set(Direction.SOUTH, 15)}
on probe.brightened(light) { lamps.set(Direction.SOUTH, 0)}Change the light level that counts as dark with Threshold in the sensor’s form. Do not let the lamps shine on the sensor, or it will turn them off again.