-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoLights.lua
More file actions
31 lines (26 loc) · 1.31 KB
/
AutoLights.lua
File metadata and controls
31 lines (26 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--[[ INFO ]]--
--[[
Name: AutoLights
Version: 1.1
Date: 11/08/2013
Author: Alex Crawford
Notes: A very simple program that will check the time in Minecraft, and automatically activate any lights that are hooked up to the computer, via redstone, at certain times, and deactivates them at certain times, and print some basic info, letting you know what it's doing, when the last check was, and whether the lights are currently activated.
]]--
--[[ PROGRAM ]]--
function CheckTime() -- Checks the time, and activates/deactives the lights depending on the time. The rest of the code is pretty self explanatory, I think.
local x = os.time()
print("Checking time...")
print("Last check at: " .. textutils.formatTime(x, true) .. " (" .. textutils.formatTime(x, false) .. ")")
if os.time() > 18 or os.time() < 5 then
redstone.setOutput("back", true) -- Change "back" to whichever side the redstone is wired to.
print("Lights currently activated.")
print("")
elseif os.time() < 18 or os.time() > 5 then
redstone.setOutput("back", false) -- Change "back" to whichever side the redstone is wired to.
print("Lights currently deactivated.")
print("")
end
sleep(30) -- The length of time (30, in seconds) between each check.
CheckTime()
end
CheckTime() -- Initial CheckTime() run. Program should run perpetually after startup.