Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Simple clock with Redstone signal at 18:10
- -- Configuration
- local sideRedstone = "top" -- The side that will emit the redstone signal
- local signalDuration = 3 -- Duration of the signal in seconds
- local sideDisable = "right" -- The side that disables the program
- -- Main function
- while true do
- -- Clear the screen
- term.clear()
- term.setCursorPos(1, 1)
- -- Get the in-game time and format it correctly
- local gameTime = os.time()
- local formattedTime = textutils.formatTime(gameTime, true)
- local day = "Day " .. os.day()
- -- Display the information
- print("=========================")
- print(" MINECRAFT CLOCK ")
- print("=========================")
- print("")
- print("Time: " .. formattedTime)
- print("Date: " .. day)
- print("")
- print("=========================")
- -- Check if a redstone signal is received on the right side
- if redstone.getInput(sideDisable) then
- print("Program disabled by redstone signal on the right side.")
- -- Do nothing, redstone is disabled
- else
- -- Check if the time is around 18:00 to 18:10
- if gameTime >= 18.000 and gameTime < 18.200 then
- print("\nIt is 18:10 in the game! Activating redstone...")
- -- Check if the Redstone peripheral exists
- if redstone.getOutput(sideRedstone) ~= nil then
- -- Activate redstone
- redstone.setOutput(sideRedstone, true)
- sleep(signalDuration) -- Keep the signal active
- redstone.setOutput(sideRedstone, false)
- print("Redstone deactivated. Waiting for the next cycle...")
- sleep(10) -- Avoid multiple activations too close together
- else
- print("ERROR: Unable to send redstone signal on '" .. sideRedstone .. "'")
- print("Make sure the PC is properly connected to redstone!")
- end
- end
- end
- -- Wait before refreshing (1 second)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement