Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Forum Connectivity Upgrade Read more... ×

PHOBOSS98

Members
  • Content Count

    28
  • Joined

  • Last visited

About PHOBOSS98

  • Rank
    Junior Member

Contact Methods

  • Minecraft
    1.12.2

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. PHOBOSS98

    New Drone Swarm Program by a noob programmer

    yeah about that... I might have forgotten to document the version I used for this... I haven't even checked if my code even works on the latest version... its going to take me a while to sort this out actually... so you might want to start tweaking the code a bit while I can't...
  2. PHOBOSS98

    New Drone Swarm Program by a noob programmer

    Hi, sorry for the late reply, are you using your own code or my code above. it would really help if you could show us the part code you edited...
  3. Hi, are you tired of your mundane minions? do you have a s@$# ton of drones and have no idea what to do with them? are you tired of havi- you know what here's the code for your Drone Army (I don't know what else to say to convince you that this is a program worth playing with): Le client.lua (this goes in your tablet): local component = require("component") local event = require("event") local serialization= require("serialization") local computer= require("computer") local modem = component.modem modem.open(2412) modem.broadcast(2412,"r= component.proxy(component.list('radar')())") modem.broadcast(2412,"n= component.proxy(component.list('navigation')())") modem.broadcast(2412,"d= component.proxy(component.list('drone')())") 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") local 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 while true do local cmd=io.read() if not cmd then return end if cmd=="ALLFLW" then -- # all follow print("Target: ") tag=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' then x= v.x + math.random(-3,3) y=v.y + math.random(-3,3) z=v.z + math.random(-3,3) d.move(x,y,z) end end") sleep(0.5) until cmd=="key_down" end if cmd=="FLW" then -- # specific drone print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' and d.name()== '"..srm.."' then x= v.x + math.random(-3,3) y=v.y + math.random(-3,3) z=v.z + math.random(-3,3) d.move(x,y,z) end end") sleep(0.5) until cmd=="key_down" end if cmd=="ALLMOV" then --# all move print("x: ") x=io.read() print("y: ") y=io.read() print("z: ") z=io.read() modem.broadcast(2412," d.move("..x..","..y..","..z..")") end if cmd=="MOV" then --# specific drone print("Drone No.: ") srm=io.read() print("x: ") x=io.read() print("y: ") y=io.read() print("z: ") z=io.read() modem.broadcast(2412,"if d.name()== '"..srm.."' then d.move("..x..","..y..","..z..") end") end if cmd=="STK" then -- # stalk print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '"..tag.. "' and d.name()== '"..srm.."' then x= v.x + 15*((math.random(1,2)*2)-3) y=v.y + 15 z=v.z + 15*((math.random(1,2)*2)-3) d.move(x,y,z) sleep(0.5) end end") until cmd=="key_down" end if cmd=="GOTO" then --# converge at target position print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' and d.name()== '"..srm.. "' then d.move(v.x,v.y,v.z) end end") end if cmd=="ALLGOTO" then -- # all converge at target position print("Target: ") tag=io.read() modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' then d.move(v.x,v.y,v.z) end end") end if cmd=="SET8" then --# make 8 drones from swarm converge at target position, used to set up shield and other stuff that I have yet to think about. print("Target: ") tag=io.read() t={1,2,3,4,5,6,7,8,9,10,11,12,13,14} local n = #t while n >= 2 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) while true do print("What Is Thy Bidding?") bid=io.read() if bid=="X" then --# use this to adjust drone alignment modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) end if bid=="OK" then break end if bid=="PORTAFORT" then--# builds a simple 5X2X5 wall (complete with small entrances/exits) around the set center with any block in the drones inventory slot 1, you need atleast 30 blocks (that's atleast 4 for each drone (technically 2 of them only need 3 blocks but you don't need to bother with that)) modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(2,2,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[1].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(2,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) end") sleep(3) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(-2,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(-2,2,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.005) d.place(0) end") sleep(4) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(2,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.3) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.move(1,0,0) sleep(0.3) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-2,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.3) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.move(-1,0,0) sleep(0.3) d.place(0) end") sleep(3) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.2) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(0,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.2) d.place(0) end") sleep(0.5) end end end if cmd=="SET9" then --# make 9 drones from swarm converge at target position, used to set up carpet bombing and other stuff that I have yet to think about. print("Target: ") tag=io.read() t={1,2,3,4,5,6,7,8,9,10,11,12,13,14} local n = #t while n >= 2 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[9].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) while true do print("What Is Thy Bidding?") bid=io.read() if bid=="X" then --# use this to adjust drone alignment modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[9].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) end if bid=="OK" then break end if bid=="SETPLANT" then --# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3 for each drone... modem.broadcast(2412,"if d.name()=='"..t[1].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[2].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[3].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[4].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[5].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[6].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[7].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[8].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[9].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") end if bid=="MAT" then --#covers a 33X33 area with 9 drones print("N,S,E,W") dir=io.read() if dir=="N" then -- #-Z modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(0,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-10,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(10,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(0,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-10,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(10,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,0,-40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(10,0,-40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-10,0,-40) end") sleep(0.5) end if dir=="S" then -- #Z modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(0,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-10,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(10,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(0,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-10,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(10,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,0,40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(10,0,40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-10,0,40) end") sleep(0.5) end if dir=="E" then -- #+X modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(20,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(20,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(20,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(30,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(30,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(30,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(40,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(40,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(40,0,0) end") sleep(0.5) end if dir=="W" then -- #+X modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(-20,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-20,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(-20,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(-30,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-30,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(-30,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(-40,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(-40,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-40,0,0) end") sleep(0.5) end end end end if cmd=="PLANT" then --# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3... print("Drone No.: ") srm=io.read() modem.broadcast(2412,"if d.name()=='"..srm.."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") end if cmd=="BUNKERBUST" then --# yeah, you need more redstone torches and TNT... print("Drone No.: ") srm=io.read() repeat local cmd= select(1,event.pull(3)) modem.broadcast(2412,"if d.name()=='"..srm.."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") sleep(0.5) until cmd=="key_down" end if cmd=="HUSH" then--# kill command modem.broadcast(2412," computer.shutdown()") end if cmd=="RISE" then --# wake message, you need to restart client after using this command modem.broadcast(2412,"RISE") end print(select(6, event.pull(3, "modem_message"))) end Le BRAIN.lua (this goes in the drone) local m=component.proxy(component.list("modem")()) local d=component.proxy(component.list("drone")()) d.SetLightColor(0x00FFE8) d.SetStatusText(d.name()) m.open(2412) m.setWakeMessage("RISE") local function respond(...) local args=table.pack(...) pcall(function() m.broadcast(2412, table.unpack(args)) end) end local function receive() while true do local evt,_,_,_,_,cmd=computer.pullSignal() if evt=="modem_message" then return load(cmd) end end end while true do local result,reason=pcall(function() local result,reason=receive() if not result then return respond(reason) end respond(result()) end) if not result then respond(reason) end end here you'll also need these to work with: atleast 64 TNT blocks atleast 64 redstone torches atleast 64 building materials (blocks preferably) Creative drone Case (sorry survivalists, I couldn't find a way to put it all in a T2 case ) Computronics 1.6.6 for 1.12.2 Radar upgrade heres: a link to the add-on:https://files.vexatos.com/?dir=Computronics/dev (ps: you need to go into the computronics config file and set the radar range to atleast 50 blocks and set it to return coordinates to true) 5X T3 Battery upgrade (or you can use less if you use more solar upgrades) Inventory upgrade Inventory controller upgrade T3 CPU 2X T3.5 Memory wireless network card (you'll need atleast 14 of these drones named from '1' to '14' ) and a creative tablet (might as well... or if your upto it, you can use a regular tablet) oh yeah I almost forgot: some of the commands: FLW-- # call a specific drone to follow (randomly flys about) ALLFLW-- # all follow ( they all randomly fly about) MOV-- # call a specific drone to move ALLMOV-- # all move GOTO-- # call a specific drone to converge at a target ALLGOTO--# all will converge at target STK-- # call a specific drone to stalk a target (its default is to follow a target 15 blocks above) PLANT--# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3... BUNKERBUST --# does the samething as PLANT but throws it in a loop yeah, you need more redstone torches and TNT... HUSH --# kill command RISE--# wake message (you need to restart client after using this command) ---for the following type in 'X' to re-center drones and 'OK' to break out of 'SET' (you'll know what I mean )--- SET8--# make 8 drones from swarm converge at target position, used to set up fort and other stuff that I have yet to think about. PORTAFORT--# builds a simple 5X2X5 wall (complete with small entrances/exits) around the set center with any block in the drones inventory slot 1, you need atleast 30 blocks (that's atleast 4 for each drone (technically 2 of them only need 3 blocks but you don't need to bother with that)) SET9--# make 9 drones from swarm converge at target position, used to set up carpet bombing and other stuff that I have yet to think about. MAT --#covers a 33X33 area with 9 drones SETPLANT--# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3 for each drone... have fun causing Havoc and chaos and this might be the first and last time I write a program for opencomputers... Byeeeee
  4. PHOBOSS98

    How many tnt blocks does it take to kill a drone?

    oh wait... why did I post this on the programming thread?... hold on
  5. PHOBOSS98

    How many tnt blocks does it take to kill a drone?

    no for real tho can it be killed?
  6. I used sangars drone control scheme and tried sending it "computer.shutdown" but I wouldn't be here if it did work XD
  7. cause I know four isn't enough...
  8. PHOBOSS98

    HELP my drone fainted

    Good news I solved it somehow... I put the table sorting line in a function OUTSIDE of the while loop and call it using 'event.listen' (I got it from event.lua)
  9. PHOBOSS98

    HELP my drone fainted

    well thats odd... apparently the drone tries to broadcast twice, I tweaked the code a small bit: local computer=require("computer") local component=require("component") local d= component.proxy(component.list("drone")()) local m= component.proxy(component.list("modem")()) local r= component.proxy(component.list("radar")()) m.open(1) while true do local_,_,_,_,_,rtable,mov,x,y,z = computer.pullSignal() if mov=="follow" then for k, v in pairs(r.getEntities()) do m.broadcast(1,"rreeeee") - - #Le tweak end end end and then got this: but when it tries to broadcast the 'v' entries it does this: then shuts down... maybe thats what's causing it to crash?(I'm just guessing here)... it doesn't happen outside the "for k,v in pairs()..." line: local computer=require("computer") local component=require("component") local d= component.proxy(component.list("drone")()) local m= component.proxy(component.list("modem")()) local r= component.proxy(component.list("radar")()) m.open(1) while true do local_,_,_,_,_,rtable,mov,x,y,z = computer.pullSignal() if mov=="follow" then m.broadcast(1,"skrrrrra") - - #does it once for k, v in pairs(r.getEntities()) do m.broadcast(1,"ka") - - #does it twice end m.broadcast(1,"pa pa ka") - -#does it once end end see:
  10. PHOBOSS98

    HELP my drone fainted

    what, do I just smack the drone with it?: I don' think that the radar would give out a nil value I tried broadcasting the 'v' entries from the drone with this code: local d= component.proxy(component.list("drone")()) local m= component.proxy(component.list("modem")()) local r= component.proxy(component.list("radar")()) m.open(1) while true do local_,_,_,_,_,rtable,mov,x,y,z = computer.pullSignal() if mov=="follow" then for k, v in pairs(r.getEntities()) do m.broadcast(1,v.name,v.distance,v.x,v.y,v.z) end end end I got this in return: ...before the drone fainted again
  11. PHOBOSS98

    HELP my drone fainted

    so for context I tested this code on some bots: local component = require("component") local event = require("event") local robot = require("robot") component.modem.open(1) local function b(_,_,_,_,_,mov) if mov=="follow" then for k,v in pairs(component.radar.getEntities()) do if v.name=="PHOBOSS" then if v.y<-1 then for i=0,v.y,-1 do robot.down() end end if v.y>-1 then for i=0,v.y, 1 do robot.up() end end if v.y==-1 then print("level") --just for %!@$ and giggles end end end end end event.listen("modem_message", b) with the radar upgrade installed I made them track my movement and told them to follow me moving up and down ( I just did this to test out my code) it worked as long as you keep broadcasting "follow" now I tried implementing this to a drone (cause its cool and way easier to set its movements): local d= component.proxy(component.list("drone")()) local m= component.proxy(component.list("modem")()) local r= component.proxy(component.list("radar")()) m.open(1) when true do local_,_,_,_,_,rtable,mov,x,y,z = computer.pullSignal() if mov=="follow" then for k, v in pairs(r.getEntities()) do - - # for clarification, here's an example: r.getEntities() = { {distance=3.008877656445322,name="PHOBOSS",x=7,z=0,y=0} , {name="Chicken",distance=5.7886764534321234,z=5,y=3,x=-2}... } if v.name=="PHOBOSS" then d.move(v.x,v.y,v.z) end end end end but the moment that it would read: for k, v in pairs(r.getEntities()) do if v.name=="PHOBOSS" then d.move(v.x,v.y,v.z) the drone shuts off... pls holp XD
  12. PHOBOSS98

    How do you make a loop stop on user input?

    doh, Im so dumb, thanks m8s been a great help XD
  13. PHOBOSS98

    How do you make a loop stop on user input?

    yeah... I want it to keep printing hello repeatedly until I tell it to stop without having to reboot
  14. PHOBOSS98

    Tell me where I went wrong?

    but still the problem stands the code still doesn't work with bots
  15. PHOBOSS98

    How do you make a loop stop on user input?

    I do need a loop that can stop by a modem event.. but you see when I tried the code you sent me (with a few changes): local component = require("component") local event = require("event") local m = component.modem m.open(1) repeat print("hello") --#the thing local cmd = select(6, event.pull("modem_message")) until cmd == "stop" it did end the program when I sent it the message but it doesn't print it repeatedly it just does this: and so I tried and tested something and changed the code: local component = require("component") local event = require("event") local m = component.modem m.open(1) repeat print("hello") local cmd = select(6, event.pull("modem_message")) print("hi")--#the new thing until cmd == "stop" and ended up with this: (note: i didn't end the program this time) it seems that the loop stops at local cmd = select(6, event.pull("modem_message")) but still thinks it's running since when I broadcasted the stop command it did this:
×

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.