Advertisement
zodiak707

Sensor MK1

Jan 1st, 2021 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. if not term.isColor() then
  2. print("Advanced computer required")
  3. end
  4.  
  5. local sides = peripheral.getNames()
  6. local sensors = {}
  7. for _, side in pairs(sides) do
  8. if peripheral.getType(side) == "warpdriveEnvironmentalSensor" then
  9. print("Wrapping "..side)
  10. table.insert(sensors, peripheral.wrap(side))
  11. end
  12. end
  13.  
  14. local sensorsConnected = true
  15. if #sensors == 0 then
  16. term.setBackgroundColor(colors.blue)
  17. term.setTextColor(colors.white)
  18. print("No environmental sensor found!")
  19.  
  20. sensorsConnected = false
  21. end
  22.  
  23. if sensorsConnected then
  24. local isRunning = true
  25. repeat
  26. for key, sensor in pairs(sensors) do
  27. local isSuccessWeather, currentWeather, secondLeft = sensor.getWeather()
  28. local isSuccessTime, day, hourDay, minuteDay, secondWorld = sensor.getWorldTime()
  29. local isSuccessTemperature, biomeTemperatureCategory, temperaturVal = sensor.getTemperature()
  30. local isSuccessHumidity, humidity, biomeRainfall = sensor.getHumidity()
  31. local isSuccessBiome, biomeName, biomeTag1, biomeTag2 = sensor.getBiome()
  32. local isSuccessAtmosphere, isBreathable, airConcentration = sensor.getAtmosphere()
  33.  
  34. term.clear()
  35. term.setCursorPos(1, 1)
  36. term.setBackgroundColor(colors.black)
  37. term.setTextColor(colors.white)
  38.  
  39. print("World Time")
  40. print(" - Days: "..day)
  41. print(" - Time: "..hourDay..":"..minuteDay)
  42. print("Biome")
  43. print(" - Name: "..biomeName)
  44. if(biomeTag1 ~= nil) then
  45. print(" - Tag 1: "..biomeTag1)
  46. end
  47. if(biomeTag2 ~= nil) then
  48. print(" - Tag 2: "..biomeTag2)
  49. end
  50. print("Atmosphere")
  51. if(isBreathable) then
  52. print(" - Breathable: Yes")
  53. else
  54. print(" - Breathable: No")
  55. end
  56. print(" - Air Concentration: "..airConcentration)
  57. print("Weather")
  58. print(" - Current: "..currentWeather)
  59. print(" - Next Change in: "..secondLeft)
  60. print(" - Humidity: "..humidity)
  61. print(" - Rainfall: "..biomeRainfall)
  62. print(" - Temperatur: "..math.floor((temperaturVal*100)).."°c")
  63. print(" - Temp. Category: "..biomeTemperatureCategory)
  64. end
  65. os.sleep(1)
  66. until not isRunning
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement