Posted 30 September 2013 - 02:29 AM
Hi all, this is just a simple program I wrote which allows the newly added robots from OpenPeripherals to shoot at a specific player.
I also added a yaw fix so the robot hits the player.
I'm working on a predictive movement program too but thought you might be interesting in what I have so far. :)/>/>/>
Code:
If you don't know how to use OpenPeripheral Mechs, just place down a robot contoller next to a computer, right click to open it and place your robot inside, this will give it an ID.
You then wrap the peripheral and use the robot ID in each function you want to execute.
Screenshot:
Pretty cool huh? :P/>/>/>
Note: If you want an API list for the mechs I made one on my wiki!
I also added a yaw fix so the robot hits the player.
I'm working on a predictive movement program too but thought you might be interesting in what I have so far. :)/>/>/>
Code:
Spoiler
function run()
target = m.getPlayerData(id,player)
tarx = target.position.x
tary = target.position.y
tarz = target.position.z
ourx,oury,ourz = m.getLocation(id)
fix = ourx + tarx
fiy = oury + tary
fiz = ourz + tarz
m.aimAt(id,fix,fiy,fiz)
fp = cp - 5
m.fireLight(id)
print("Target X "..tarx)
print("Target Y "..tary)
print("Target Z "..tarz)
print("Our X "..ourx)
print("Our Y "..oury)
print("Our Z "..ourz)
print("Fixed X "..fix)
print("Fixed Y "..fiy)
print("Fixed Z "..fiz)
print("Yaw "..cp)
end
arg = {...}
if #arg == 0 then
print("Usage: <amount> <time> <player> <robot id> <side>")
return
end
player = arg[3]
id = tonumber(arg[4])
m = peripheral.wrap(arg[5])
for i = 1, arg[1] do
run()
sleep(tonumber(arg[2]))
end
If you don't know how to use OpenPeripheral Mechs, just place down a robot contoller next to a computer, right click to open it and place your robot inside, this will give it an ID.
You then wrap the peripheral and use the robot ID in each function you want to execute.
Screenshot:
Pretty cool huh? :P/>/>/>
Note: If you want an API list for the mechs I made one on my wiki!
Edited on 02 January 2014 - 03:27 PM