This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Landstryder's profile picture

Robot Warrior Defender (OpenPeripheral)

Started by Landstryder, 07 December 2013 - 11:43 AM
Landstryder #1
Posted 07 December 2013 - 12:43 PM
Got to say- I LOVE ROBOTS!

and the new robot warrior that Mikeemoo has given us to play with, defiantly has a ton of fun potential.

So here is my version of Mikeemoo's code that he used in this video:

http://www.youtube.com/watch?v=mpDSdBWtHbA

THIS IS NOT MY OWN CODE
basically just copied what was in the video and added the ability to switch it off from a bundled input and changed the random move part slightly.

The purpose of posting this is just to give those folks that want to experiment with the robot and that need a little help getting started with their own program idea, a starting point.

I will defiantly use this as a core to create a more robust warrior program (that's why I started with bundled inputs, later that will give me a bunch of levers and buttons to control robot functions)

http://pastebin.com/HfYy7392


bot=peripheral.wrap("front")
local trol="right"
while true do
if rs.getBundledInput(trol) > 0 then
 
x,y,z=bot.getLocation(0)
mobIds=bot.getMobIds(0)
 
for k,mobId in pairs(mobIds) do
 
  while true do
  
   mobData=bot.getMobData(0,mobId)
  
   if mobData==nil then break end
  
   if mobData.type=="entity.OpenPeripheral.RobotWarrior.name" then break end
  
   if mobData.isDead or mobData.health <0 then break end
  
   print("Aiming at: "..mobData.type)--reports target type to help identify enties that might need filtered out
 
  bot.aimAt(0,mobData.position.x+x,mobData.position.y+y,mobData.position.z+z)
  bot.fireLight(0)
  sleep(0.3)
 
  end
end
bot.goto(0,x+math.random(-10,10)*50,y+math.random(-10,10),z)
os.pullEvent()
end
sleep(1)
end

THANKS MIKEEMOO for such an AWESOME MOD!!
pogof #2
Posted 08 December 2013 - 01:56 AM
This is cool :D/>
-pogof