Advertisement
Guest User

enable

a guest
Sep 17th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. if not term.isColor() then
  2.   print("Advanced computer required")
  3.   error()
  4. end
  5.  
  6. local sides = peripheral.getNames()
  7. local projector
  8. for _, side in pairs(sides) do
  9.   os.sleep(0)
  10.   local deviceType = peripheral.getType(side)
  11.   if deviceType == "warpdriveForceFieldProjector" then
  12.     projector = peripheral.wrap(side)
  13.   end
  14. end
  15.  
  16. if projector == nil or projector.isInterfaced() ~= true then
  17.   term.setBackgroundColor(colors.red)
  18.   term.setTextColor(colors.white)
  19.   print("No force field projector detected")
  20. else
  21.   projector.enable(true)
  22.   os.sleep(1)
  23.   local status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
  24.   if isConnected then
  25.     if isPowered then
  26.       term.setBackgroundColor(colors.lime)
  27.       term.setTextColor(colors.blue)
  28.       print("Projector is enabled")
  29.     else
  30.       term.setBackgroundColor(colors.red)
  31.       term.setTextColor(colors.white)
  32.       print("Projector is missing a shape!")
  33.     end
  34.   else
  35.     term.setBackgroundColor(colors.red)
  36.     term.setTextColor(colors.white)
  37.     print("Projector is missing a beam frequency!")
  38.   end
  39. end
  40.  
  41. term.setBackgroundColor(colors.black)
  42. term.setTextColor(colors.white)
  43. print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement