Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to clear the screen and set the cursor position
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to display the header
- local function displayHeader()
- clearScreen()
- print("=== Doggy.net Weather Forecast ===")
- print("===================================")
- end
- -- Function to check if it's raining
- local function checkRain()
- return redstone.getInput("right")
- end
- -- Function to get the current time
- local function getTime()
- local time = os.date("*t") -- Get the current time table
- return string.format("%02d:%02d:%02d", time.hour, time.min, time.sec)
- end
- -- Function to display the weather forecast
- local function displayForecast()
- if checkRain() then
- return "Weather Condition: Rain detected."
- else
- return "Weather Condition: No rain detected."
- end
- end
- -- Main loop to continuously update the display
- while true do
- displayHeader()
- -- Display weather information
- print("Weather Forecast:")
- print(displayForecast())
- -- Display the current time
- print("\nCurrent Time:")
- print(getTime())
- -- Wait for a while before updating again
- sleep(1) -- Update every 1 second
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement