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)
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.
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
Link to post
Share on other sites