View difference between Paste ID: zTJ6WFj7 and H4kALgKf
SHOW: | | - or go back to the newest paste.
1
2-
--[ABM Server, use with http://pastebin.com/aNsduCem]]--
2+
3
--[[Skynet Nuclear ABM Defense Program by Andrew2060]]--
4
--[ABM Server, use with http://pastebin.com/fZ5xeB99]]--
5
--[System requires atleast 5 CC's with Modems and ABMs]]--
6
--[System has 5% chance of failure in killing missiles]]--
7
 
8
--[[Settings]]--
9
local waitDelay = 2
10
local countersPerMissile = 1
11
local missileDelay = 3
12-
local silos, curSilo = {}, 1
12+
13
--[[Initialization]]--
14
local data, curSilo = {}, 1
15
local silos = {}
16
peripheral.find("modem", rednet.open)
17
term.setBackgroundColor(colors.blue)
18
 
19
local function red()
20
term.setBackgroundColor(colors.red)
21
print("                                                   ")
22
term.setBackgroundColor(colors.blue)
23
end
24
 
25-
	local id, msg = rednet.receive(waitDelay)
25+
26-
	if msg == "ABM" then table.insert(silos, id) end
26+
27
repeat
28
        local id, msg = rednet.receive(waitDelay)
29
        
30
        if type(msg) == "table" and msg.Msg == "ABM" then
31-
	if not redstone.getInput("back") then
31+
                table.insert(silos, msg)
32-
		term.clear()
32+
                table.insert(data, msg.ID)
33-
		term.setCursorPos(1, 1)
33+
                
34
        end
35-
		red()
35+
36-
		print("        SKYNET DEFENSE SYSTEMS ACTIVATED           ")
36+
37-
		red()
37+
38-
		print("      ANTI-BALLISTIC MISSILE SHIELD ONLINE         ")
38+
39-
		red()
39+
40-
	    red()
40+
41-
		print("               [STANDBY ABM Silos]                 ")
41+
    if not redstone.getInput("back") then
42
        term.clear()
43-
		for k, v in ipairs(silos) do print("  silo #" .. k .. " id = "..v) end
43+
        term.setCursorPos(1,1)
44
        red()
45-
		
45+
        print("        SKYNET DEFENSE SYSTEMS ACTIVATED           ")
46-
		repeat os.pullEvent("redstone") until redstone.getInput("back")
46+
47-
	end
47+
        print("      ANTI-BALLISTIC MISSILE SHIELD ONLINE         ")
48-
	
48+
49-
	term.clear()
49+
50-
	term.setCursorPos(1, 1)
50+
        print("               [STANDBY ABM Silos]                 ")
51-
	term.setTextColor(colors.red)
51+
52-
	
52+
for k, v in ipairs(silos) do
53-
	print("Incoming Missiles:")
53+
        print("[S#:".. k .."] [ID:" .. v.ID .."] [Type:".. v.Missile .. "] [Target:".. v.Target .. "]")
54-
	print("Firing CounterMeasures\n")
54+
55-
	
55+
56
       
57
        repeat os.pullEvent("redstone") until redstone.getInput("back")
58
    end
59
   
60
    term.clear()
61
    term.setCursorPos(1, 1)
62
    term.setTextColor(colors.red)
63
   
64
    print("Incoming Missiles:")
65-
		local msg = {["x"] = math.floor(maptab["x_"..i]), ["y"] = math.floor(maptab["y_"..i]), ["z"] = math.floor(maptab["z_"..i])}
65+
    print("Firing CounterMeasures\n")
66
   
67-
		print("Incoming Missile Threat #" .. i .. " at X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z)
67+
68-
		print("Launching " .. countersPerMissile .. " of ABM Missile CounterMeasures...\n")
68+
69
 if maptxt ~= "{}" then
70-
		for i = 1, countersPerMissile do
70+
71-
			rednet.send(silos[curSilo], msg)
71+
72-
			curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
72+
73-
			sleep(missileDelay)
73+
74-
			end
74+
75-
	    sleep(0)
75+
76-
		end
76+
        local msg = {["x"] = math.floor(maptab["x_"..i]), ["y"] = math.floor(maptab["y_"..i]), ["z"] = math.floor(maptab["z_"..i])}
77
 
78-
	end
78+
        print("Incoming Missile Threat #" .. i .. " at X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z)
79
        print("Launching " .. countersPerMissile .. " of ABM Missile CounterMeasures...\n")
80
 
81
        for i = 1, countersPerMissile do
82
            rednet.send(data[curSilo], msg)
83
            curSilo = (curSilo == #data) and 1 or (curSilo + 1)
84
            sleep(missileDelay)
85
            end
86
        sleep(0)
87
        end
88
     sleep(0)
89
    end
90
   sleep(2)
91
end
92
sleep(1)