infiniteblock

Untitled

Nov 7th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. if warpdriveCommons then os.unloadAPI("warpdriveCommons") end
  2. if not os.loadAPI("warpdrive/warpdriveCommons") then error("missing warpdriveCommons") end
  3. local w = warpdriveCommons.w
  4.  
  5. local data
  6.  
  7. ----------- Ship support
  8.  
  9. local ship
  10. local ship_front = 0
  11. local ship_right = 0
  12. local ship_up = 0
  13. local ship_back = 0
  14. local ship_left = 0
  15. local ship_down = 0
  16. local ship_isInHyper = false
  17. local ship_x, ship_y, ship_z = 0, 0, 0
  18. local ship_xTarget, ship_yTarget, ship_zTarget = 0, 0, 0
  19. local ship_actualDistance = 0
  20. local ship_energyRequired = 0
  21. local ship_movement = { 0, 0, 0 }
  22. local ship_rotationSteps = 0
  23. local ship_indexPlayer = 0
  24. local ship_arrayPlayers = { }
  25. local ship_indexTarget = 0
  26.  
  27. function ship_read(parData)
  28.   data = parData
  29. end
  30.  
  31. function ship_name(parName)
  32.   if ship == nil or ship.isInterfaced() == nil then
  33.     return ''
  34.   end
  35.   return ship.name(parName)
  36. end
  37.  
  38. function ship_boot()
  39.   if ship == nil or ship.isInterfaced() == nil then
  40.     return
  41.   end
  42.  
  43.   w.setColorNormal()
  44.   w.writeLn("Booting Ship")
  45.  
  46.   w.write("- acquiring parameters: ")
  47.   ship_front, ship_right, ship_up = ship.dim_positive()
  48.   ship_back, ship_left, ship_down = ship.dim_negative()
  49.   ship_isInHyper = ship.isInHyperspace()
  50.   ship_movement = { ship.movement() }
  51.   ship_rotationSteps = ship.rotationSteps()
  52.   w.setColorSuccess()
  53.   w.writeLn("ok")
  54.  
  55.   w.setColorNormal()
  56.   w.write("- checking assembly   : ")
  57.   local timeout = 10
  58.   local isValid, message
  59.   repeat
  60.     isValid, message = ship.getAssemblyStatus()
  61.     w.sleep(0.05)
  62.     timeout = timeout - 1
  63.   until isValid == true or timeout < 0
  64.   if timeout < 0 then
  65.     w.setColorWarning()
  66.     w.writeLn("failed")
  67.     w.writeLn(message)
  68.     w.setColorNormal()
  69.     w.sleep(6)
  70.     -- don't reboot as the player might need to set new dimensions to fix it
  71.   else
  72.     w.setColorSuccess()
  73.     w.writeLn("passed")
  74.   end
  75.   w.sleep(0.2)
  76.  
  77.   w.setColorNormal()
  78.   w.write("- celestial position  : ")
  79.   timeout = 10
  80.   local pos
  81.   repeat
  82.     pos = ship.getLocalPosition()
  83.     w.sleep(0.05)
  84.     timeout = timeout - 1
  85.   until pos ~= nil or timeout < 0
  86.   if timeout < 0 then
  87.     w.setColorWarning()
  88.     w.writeLn("failed")
  89.     w.writeLn("")
  90.     w.writeLn("Something is wrong here, rebooting...")
  91.     w.setColorNormal()
  92.     w.sleep(2)
  93.     w.reboot()
  94.   else
Advertisement
Add Comment
Please, Sign In to add comment