toastonrye

EclipseTracker

Nov 13th, 2021 (edited)
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. Purpose: To remind the player that the Astral Sorcery Horologium constellation is coming.
  3. Uses CC:Tweaked and Plethora mods to track the in-game Eclipse
  4. Made with the Engimatica 2:Expert modpack for Minecraft 1.12.2
  5. Wiki says eclipse occurs every 36 days, but only after the first eclipse
  6. I found the first eclipse in my testing world occured at 34 days
  7. --]]
  8.  
  9. --Requires the Overlay Glasses, Clock & Daylight Sensor
  10. --Peripherals to be installed in the Neural Connector
  11. local interface = peripheral.wrap("back")
  12.  
  13. --Canvas to draw objects on
  14. local canvas = interface.canvas()
  15. canvas.clear()
  16.  
  17. --Group box and text objects together, all will be drawn on the canvas
  18. local iGroup = canvas.addGroup({0,50})
  19. local rect = iGroup.addRectangle(0,0,180,25, 0x00FF002F)
  20. local text = iGroup.addText({5,5}, "")
  21. local dbg = iGroup.addText({5,15}, "")
  22.  
  23. local day
  24. local nextDay = 0
  25. local eclipseFlag = 0
  26.  
  27.  
  28. while true do
  29.     day = interface.getDay()
  30.     angle = math.floor(interface.getCelestialAngle() + 0.5)
  31.     light = interface.getSkyLight()
  32.    
  33.     --Initialize variables for a new day
  34.     if day ~= nextDay then
  35.        nextDay = day
  36.        eclipseFlag = 0
  37.        rect.setColour(0x00FF002F)
  38.     end
  39.    
  40.    
  41.     if eclipseFlag == 0 then
  42.         --Sets eclipseFlag based on celestial angle and sky light
  43.         if (angle > 355 or angle < 5) then
  44.             if light <= 8 then
  45.                 text.setText("Status: Eclipse!")
  46.                 eclipseFlag = 1
  47.             end      
  48.         else
  49.             text.setText("Status: ")
  50.         end
  51.     end
  52.    
  53.     --If it's night, Horologium should be visible
  54.     if (eclipseFlag == 1 and angle > 95 and angle < 245) then
  55.         text.setText("Status: Horologium is in the sky!")
  56.         rect.setColour(0xFF0000FF)
  57.     end
  58.    
  59.     --Data for debugging
  60.     dbg.setText("A: "..angle.."  L: "..light.."  E: "..eclipseFlag.."  ND: "..nextDay)
  61.     sleep(5)
  62. end
  63.  
  64. --daysLeft = (36-day%36)
  65. --text.setText("Day: " .. day .. " | " .. daysLeft .. " Days to " .. tracker)
Add Comment
Please, Sign In to add comment