Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --http://computercraft.ru/topic/1429-okhrannaia-sistema-turelei-opensecurity/
- local function func()
- local com = require("component")
- local event = require("event")
- local gpu = com.gpu
- local turret = com.os_energyturret
- local radar = com.openperipheral_sensor
- local autors = {"qwertyMAN"}
- local version = "0.9.1"
- -- Настройки
- local firePleayers = true
- local fireMobs = true
- local Black_Player_List = {}
- local White_Player_List = {}
- -- относительные координаты пушки от сканера
- local correct = {
- x = 0,
- y = 3,
- z = 0
- }
- 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 = (180-outX)%360
- end
- return outX,outY
- end
- while true do
- os.sleep(0)
- local target = false
- local fire = true
- local scan=radar.getPlayers()
- if firePleayers and #scan>0 then
- if #White_Player_List>0 then
- for i=1, #autors do
- White_Player_List[#White_Player_List+1] = autors[i]
- end
- for i=1, #scan do
- local swich = true
- for j=1, #White_Player_List do
- if scan[i].name==White_Player_List[j] or not scan[i].name then
- swich = false
- end
- end
- if swich then
- target = scan[i].name
- break
- end
- end
- elseif #Black_Player_List>0 then
- for i=#Black_Player_List, 1, -1 do
- for j=1, #autors do
- if Black_Player_List[i] == autors[j] then
- table.remove(Black_Player_List,i)
- end
- end
- end
- for i=1, #scan do
- local swich = false
- for j=1, #Black_Player_List do
- if scan[i].name==Black_Player_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_Player_List[#White_Player_List+1] = autors[i]
- end
- else
- target = scan[1].name
- end
- end
- if target and 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
- fire = false
- end
- end
- target = false
- if fireMobs and fire then
- local scan=radar.getMobIds()
- if #scan>0 then
- for i=1, #scan do
- local mob
- if radar.getMobData(scan[i]).basic() then
- mob = radar.getMobData(scan[i]).basic()
- target = mob
- end
- end
- if target then
- local x,y,z = target.position.x-0.5-correct.x, target.position.y-0.5-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
- end
- -- мегакостыль
- while true do
- local oop = pcall(func)
- print(oop)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement