SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local component = require("component") |
| 1 | + | local component = require("component")
|
| 2 | - | local event = require("event") |
| 2 | + | local event = require("event")
|
| 3 | - | local serialization= require("serialization") |
| 3 | + | local serialization= require("serialization")
|
| 4 | - | local computer= require("computer") |
| 4 | + | local computer= require("computer")
|
| 5 | - | local modem = component.modem |
| 5 | + | local modem = component.modem |
| 6 | - | radar = component.radar |
| 6 | + | radar = component.radar |
| 7 | - | |
| 7 | + | |
| 8 | - | modem.open(2412) |
| 8 | + | modem.open(2412) |
| 9 | - | modem.broadcast(2412,"Qr= component.proxy(component.list('radar')())") |
| 9 | + | modem.broadcast(2412,"Qr= component.proxy(component.list('radar')())")
|
| 10 | - | modem.broadcast(2412,"Qn= component.proxy(component.list('navigation')())") |
| 10 | + | modem.broadcast(2412,"Qn= component.proxy(component.list('navigation')())")
|
| 11 | - | modem.broadcast(2412,"Qd= component.proxy(component.list('drone')())") |
| 11 | + | modem.broadcast(2412,"Qd= component.proxy(component.list('drone')())")
|
| 12 | - | modem.broadcast(2412,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") |
| 12 | + | modem.broadcast(2412,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") |
| 13 | - | modem.broadcast(2412,"e_coords={0,0,0} ") |
| 13 | + | modem.broadcast(2412,"e_coords={0,0,0} ")
|
| 14 | - | |
| 14 | + | |
| 15 | - | modem.broadcast(2412,"local function getEntityCoord(e_name) for k,v in ipairs(Qr.getEntities()) do if v.name == e_name then return 1 end end return 0 end") |
| 15 | + | modem.broadcast(2412,"local function getEntityCoord(e_name) for k,v in ipairs(Qr.getEntities()) do if v.name == e_name then return 1 end end return 0 end") |
| 16 | - | |
| 16 | + | |
| 17 | - | modem.open(2013) |
| 17 | + | modem.open(2013) |
| 18 | - | modem.broadcast(2013,"Sr= component.proxy(component.list('radar')())") |
| 18 | + | modem.broadcast(2013,"Sr= component.proxy(component.list('radar')())")
|
| 19 | - | modem.broadcast(2013,"Sn= component.proxy(component.list('navigation')())") |
| 19 | + | modem.broadcast(2013,"Sn= component.proxy(component.list('navigation')())")
|
| 20 | - | modem.broadcast(2013,"Sd= component.proxy(component.list('drone')())") |
| 20 | + | modem.broadcast(2013,"Sd= component.proxy(component.list('drone')())")
|
| 21 | - | modem.broadcast(2013,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") |
| 21 | + | modem.broadcast(2013,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") |
| 22 | - | |
| 22 | + | |
| 23 | - | local function sleep(timeout) checkArg(1, timeout, "number", "nil") |
| 23 | + | local function sleep(timeout) checkArg(1, timeout, "number", "nil") |
| 24 | - | local deadline = computer.uptime() + (timeout or 0) |
| 24 | + | local deadline = computer.uptime() + (timeout or 0) |
| 25 | - | repeat |
| 25 | + | repeat |
| 26 | - | computer.pullSignal(deadline - computer.uptime()) |
| 26 | + | computer.pullSignal(deadline - computer.uptime()) |
| 27 | - | until computer.uptime() >= deadline |
| 27 | + | until computer.uptime() >= deadline |
| 28 | end | |
| 29 | - | |
| 29 | + | |
| 30 | - | local Qcommand = "while true do local _,_,_port,_,brk =event.pull('modem_message') if port==2412 and brk == 'stop' then Qd.setLightColor(0xFF0000) break end Qd.setLightColor(0x00FF00) end" |
| 30 | + | local Qcommand = "while true do local _,_,_port,_,brk =event.pull('modem_message') if port==2412 and brk == 'stop' then Qd.setLightColor(0xFF0000) break end Qd.setLightColor(0x00FF00) end"
|
| 31 | - | |
| 31 | + | |
| 32 | - | local command = "while true do local evt,_,_,port,_brk =computer.pullSignal() if evt=='modem_message' and port==2413 and brk =='stop' then Qd.setLightColor(0xFF0000) break end Qd.setLightColor(0x00FF00) sleep(1) end" |
| 32 | + | local command = "while true do local evt,_,_,port,_brk =computer.pullSignal() if evt=='modem_message' and port==2413 and brk =='stop' then Qd.setLightColor(0xFF0000) break end Qd.setLightColor(0x00FF00) sleep(1) end" |
| 33 | - | |
| 33 | + | |
| 34 | - | local c = "local cmd local g=1 repeat cmd = select(6,computer.pullSignal(0.5)) Qd.setLightColor(0xFFFF00) Qd.setStatusText(\"Bingus \"..g) g=g+1 until cmd==\"stop\" Qd.setLightColor(0xFF0000) Qd.setStatusText(cmd)" |
| 34 | + | local c = "local cmd local g=1 repeat cmd = select(6,computer.pullSignal(0.5)) Qd.setLightColor(0xFFFF00) Qd.setStatusText(\"Bingus \"..g) g=g+1 until cmd==\"stop\" Qd.setLightColor(0xFF0000) Qd.setStatusText(cmd)" |
| 35 | - | |
| 35 | + | |
| 36 | - | local rad = "for k,v in ipairs(Qr.getEntities()) do if v.name == \"ph0\" then Qd.setLightColor(0x0000FF) Qd.setStatusText(v.name) end end" |
| 36 | + | local rad = "for k,v in ipairs(Qr.getEntities()) do if v.name == \"ph0\" then Qd.setLightColor(0x0000FF) Qd.setStatusText(v.name) end end" |
| 37 | - | |
| 37 | + | |
| 38 | - | local rad2 ="getE(\"ph0\") Qd.setStatusText(tostring(e_coords[1]))" |
| 38 | + | local rad2 ="getE(\"ph0\") Qd.setStatusText(tostring(e_coords[1]))" |
| 39 | - | modem.broadcast(2412,"function getE(e_name) checkArg(1,e_name,'string','nil') for k,v in ipairs(Qr.getEntities()) do if v.name == e_name then e_coords[1]=v.x e_coords[2]=v.y e_coords[3]=v.z Qd.setLightColor(0x0000FF) Qd.setStatusText(v.name) break end end end") |
| 39 | + | modem.broadcast(2412,"function getE(e_name) checkArg(1,e_name,'string','nil') for k,v in ipairs(Qr.getEntities()) do if v.name == e_name then e_coords[1]=v.x e_coords[2]=v.y e_coords[3]=v.z Qd.setLightColor(0x0000FF) Qd.setStatusText(v.name) break end end end") |
| 40 | - | |
| 40 | + | |
| 41 | - | print("Bingus3") |
| 41 | + | print("Bingus3")
|
| 42 | - | |
| 42 | + | |
| 43 | - | e_coords = {} |
| 43 | + | e_coords = {}
|
| 44 | - | |
| 44 | + | |
| 45 | - | function e_coords:deleteMe() |
| 45 | + | function e_coords:deleteMe() |
| 46 | - | e_coords = nil |
| 46 | + | e_coords = nil |
| 47 | end | |
| 48 | - | |
| 48 | + | |
| 49 | - | local function getPlayerCoords(p_name) |
| 49 | + | local function getPlayerCoords(p_name) |
| 50 | - | for k,v in ipairs(require("component").radar.getEntities()) do |
| 50 | + | for k,v in ipairs(require("component").radar.getEntities()) do
|
| 51 | - | if v.name == p_name then |
| 51 | + | if v.name == p_name then |
| 52 | - | e_coords[1] = v.x |
| 52 | + | e_coords[1] = v.x |
| 53 | - | e_coords[2] = v.y |
| 53 | + | e_coords[2] = v.y |
| 54 | - | e_coords[3] = v.z |
| 54 | + | e_coords[3] = v.z |
| 55 | - | return 1 |
| 55 | + | return 1 |
| 56 | - | end |
| 56 | + | end |
| 57 | - | print(k,v.name,v.x,v.y,v.z) |
| 57 | + | print(k,v.name,v.x,v.y,v.z) |
| 58 | - | end |
| 58 | + | end |
| 59 | - | return 0 |
| 59 | + | return 0 |
| 60 | end | |
| 61 | - | |
| 61 | + | |
| 62 | - | if getPlayerCoords("ph0")==1 then |
| 62 | + | if getPlayerCoords("ph0")==1 then
|
| 63 | - | for e in pairs(e_coords) do |
| 63 | + | for e in pairs(e_coords) do |
| 64 | - | print(e) |
| 64 | + | print(e) |
| 65 | - | end |
| 65 | + | end |
| 66 | - | else |
| 66 | + | else |
| 67 | - | print("Entity Not Found") |
| 67 | + | print("Entity Not Found")
|
| 68 | end | |
| 69 | - | e_coords:deleteMe() |
| 69 | + | e_coords:deleteMe() |
| 70 | - | |
| 70 | + | |
| 71 | - | |
| 71 | + | |
| 72 | - | |
| 72 | + | |
| 73 | - | while true do |
| 73 | + | while true do |
| 74 | - | local cmd=io.read() |
| 74 | + | local cmd=io.read() |
| 75 | - | if not cmd then return end |
| 75 | + | if not cmd then return end |
| 76 | - | modem.broadcast(2412,cmd) |
| 76 | + | modem.broadcast(2412,cmd) |
| 77 | - | if(cmd == "A") then |
| 77 | + | if(cmd == "A") then |
| 78 | - | modem.broadcast(2412,rad2) |
| 78 | + | modem.broadcast(2412,rad2) |
| 79 | - | sleep(0.5) |
| 79 | + | sleep(0.5) |
| 80 | - | elseif(cmd == "S") then |
| 80 | + | elseif(cmd == "S") then |
| 81 | - | modem.broadcast(2412,"stop") |
| 81 | + | modem.broadcast(2412,"stop") |
| 82 | - | sleep(0.5) |
| 82 | + | sleep(0.5) |
| 83 | - | else |
| 83 | + | else |
| 84 | - | modem.broadcast(2412,cmd) |
| 84 | + | modem.broadcast(2412,cmd) |
| 85 | - | end |
| 85 | + | end |
| 86 | end |