Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
PHOBOSS98

BUDGET DRONE ARMY... FOR FREE!!!

Recommended Posts

So... I'm back...you know radars are expensive... that makes radar upgrades for each drone more expensive...which defeats the purpose of having a dispensable army. This is my attempt at fixing this issue:

Instead of having each of your drone fly around with equipment worth half of the US military budget, why not have a single radar and a computer to tell the swarm where to buzz around?.

Here's the new stuff that you need:

a Waypoint block named "yeet" -- or something else if you want, just don't forget to change it in the code

Radar block --from computronics

a computer-- preferably a server or something that can give you a portable interface to type in your commands

atleast a tier 2 drone --for the survivalists note: they run out of power fast if you dont give them the right upgrades tho... thats why I prefer creative cases

1 Navigation upgrade for each drone

and the code:

this goes into your computer:

  1. local component = require("component")
  2. local event = require("event")
  3. local serialization= require("serialization")
  4. local computer= require("computer")
  5. local radar = component.radar
  6. local modem = component.modem
  7.  
  8. modem.open(2412)
  9. modem.broadcast(2412,"n= component.proxy(component.list('navigation')())")
  10. modem.broadcast(2412,"d= component.proxy(component.list('drone')())")
  11. modem.broadcast(2412,"rbt= component.proxy(component.list(‘robot’)())")
  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.  
  14. local function sleep(timeout) checkArg(1, timeout, "number", "nil") local deadline = computer.uptime() + (timeout or 0) repeatcomputer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline
  15. end
  16.  
  17. while true do
  18. local cmd=io.read()
  19.  if not cmd then return
  20.  end
  21.  
  22.  if cmd=="BZZ" then
  23.    print("Target: ") tag=io.read()
  24.    print("Drone No.: ") srm=io.read()
  25.      repeat
  26.       local cmd=select(1,event.pull(1))
  27.  
  28.   for k, v in ipairs(radar.getEntities()) do
  29.     if v.name==tag then
  30.         x= v.x  y=v.y  z=v.z
  31.     end
  32.     if v.y>0 then y=v.y+1
  33.     end
  34.   end  
  35.   modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' and d.name()=='"..srm.."' then a=-v.position[1]-'"..x.."'+ math.random(-3,3) math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a)  end b=-v.position[2]-'"..y.."'+ math.random(-3,3) math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b)  end c=-v.position[3]-'"..z.."'+ math.random(-3,3) math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c)  end  d.move(a,b,c) end end")
  36.  
  37. print (x,y,z)sleep(0.5)
  38.  
  39.     until cmd=="key_down"
  40.   end
  41.  
  42.  if cmd=="SWARM" then
  43.    print("Target: ") tag=io.read()
  44.      repeat
  45.       local cmd=select(1,event.pull(1))
  46.  
  47.   for k, v in ipairs(radar.getEntities()) do
  48.     if v.name==tag then
  49.         x= v.x  y=v.y  z=v.z
  50.     end
  51.     if v.y>0 then y=v.y+1
  52.     end
  53.   end  
  54. modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' then a=-v.position[1]-'"..x.."'+ math.random(-3,3) math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a)  end b=-v.position[2]-'"..y.."'+ math.random(-3,3) math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b)  end c=-v.position[3]-'"..z.."'+ math.random(-3,3) math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c)  end  d.move(a,b,c) end end")
  55.  
  56. print (x,y,z)sleep(0.5)
  57.  
  58.     until cmd=="key_down"
  59.   end
  60.  
  61.  if cmd=="RETURN" then
  62.    print("Target: ") tag=io.read()
  63.      repeat
  64.       local cmd=select(1,event.pull(1))
  65.  
  66.   for k, v in ipairs(radar.getEntities()) do
  67.     if v.name==tag then
  68.         x= v.x  y=v.y  z=v.z
  69.     end
  70.     if v.y>0 then y=v.y+1
  71.     end
  72.   end  
  73. modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' then a=-v.position[1]-'"..x.."' math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a)  end b=-v.position[2]-'"..y.."' math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b)  end c=-v.position[3]-'"..z.."' math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c)  end  d.move(a,b,c) end end")
  74.  
  75. print (x,y,z)sleep(0.5)
  76.  
  77.     until cmd=="key_down"
  78.   end
  79.  
  80.   print(select(6, event.pull(3, "modem_message")))
  81.  
  82. end

and for the drone (nothing really changed):

  1. local m=component.proxy(component.list("modem")())
  2. local d=component.proxy(component.list("drone")())
  3. d.setLightColor(0x00FFE8)               -- the first character 's' of the method should have been in lower case
  4. d.setStatusText(d.name())                -- same here... my bad
  5. m.open(2412)
  6. m.setWakeMessage("RISE")
  7. local function respond(...)
  8.   local args=table.pack(...)
  9.   pcall(function() m.broadcast(2412, table.unpack(args)) end)
  10. end
  11. local function receive()
  12.   while true do
  13.     local evt,_,_,_,_,cmd=computer.pullSignal()
  14.     if evt=="modem_message" then return load(cmd) end
  15.   end
  16. end
  17. while true do
  18.   local result,reason=pcall(function()
  19.     local result,reason=receive()
  20.     if not result then return respond(reason) end
  21.     respond(result())
  22.   end)
  23.   if not result then respond(reason) end
  24. end

Back in the days where everything was simple, like when I made the original code, each drone had a Radar upgrade that tells it where everybody is relative to the drone itself... this had to change...

The drones have to rely on a reference point to know where they are in space. With the waypoint block pointed to the radar block the drones can know their relative distance from the radar. (It should work wherever you place it, just have the side with the particle effects touch the radar block)

475876196_ScreenShot2019-03-25at9_12_38pm.jpg.eed0d0c55255490c99a9b08a54f3ae28.jpg

With the radar knowing where entities are in space relative to the itself the computer can tell the drones where an entity is from the radars perspective. With some quick maths the drones know where an entity is relative to themselves.... and thats how science works...

COMMANDS SO FAR:

BZZ -- call a drone to fly randomly around you or another entity note: energy drains really fast when you let it fly around too long...

SWARM -- calls the whole swarm to do the same thing

RETURN -- calls the whole swarm to your feet. Much easier than going on a scavenger hunt for your lost drones

have F.U.N.

PS: the drones should all be powered on before running the program

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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