Added support for wired forcefield in CC scripts

This commit is contained in:
LemADEC 2017-05-12 20:47:50 +02:00
parent af99f09fa3
commit 6ff9966d4a
2 changed files with 18 additions and 18 deletions

View file

@ -3,13 +3,13 @@ if not term.isColor() then
exit()
end
Side = { "bottom", "top", "back", "left", "right" }
for i = 1,5 do
if peripheral.getType(Side[i]) == "warpdriveForceFieldProjector" then
projector = peripheral.wrap(Side[i])
break
else
projector = nil
local sides = peripheral.getNames()
local projector
for key, side in pairs(sides) do
os.sleep(0)
local deviceType = peripheral.getType(side)
if deviceType == "warpdriveForceFieldProjector" then
projector = peripheral.wrap(side)
end
end
@ -19,8 +19,8 @@ if projector == nil then
term.write("No force field projector detected")
else
projector.enable(false)
sleep(1)
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
os.sleep(1)
local status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
term.setBackgroundColor(colors.lime)
term.setTextColor(colors.blue)
term.write("Projector is disabled")

View file

@ -3,13 +3,13 @@ if not term.isColor() then
exit()
end
Side = { "bottom", "top", "back", "left", "right" }
for i = 1,5 do
if peripheral.getType(Side[i]) == "warpdriveForceFieldProjector" then
projector = peripheral.wrap(Side[i])
break
else
projector = nil
local sides = peripheral.getNames()
local projector
for key, side in pairs(sides) do
os.sleep(0)
local deviceType = peripheral.getType(side)
if deviceType == "warpdriveForceFieldProjector" then
projector = peripheral.wrap(side)
end
end
@ -19,8 +19,8 @@ if projector == nil then
term.write("No force field projector detected")
else
projector.enable(true)
sleep(1)
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
os.sleep(1)
local status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
if isConnected then
if isPowered then
term.setBackgroundColor(colors.lime)