View difference between Paste ID: JxxHMdkE and iwS1b6sn
SHOW: | | - or go back to the newest paste.
1
if(fs.exists("conf") == false) then
2
	shell.run("pastebin get jtu7T4Ri conf")
3
	term.clear()
4
end
5
local shield = peripheral.find("warpdriveForceFieldProjector")
6
local laser = peripheral.find("warpdriveLaserCamera")
7-
---
7+
local lever = "front" -- format: front,back,left,right,top,bottom ONLY
8
-- Sets the frequency of the laser to 1420
9-
--- this function is really janky but I don't want to make it better
9+
10
 
11
-- initial message
12
print("Control System Online, Toggle Redstone To Toggle Shields, Press C to Configure")
13
 
14
15
local _, upgrades = shield.getUpgrades()
16
17
function getRange()
18
    if upgrades:match("1/4 x Range") then
19
        return 1
20
    elseif upgrades:match("2/4 x Range") then
21
        return 2
22
    elseif upgrades:match("3/4 x Range") then
23
        return 3
24
    elseif upgrades:match("4/4 x Range") then
25
        return 4
26-
    while true do
26+
27-
  -- Waits for a "laserScanning" event
27+
28-
  os.pullEvent("laserScanning")
28+
29-
    local type, lx, ly, lz, block = laser.getScanResult()
29+
30
31-
    tx = (lx-fx) / Size
31+
32-
    ty = (ly-fy) / Size
32+
33-
    tz = (lz-fz) / Size
33+
while true do
34-
    print(tx, ty, tz)
34+
    os.sleep(0.5)
35-
shield.translation(tx, ty, tz)
35+
    local event, key = os.pullEvent()
36
    if event == "redstone" then
37-
    
37+
        local on = redstone.getAnalogInput(lever)
38-
    
38+
        if on > 6 then
39
            shield.enable(false)
40
41
        elseif on < 5 then
42
            shield.enable(true)
43
44
        end
45
    elseif event == "key" then
46
        -- keys are represented by numbers, the number for 'C' is 46
47
        if key == 46 then
48
            print("C key pressed, running 'conf' script...")
49
            shell.run("conf")
50
        end
51
    elseif event == "laserScanning" then
52
        local type, lx, ly, lz, block = laser.getScanResult()
53
        local fx, fy, fz = shield.getLocalPosition()
54
        tx = (lx-fx) / Size
55
        ty = (ly-fy) / Size
56
        tz = (lz-fz) / Size
57
        shield.translation(tx, ty, tz)
58
    end
59
end
60