if not term.isColor() then
  print("Advanced computer required")
  error()
end

local sides = peripheral.getNames()
local cloakingCore
for _, side in pairs(sides) do
  if peripheral.getType(side) == "warpdriveCloakingCore" then
    print("Wrapping " .. side)
    cloakingCore = peripheral.wrap(side)
    break
  end
end


if cloakingCore == nil or cloakingCore.interfaced() == nil then
  term.setBackgroundColor(colors.red)
  term.setTextColor(colors.white)
  term.write("No cloaking core detected")
else
  cloakingCore.tier(2)
  cloakingCore.enable(true)
  local isValid, message = cloakingCore.isAssemblyValid()
  if isValid then
    term.setBackgroundColor(colors.lime)
    term.setTextColor(colors.red)
    term.write("Tier 2 cloaking is enabled")
  else
    term.setBackgroundColor(colors.red)
    term.setTextColor(colors.white)
    print(message)
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    print()
    print("In each of the 6 directions, you need to place exactly 2 Cloaking coils, for a total of 12 coils.")
    print("The 6 inner coils shall be exactly one block away from the core.")
    print("The cloaking field will extend 5 blocks past the outer 6 coils.")
    print("Power consumption scales with the amount of cloaked blocks.")
  end
end

term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)

print()
print()
-- print("Program closed")
