#cctweaked — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #cctweaked, aggregated by home.social.
-
Big fan of this one, Chat. Made this cute kiosk program that tells you the in-game time, the day of your world, says Hi, and the current Weather.
This uses the mods CC: Tweaked, for the computer and Advanced Peripherals for the Environment Detector which reports on the weather.
Technically, it's possible to tell the current weather using the Daylight Detector because the computer can measure the redstone strength based on the light level. But it was complicated, required a lot of space, I found it difficult to calculate the sine wave of light level compared to current weather while also calculating the daylight compared to the time of day and somehow calculating that.
It's possible for sure but I'm not good enough at maths to understand it.
Anyway here's the code:local monitor = peripheral.find("monitor") function flash_line(text, background_colour, text_colour) local line_length, _ = monitor.getSize() local current_text_colour = monitor.getTextColour() local current_background_colour = monitor.getBackgroundColour() local current_x, current_y = monitor.getCursorPos() monitor.clearLine() monitor.setTextColour(text_colour) for i = 1, 3 do -- Flash half monitor.setBackgroundColour(background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) -- Flash second-half monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) end monitor.setTextColour(current_text_colour) monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(current_x, current_y) monitor.clearLine() end if not monitor then print("Could not find monitor.") return end local is_raining = false local raining_start = 0 local is_sunny = false local sunny_start = 0 local is_thunder = false local thunder_start = 0 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.clear() while(true) do local env = peripheral.find("environment_detector") local time = os.time() local day = os.day() local greeting local day_stat = "Day: " .. day local screen_width, screen_height = monitor.getSize() local distance_from_right = screen_width - day_stat:len() + 1 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.setCursorPos(1,1) monitor.clearLine() monitor.write(textutils.formatTime(time)) monitor.setCursorPos(distance_from_right,1) monitor.write(day_stat) monitor.setCursorPos(1,2) monitor.clearLine() if time < 12.0 then monitor.write("Good ") monitor.setTextColour(colours.magenta) monitor.write("morning.") elseif time < 19.0 then monitor.write("Good ") monitor.setTextColour(colours.yellow) monitor.write("afternoon.") else monitor.write("Good ") monitor.setTextColour(colours.orange) monitor.write("evening.") end if env then monitor.setCursorPos(1,4) monitor.clearLine() monitor.setTextColour(colours.lime) monitor.write("Today's Weather:") monitor.setCursorPos(1,5) -- It just started sunny. if env.isSunny() and not is_sunny then -- The timer is the computer uptime. sunny_start = os.epoch("utc") is_sunny = true flash_line("!", colours.white, colours.black) elseif not env.isSunny() then -- Set state to false and reset start time. is_sunny = false sunny_start = 0 end -- It just started raining. if env.isRaining() and not is_raining then -- The timer is the computer uptime. raining_start = os.epoch("utc") is_raining = true flash_line("!", colours.yellow, colours.black) elseif not env.isRaining() then -- Set state to false and reset start time. is_raining = false raining_start = 0 end -- It just started thundering. if env.isThunder() and not is_thunder then -- The timer is the computer uptime. thunder_start = os.epoch("utc") is_thunder = true flash_line("!", colours.red, colours.black) elseif not env.isThunder() then -- Set state to false and reset start time. is_thunder = false thunder_start = 0 end if is_thunder then local thunder_time = (os.epoch("utc") - thunder_start) / 1000 local weather_report = "Thundering for: " .. os.date("!%T", thunder_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_raining then local raining_time = (os.epoch("utc") - raining_start) / 1000 local weather_report = "Raining for: " .. os.date("!%T", raining_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_sunny then local sunny_time = (os.epoch("utc") - sunny_start) / 1000 local weather_report = "Sunny for: " .. os.date("!%T", sunny_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) end end sleep(0.1) end
#minecraft #ComputerCraft #CCtweaked -
Big fan of this one, Chat. Made this cute kiosk program that tells you the in-game time, the day of your world, says Hi, and the current Weather.
This uses the mods CC: Tweaked, for the computer and Advanced Peripherals for the Environment Detector which reports on the weather.
Technically, it's possible to tell the current weather using the Daylight Detector because the computer can measure the redstone strength based on the light level. But it was complicated, required a lot of space, I found it difficult to calculate the sine wave of light level compared to current weather while also calculating the daylight compared to the time of day and somehow calculating that.
It's possible for sure but I'm not good enough at maths to understand it.
Anyway here's the code:local monitor = peripheral.find("monitor") function flash_line(text, background_colour, text_colour) local line_length, _ = monitor.getSize() local current_text_colour = monitor.getTextColour() local current_background_colour = monitor.getBackgroundColour() local current_x, current_y = monitor.getCursorPos() monitor.clearLine() monitor.setTextColour(text_colour) for i = 1, 3 do -- Flash half monitor.setBackgroundColour(background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) -- Flash second-half monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) end monitor.setTextColour(current_text_colour) monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(current_x, current_y) monitor.clearLine() end if not monitor then print("Could not find monitor.") return end local is_raining = false local raining_start = 0 local is_sunny = false local sunny_start = 0 local is_thunder = false local thunder_start = 0 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.clear() while(true) do local env = peripheral.find("environment_detector") local time = os.time() local day = os.day() local greeting local day_stat = "Day: " .. day local screen_width, screen_height = monitor.getSize() local distance_from_right = screen_width - day_stat:len() + 1 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.setCursorPos(1,1) monitor.clearLine() monitor.write(textutils.formatTime(time)) monitor.setCursorPos(distance_from_right,1) monitor.write(day_stat) monitor.setCursorPos(1,2) monitor.clearLine() if time < 12.0 then monitor.write("Good ") monitor.setTextColour(colours.magenta) monitor.write("morning.") elseif time < 19.0 then monitor.write("Good ") monitor.setTextColour(colours.yellow) monitor.write("afternoon.") else monitor.write("Good ") monitor.setTextColour(colours.orange) monitor.write("evening.") end if env then monitor.setCursorPos(1,4) monitor.clearLine() monitor.setTextColour(colours.lime) monitor.write("Today's Weather:") monitor.setCursorPos(1,5) -- It just started sunny. if env.isSunny() and not is_sunny then -- The timer is the computer uptime. sunny_start = os.epoch("utc") is_sunny = true flash_line("!", colours.white, colours.black) elseif not env.isSunny() then -- Set state to false and reset start time. is_sunny = false sunny_start = 0 end -- It just started raining. if env.isRaining() and not is_raining then -- The timer is the computer uptime. raining_start = os.epoch("utc") is_raining = true flash_line("!", colours.yellow, colours.black) elseif not env.isRaining() then -- Set state to false and reset start time. is_raining = false raining_start = 0 end -- It just started thundering. if env.isThunder() and not is_thunder then -- The timer is the computer uptime. thunder_start = os.epoch("utc") is_thunder = true flash_line("!", colours.red, colours.black) elseif not env.isThunder() then -- Set state to false and reset start time. is_thunder = false thunder_start = 0 end if is_thunder then local thunder_time = (os.epoch("utc") - thunder_start) / 1000 local weather_report = "Thundering for: " .. os.date("!%T", thunder_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_raining then local raining_time = (os.epoch("utc") - raining_start) / 1000 local weather_report = "Raining for: " .. os.date("!%T", raining_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_sunny then local sunny_time = (os.epoch("utc") - sunny_start) / 1000 local weather_report = "Sunny for: " .. os.date("!%T", sunny_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) end end sleep(0.1) end
#minecraft #ComputerCraft #CCtweaked -
Big fan of this one, Chat. Made this cute kiosk program that tells you the in-game time, the day of your world, says Hi, and the current Weather.
This uses the mods CC: Tweaked, for the computer and Advanced Peripherals for the Environment Detector which reports on the weather.
Technically, it's possible to tell the current weather using the Daylight Detector because the computer can measure the redstone strength based on the light level. But it was complicated, required a lot of space, I found it difficult to calculate the sine wave of light level compared to current weather while also calculating the daylight compared to the time of day and somehow calculating that.
It's possible for sure but I'm not good enough at maths to understand it.
Anyway here's the code:local monitor = peripheral.find("monitor") function flash_line(text, background_colour, text_colour) local line_length, _ = monitor.getSize() local current_text_colour = monitor.getTextColour() local current_background_colour = monitor.getBackgroundColour() local current_x, current_y = monitor.getCursorPos() monitor.clearLine() monitor.setTextColour(text_colour) for i = 1, 3 do -- Flash half monitor.setBackgroundColour(background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) -- Flash second-half monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) end monitor.setTextColour(current_text_colour) monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(current_x, current_y) monitor.clearLine() end if not monitor then print("Could not find monitor.") return end local is_raining = false local raining_start = 0 local is_sunny = false local sunny_start = 0 local is_thunder = false local thunder_start = 0 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.clear() while(true) do local env = peripheral.find("environment_detector") local time = os.time() local day = os.day() local greeting local day_stat = "Day: " .. day local screen_width, screen_height = monitor.getSize() local distance_from_right = screen_width - day_stat:len() + 1 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.setCursorPos(1,1) monitor.clearLine() monitor.write(textutils.formatTime(time)) monitor.setCursorPos(distance_from_right,1) monitor.write(day_stat) monitor.setCursorPos(1,2) monitor.clearLine() if time < 12.0 then monitor.write("Good ") monitor.setTextColour(colours.magenta) monitor.write("morning.") elseif time < 19.0 then monitor.write("Good ") monitor.setTextColour(colours.yellow) monitor.write("afternoon.") else monitor.write("Good ") monitor.setTextColour(colours.orange) monitor.write("evening.") end if env then monitor.setCursorPos(1,4) monitor.clearLine() monitor.setTextColour(colours.lime) monitor.write("Today's Weather:") monitor.setCursorPos(1,5) -- It just started sunny. if env.isSunny() and not is_sunny then -- The timer is the computer uptime. sunny_start = os.epoch("utc") is_sunny = true flash_line("!", colours.white, colours.black) elseif not env.isSunny() then -- Set state to false and reset start time. is_sunny = false sunny_start = 0 end -- It just started raining. if env.isRaining() and not is_raining then -- The timer is the computer uptime. raining_start = os.epoch("utc") is_raining = true flash_line("!", colours.yellow, colours.black) elseif not env.isRaining() then -- Set state to false and reset start time. is_raining = false raining_start = 0 end -- It just started thundering. if env.isThunder() and not is_thunder then -- The timer is the computer uptime. thunder_start = os.epoch("utc") is_thunder = true flash_line("!", colours.red, colours.black) elseif not env.isThunder() then -- Set state to false and reset start time. is_thunder = false thunder_start = 0 end if is_thunder then local thunder_time = (os.epoch("utc") - thunder_start) / 1000 local weather_report = "Thundering for: " .. os.date("!%T", thunder_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_raining then local raining_time = (os.epoch("utc") - raining_start) / 1000 local weather_report = "Raining for: " .. os.date("!%T", raining_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_sunny then local sunny_time = (os.epoch("utc") - sunny_start) / 1000 local weather_report = "Sunny for: " .. os.date("!%T", sunny_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) end end sleep(0.1) end
#minecraft #ComputerCraft #CCtweaked -
Big fan of this one, Chat. Made this cute kiosk program that tells you the in-game time, the day of your world, says Hi, and the current Weather.
This uses the mods CC: Tweaked, for the computer and Advanced Peripherals for the Environment Detector which reports on the weather.
Technically, it's possible to tell the current weather using the Daylight Detector because the computer can measure the redstone strength based on the light level. But it was complicated, required a lot of space, I found it difficult to calculate the sine wave of light level compared to current weather while also calculating the daylight compared to the time of day and somehow calculating that.
It's possible for sure but I'm not good enough at maths to understand it.
Anyway here's the code:local monitor = peripheral.find("monitor") function flash_line(text, background_colour, text_colour) local line_length, _ = monitor.getSize() local current_text_colour = monitor.getTextColour() local current_background_colour = monitor.getBackgroundColour() local current_x, current_y = monitor.getCursorPos() monitor.clearLine() monitor.setTextColour(text_colour) for i = 1, 3 do -- Flash half monitor.setBackgroundColour(background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) -- Flash second-half monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(1, current_y) for cursor_x = 1, line_length do monitor.write(text) end os.sleep(0.5) end monitor.setTextColour(current_text_colour) monitor.setBackgroundColour(current_background_colour) monitor.setCursorPos(current_x, current_y) monitor.clearLine() end if not monitor then print("Could not find monitor.") return end local is_raining = false local raining_start = 0 local is_sunny = false local sunny_start = 0 local is_thunder = false local thunder_start = 0 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.clear() while(true) do local env = peripheral.find("environment_detector") local time = os.time() local day = os.day() local greeting local day_stat = "Day: " .. day local screen_width, screen_height = monitor.getSize() local distance_from_right = screen_width - day_stat:len() + 1 monitor.setBackgroundColour(colours.blue) monitor.setTextColour(colours.lime) monitor.setCursorPos(1,1) monitor.clearLine() monitor.write(textutils.formatTime(time)) monitor.setCursorPos(distance_from_right,1) monitor.write(day_stat) monitor.setCursorPos(1,2) monitor.clearLine() if time < 12.0 then monitor.write("Good ") monitor.setTextColour(colours.magenta) monitor.write("morning.") elseif time < 19.0 then monitor.write("Good ") monitor.setTextColour(colours.yellow) monitor.write("afternoon.") else monitor.write("Good ") monitor.setTextColour(colours.orange) monitor.write("evening.") end if env then monitor.setCursorPos(1,4) monitor.clearLine() monitor.setTextColour(colours.lime) monitor.write("Today's Weather:") monitor.setCursorPos(1,5) -- It just started sunny. if env.isSunny() and not is_sunny then -- The timer is the computer uptime. sunny_start = os.epoch("utc") is_sunny = true flash_line("!", colours.white, colours.black) elseif not env.isSunny() then -- Set state to false and reset start time. is_sunny = false sunny_start = 0 end -- It just started raining. if env.isRaining() and not is_raining then -- The timer is the computer uptime. raining_start = os.epoch("utc") is_raining = true flash_line("!", colours.yellow, colours.black) elseif not env.isRaining() then -- Set state to false and reset start time. is_raining = false raining_start = 0 end -- It just started thundering. if env.isThunder() and not is_thunder then -- The timer is the computer uptime. thunder_start = os.epoch("utc") is_thunder = true flash_line("!", colours.red, colours.black) elseif not env.isThunder() then -- Set state to false and reset start time. is_thunder = false thunder_start = 0 end if is_thunder then local thunder_time = (os.epoch("utc") - thunder_start) / 1000 local weather_report = "Thundering for: " .. os.date("!%T", thunder_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_raining then local raining_time = (os.epoch("utc") - raining_start) / 1000 local weather_report = "Raining for: " .. os.date("!%T", raining_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) elseif is_sunny then local sunny_time = (os.epoch("utc") - sunny_start) / 1000 local weather_report = "Sunny for: " .. os.date("!%T", sunny_time) --local distance_from_right = screen_width - weather_report:len() + 1 --monitor.setCursorPos(distance_from_right,3) monitor.clearLine() monitor.write(weather_report) end end sleep(0.1) end
#minecraft #ComputerCraft #CCtweaked