Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = require("component")
- local gpu = com.gpu
- local turret = com.os_energyturret
- local radar = com.openperipheral_sensor
- local autors = {"qwertyMAN"}
- local version = "0.9"
- local Black_List = {}
- local White_List = {}
- -- относительные координаты пушки от сканера
- local correct = {
- x = 0,
- y = 4,
- z = 0
- }
- local function kostil(x)
- while true do
- if x>=360 then
- x = x - 360
- elseif x<0 then
- x = x + 360
- else
- break
- end
- end
- return x
- end
- local function pointer(x,y,z)
- local distXY = math.sqrt(x^2+z^2)
- local distDY = math.sqrt(y^2+distXY^2)
- local outX = math.deg(math.acos(x/distXY))+90
- local outY = 90-math.deg(math.acos(y/distDY))
- if z<0 then
- outX = kostil(180-outX)
- end
- return outX,outY
- end
- while true do
- os.sleep(0)
- local target = false
- local scan=radar.getPlayers()
- if #scan>0 then
- if #White_List>0 then
- for i=1, #autors do
- White_List[#White_List+1] = autors[i]
- end
- for i=1, #scan do
- local swich = true
- for j=1, #White_List do
- if scan[i].name==White_List[j] then
- swich = false
- end
- end
- if swich then
- target = scan[i].name
- break
- end
- end
- elseif #Black_List>0 then
- for i=#Black_List, 1, -1 do
- for j=1, #autors do
- if Black_List[i] == autors[j] then
- table.remove(Black_List,i)
- end
- end
- end
- for i=1, #scan do
- local swich = false
- for j=1, #Black_List do
- if scan[i].name==Black_List[j] then
- swich = true
- end
- end
- if swich then
- target = scan[i].name
- break
- end
- end
- else
- if #autors>0 then
- for i=1, #autors do
- White_List[#White_List+1] = autors[i]
- end
- else
- target = scan[1].name
- end
- end
- if target then
- if radar.getPlayerByName(target) then
- target=radar.getPlayerByName(target).all()
- local x,y,z = target.position.x-0.5-correct.x, target.position.y+0.3-correct.y, target.position.z-0.5-correct.z
- local vx,vy = pointer(x,y,z)
- turret.moveTo(vx,vy)
- if turret.isOnTarget() then
- turret.fire()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement