diff --git a/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/disable b/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/disable index 42c17158..768efee0 100644 --- a/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/disable +++ b/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/disable @@ -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") diff --git a/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/enable b/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/enable index 0f09dabb..73204f5e 100644 --- a/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/enable +++ b/src/main/resources/assets/warpdrive/lua.ComputerCraft/warpdriveForceFieldProjector/enable @@ -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)