Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Using: CC: Tweaked, Plethora
- pastebin run gcJmSj0w
- pastebin get gcJmSj0w startup
- ]]--
- if pcall(os.loadAPI, "jLib/jFuncs") then
- else
- shell.run("pastebin get kqBFGcfV jLib/jFuncs")
- os.loadAPI("jLib/jFuncs")
- end
- local scanInterval = 0.2
- local renderInterval = 0.05
- local scannerRange = 8
- local scannerWidth = scannerRange * 2 + 1
- local size = 0.5
- local cellSize = 16
- local offsetX = 75
- local offsetY = 75
- local modules = peripheral.find("neuralInterface")
- if not modules then error("Must have a neural interface", 0) end
- if not modules.hasModule("plethora:sensor") then error("The entity sensor is missing", 0) end
- if not modules.hasModule("plethora:glasses") then error("The overlay glasses are missing", 0) end
- local canvas = modules.canvas()
- canvas.clear()
- local playerName = "EvilKurt2"
- local ignoreList = "Painting"
- local player = nil
- local entities = {}
- local args = {...}
- local toFind = nil
- local foundEntity = nil
- if(args ~= nil) then
- toFind = args[1]
- end
- if(toFind ~= nil) then
- print(("Trying to find %s"):format(toFind))
- end
- local y = 50
- local function scan()
- while true do
- entities = {}
- for i, entity in pairs(modules.sense()) do
- if(string.find(entity.name, toFind)) then
- foundEntity = entity
- end
- if(entity.name ~= ignoreList) then
- if(entity.name ~= playerName) then
- table.insert(entities, modules.getMetaByID(entity.id))
- else
- player = entity
- end
- end
- end
- if(foundEntity ~= nil) then
- return
- end
- sleep(scanInterval)
- end
- end
- local function getDirection(entity, player)
- local ret = ""
- if(player == nil) then
- return "???"
- end
- local deltaZ = player.z - entity.z
- local deltaX = player.x - entity.x
- local deltaY = player.y - entity.y
- if(math.abs(deltaZ) > 3) then
- if(deltaZ > 0) then
- ret = "N"
- else
- ret = "S"
- end
- end
- if(math.abs(deltaX) > 3) then
- if(deltaX > 0) then
- ret = ret .. "W"
- else
- ret = ret .. "E"
- end
- end
- if(math.abs(deltaY) > 3) then
- if(deltaY > 0) then
- ret = ret .. " Down"
- else
- ret = ret .. " Up"
- end
- end
- if(ret == "") then
- return "C"
- end
- return ret
- end
- local function getString(entity)
- ret = entity.displayName
- if(entity.health ~= nil) then
- ret = ret .. "\t" .. entity.health
- else
- ret = ret .. "\t?"
- end
- if(entity.maxHealth ~= nil) then
- ret = ret .. "/" .. entity.maxHealth
- else
- ret = ret .. "/?"
- end
- return ret .. "\t" .. getDirection(entity, player)
- end
- local function render(entityToFind)
- local lastLoop = false
- local color = 0xFFFFFFFF
- while(true) do
- sleep(renderInterval)
- local y = 50
- canvas.clear()
- for i, entity in pairs(entities) do
- canvas.addText({ 10, y}, getString(entity), color, size)
- y = y + 10
- end
- if(foundEntity ~= nil) then
- return
- end
- end
- end
- parallel.waitForAll(render, scan)
- print(("Found %s!"):format(toFind))
- canvas.clear()
- canvas.addText({ 10, 30}, getString(foundEntity), 0xFFFFFFFF, 1)
Add Comment
Please, Sign In to add comment