Advertisement
DOGGYWOOF

Untitled

Jul 30th, 2024 (edited)
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. -- Function to clear the screen and set the cursor position
  2. local function clearScreen()
  3. term.clear()
  4. term.setCursorPos(1, 1)
  5. end
  6.  
  7. -- Function to display the header
  8. local function displayHeader()
  9. clearScreen()
  10. print("=== Doggy.net Weather Forecast ===")
  11. print("===================================")
  12. end
  13.  
  14. -- Function to check if it's raining
  15. local function checkRain()
  16. return redstone.getInput("right")
  17. end
  18.  
  19. -- Function to get the current time
  20. local function getTime()
  21. local time = os.date("*t") -- Get the current time table
  22. return string.format("%02d:%02d:%02d", time.hour, time.min, time.sec)
  23. end
  24.  
  25. -- Function to display the weather forecast
  26. local function displayForecast()
  27. if checkRain() then
  28. return "Weather Condition: Rain detected."
  29. else
  30. return "Weather Condition: No rain detected."
  31. end
  32. end
  33.  
  34. -- Main loop to continuously update the display
  35. while true do
  36. displayHeader()
  37.  
  38. -- Display weather information
  39. print("Weather Forecast:")
  40. print(displayForecast())
  41.  
  42. -- Display the current time
  43. print("\nCurrent Time:")
  44. print(getTime())
  45.  
  46. -- Wait for a while before updating again
  47. sleep(1) -- Update every 1 second
  48. end
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement