Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mode = 0--0 = Sleep, 1 = Holstered, 2 = Engaging
- local Aggression = 0
- --Inventory Setup, 1 = Weapon, 2 = Speaker, 3= Modem, 4= Detector
- local Staff = {}
- local Direction = "N"
- function GetDirection(player)
- local X1, Y1, Z1 = gps.getPosition()
- local X2, Y2, Z2 = SearchArea_Player(player)
- if X1 > X2 then
- Direction = "W"
- elseif X1 < X2 then
- Direction = "E"
- elseif Z1 > Z2 then
- Direction = "S"
- elseif Z1 < Z2 then
- Direction = "N"
- end
- end
- function GiveWarning()
- turtle.select(2)
- turtle.equipLeft()
- local Speaker = peripheral.find("speaker")
- Speaker.playSound("block.note_block.bit")
- turtle.unequipLeft()
- end
- function ApproachPlayer(player)
- GetDirection(player)
- local Cords = SearchArea_Player(player)
- Cords[4] = Direction
- shell.run("Mover",Cords)
- end
- function WarnPlayer(player)
- ApproachPlayer(player)
- GiveWarning()
- end
- function Attack()
- turtle.select(1)
- turtle.equipLeft()
- turtle.attack()
- turtle.unequipLeft()
- end
- function SearchArea_Player(player)
- local R = {}
- turtle.select(4)
- turtle.equipLeft()
- local Detector = peripheral.find("playerDetector")
- local Pos = Detector.getPlayerPos(player)
- R = {Pos.x,Pos.y,Pos.z}
- turtle.unequipLeft()
- return R
- end
- function Engage(player)
- for i = 1, 4 do
- local Cords = SearchArea_Player(player)
- GetDirection(player)
- Cords[4] = Direction
- shell.run("Mover",Cords)
- Attack()
- end
- end
- function Startup()
- turtle.select(3)
- assert(turtle.equipRight())
- peripherals.find("modem",rednet.open)
- end
- if tArg[1] == "start" then
- Startup()
- elseif tArg[1] == "Idle" then
- elseif tArg[1] == "Respond" then
- Aggression = tArg[3]
- if Aggression == 1 then
- WarnPlayer(tArg[2])
- elseif Aggression > 1 then
- for q = 1, 15 do
- Engage(tArg[2])
- end
- end
- end
Add Comment
Please, Sign In to add comment