Advertisement
BigBlow_

Time-Controll-EternalDay-ModularRouter_Arsnouveau

Mar 8th, 2025 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. -- Simple clock with Redstone signal at 18:10
  2.  
  3. -- Configuration
  4. local sideRedstone = "top" -- The side that will emit the redstone signal
  5. local signalDuration = 3 -- Duration of the signal in seconds
  6. local sideDisable = "right" -- The side that disables the program
  7.  
  8. -- Main function
  9. while true do
  10. -- Clear the screen
  11. term.clear()
  12. term.setCursorPos(1, 1)
  13.  
  14. -- Get the in-game time and format it correctly
  15. local gameTime = os.time()
  16. local formattedTime = textutils.formatTime(gameTime, true)
  17. local day = "Day " .. os.day()
  18.  
  19. -- Display the information
  20. print("=========================")
  21. print(" MINECRAFT CLOCK ")
  22. print("=========================")
  23. print("")
  24. print("Time: " .. formattedTime)
  25. print("Date: " .. day)
  26. print("")
  27. print("=========================")
  28.  
  29. -- Check if a redstone signal is received on the right side
  30. if redstone.getInput(sideDisable) then
  31. print("Program disabled by redstone signal on the right side.")
  32. -- Do nothing, redstone is disabled
  33. else
  34. -- Check if the time is around 18:00 to 18:10
  35. if gameTime >= 18.000 and gameTime < 18.200 then
  36. print("\nIt is 18:10 in the game! Activating redstone...")
  37.  
  38. -- Check if the Redstone peripheral exists
  39. if redstone.getOutput(sideRedstone) ~= nil then
  40. -- Activate redstone
  41. redstone.setOutput(sideRedstone, true)
  42. sleep(signalDuration) -- Keep the signal active
  43. redstone.setOutput(sideRedstone, false)
  44.  
  45. print("Redstone deactivated. Waiting for the next cycle...")
  46. sleep(10) -- Avoid multiple activations too close together
  47. else
  48. print("ERROR: Unable to send redstone signal on '" .. sideRedstone .. "'")
  49. print("Make sure the PC is properly connected to redstone!")
  50. end
  51. end
  52. end
  53.  
  54. -- Wait before refreshing (1 second)
  55. sleep(1)
  56. end
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement