Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if fs.exists("conf") == false then
- shell.run("pastebin get 38M5cNbZ conf")
- term.clear()
- end
- local OffsetValue = 3
- local shield = peripheral.find("warpdriveForceFieldProjector")
- local speaker = peripheral.find("warpdriveSpeaker")
- local lever = "front"
- local safedist = 15
- print("Control System Online, Toggle Redstone To Toggle Shields, Press C to Configure")
- local _, upgrades = shield.getUpgrades()
- function getRange()
- if upgrades:match("1/4 x Range") then
- return 1
- elseif upgrades:match("2/4 x Range") then
- return 2
- elseif upgrades:match("3/4 x Range") then
- return 3
- elseif upgrades:match("4/4 x Range") then
- return 4
- elseif upgrades:match("0/4 x Range") then
- return 0
- end
- end
- Size = getRange() * 16
- -- function to update beam frequency for all the connected warpdriveLaserCamera peripherals
- local function updateLasersFrequency()
- for _, name in ipairs(peripheral.getNames()) do
- if peripheral.getType(name) == "warpdriveLaserCamera" then
- local laser = peripheral.wrap(name)
- laser.beamFrequency(1420)
- end
- end
- end
- -- function to process the scanning results from all the available lasers
- local function processScanningResults()
- for _, name in ipairs(peripheral.getNames()) do
- if peripheral.getType(name) == "warpdriveLaserCamera" then
- local type, lx, ly, lz, block = peripheral.wrap(name).getScanResult()
- lx, ly, lz = tonumber(lx), tonumber(ly), tonumber(lz)
- if lx and lx ~= 0 and ly and ly ~= 0 and lz and lz ~= 0 then
- -- the rest of your processing code goes here
- end
- end
- end
- end
- while true do
- local event, lx, ly, lz = os.pullEvent()
- if event == "key" and lx == 46 then
- print("C key pressed, running 'conf' script...")
- shell.run("conf")
- end
- if event == "laserScanning" then
- updateLasersFrequency()
- processScanningResults()
- elseif event == "redstone" then
- local _, _, _, distance = shieldOffset()
- local on = redstone.getAnalogInput(lever)
- if on > 6 and distance > safedist then
- shield.enable(true)
- elseif on > 6 and distance < safedist then
- shield.enable(false)
- print("Target is too Close! Shield Disabled!")
- elseif on < 5 then
- shield.enable(false)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement