Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if turtle then
- turtle.equipLeft()
- turtle.equipLeft()
- turtle.equipRight()
- turtle.equipRight()
- end
- local function fetch(u)
- local h = http.get(u)
- local c = h.readAll()
- h.close()
- return c
- end
- local function update()
- local data = fetch "https://pastebin.com/raw/ZfhJz6n4"
- if data then
- local f = fs.open("startup", "w")
- f.write(data)
- f.close()
- end
- end
- if process then process.signal("signd", process.signals.KILL) end
- local ni = peripheral.find "neuralInterface"
- local sign = peripheral.find "minecraft:sign"
- local sensor, laser
- if not ni then
- sensor = peripheral.find "plethora:sensor"
- laser = peripheral.find "plethora:laser"
- else
- sensor = ni
- laser = ni
- end
- local speaker = peripheral.find "speaker"
- local function get_direction(entity)
- local x, y, z = entity.x, entity.y, entity.z
- local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
- local yaw = math.atan2(-x, z)
- print(yaw, pitch)
- return math.deg(yaw), math.deg(pitch)
- end
- local function shoot(entity)
- local dn = entity.displayName
- if dn:find "gollark" or dn:find "laser" or dn:find "Arrow" then return end
- local y, p = get_direction(entity)
- if speaker then speaker.playSound "entity.lightning.impact" end
- laser.fire(y, p, 5)
- end
- local banned = {
- }
- local function update_banned()
- while true do
- local l = textutils.unserialise(fetch(settings.get "traffic.ban_list" or "https://pastebin.com/raw/phbWuSXd"))
- if type(l) == "table" then
- banned = {}
- for _, v in pairs(l) do
- print("Banned:", v)
- banned[v] = true
- end
- else
- printError "Invalid Banned List."
- end
- sleep(15)
- end
- end
- local function main()
- local incidents = 0
- while true do
- local entities = sensor.sense()
- for _, entity in pairs(entities) do
- --if entity.displayName:find "item." then shoot(entity) end
- local velocity = vector.new(entity.motionX, entity.motionY + 0.0784, entity.motionZ) -- compensate for gravity
- local position = vector.new(entity.x, entity.y, entity.z)
- local distance = position:length()
- local speed = velocity:length()
- if (speed > 0.8) and not settings.get "traffic.ignore_speed" then
- incidents = incidents + 1
- shoot(entity)
- end
- if (distance < 1.5) and not settings.get "traffic.ignore_near" then
- shoot(entity)
- end
- if speed > 1e-5 then
- print(entity.displayName, "V", speed, "D", distance)
- end
- if banned[entity.displayName] then shoot(entity) end
- end
- if sign then sign.setSignText("Speed Limit", "Violations:", tostring(incidents)) end
- sleep(1)
- end
- end
- parallel.waitForAll(update, main, update_banned, function()
- while true do local _, k = os.pullEvent "key" if k == keys.u then break end end
- update()
- os.reboot()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement