Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Computercraft Computer script by Scott 'Satscape' Hather
- -- this will display the current Minecraft time
- -- along with a weather report
- -- It will require a world sensor placing into your world and a sensor controller
- -- attaching to your computer. Optional: large monitor to display this data.
- os.unloadAPI ("sensors")
- os.loadAPI ("/rom/apis/sensors")
- conside = sensors.getController() --what side is the controller on
- sens = sensors.getSensors(conside)
- weatherSensor = sens[1] -- The first sensor (if you have more, change this)
- probes = sensors.getProbes(conside,weatherSensor)
- areaProbe = probes[2]
- targets = sensors.getAvailableTargetsforProbe(conside,weatherSensor,areaProbe)
- target=targets[1]
- sensors.setTarget(conside,weatherSensor,target)
- m=peripheral.wrap("right") -- monitor is to the right
- m.setTextScale(3) -- scale is 1 to 5, set to 3
- while true do -- use control T to terminate this infinite loop
- rs.setOutput("top",true) --Turn on redstone light above
- term.clear()
- -- GET THE TIME STUFF
- mins=os.time() % 1
- mins=mins*60
- theTime=string.format("%02d:%02d", math.floor(os.time()), mins) -- FORMAT THE TIME
- if os.time() >18 then
- theTime2 ="Evening"
- elseif os.time() >17 then
- theTime2 = "Sunset"
- elseif os.time() >12 then
- theTime2 = "Afternoon"
- elseif os.time() >5 then
- theTime2 = "Morning"
- elseif os.time() >4 then
- theTime2 = "Sunrise"
- else
- theTime2 = "Late night"
- end
- -- READ FROM PROBE
- reading=sensors.getSensorReadingAsDict(conside,weatherSensor,target,areaProbe)
- raining=reading.isRaining
- thunder=reading.isThunderStorm
- if thunder then
- theWeather="Thunder"
- elseif raining then
- theWeather="Rain"
- else
- if reading.isDaytime then
- theWeather="Sunshine"
- else
- theWeather="Clear skies"
- end
- end
- -- DISPLAY EVERYTHING
- term.setCursorPos(1,2)
- print("Time");
- term.setCursorPos(10,2)
- print(theTime)
- term.setCursorPos(10,3)
- print(theTime2)
- term.setCursorPos(1,5)
- print("Weather")
- term.setCursorPos(10,5)
- print(theWeather)
- sleep(10) -- no need to hammer this script, take it easy, have a nap.
- rs.setOutput("top",false) -- turn off the redstone light
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment