MineMcMine

MobFinder

Apr 11th, 2022 (edited)
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. --[[
  2.     Using: CC: Tweaked, Plethora
  3.     pastebin run gcJmSj0w
  4.     pastebin get gcJmSj0w startup
  5. ]]--
  6.  
  7. if pcall(os.loadAPI, "jLib/jFuncs") then
  8. else
  9.     shell.run("pastebin get kqBFGcfV jLib/jFuncs")
  10.     os.loadAPI("jLib/jFuncs")
  11. end
  12.  
  13.  
  14. local scanInterval = 0.2
  15. local renderInterval = 0.05
  16. local scannerRange = 8
  17. local scannerWidth = scannerRange * 2 + 1
  18. local size = 0.5
  19. local cellSize = 16
  20. local offsetX = 75
  21. local offsetY = 75
  22.  
  23. local modules = peripheral.find("neuralInterface")
  24. if not modules then error("Must have a neural interface", 0) end
  25. if not modules.hasModule("plethora:sensor") then error("The entity sensor is missing", 0) end
  26. if not modules.hasModule("plethora:glasses") then error("The overlay glasses are missing", 0) end
  27.  
  28. local canvas = modules.canvas()
  29. canvas.clear()
  30.  
  31. local playerName = "EvilKurt2"
  32. local ignoreList = "Painting"
  33. local player = nil
  34. local entities = {}
  35.  
  36. local args = {...}
  37. local toFind = nil
  38. local foundEntity = nil
  39. if(args ~= nil) then
  40.     toFind = args[1]
  41. end
  42.  
  43.  
  44. if(toFind ~= nil) then
  45.     print(("Trying to find %s"):format(toFind))
  46. end
  47.  
  48. local y = 50
  49. local function scan()
  50.     while true do
  51.         entities = {}
  52.  
  53.         for i, entity in pairs(modules.sense()) do
  54.             if(string.find(entity.name, toFind)) then
  55.                 foundEntity = entity
  56.             end
  57.             if(entity.name ~= ignoreList) then
  58.                 if(entity.name ~= playerName) then
  59.                     table.insert(entities, modules.getMetaByID(entity.id))
  60.                 else
  61.                     player = entity
  62.                 end
  63.             end
  64.         end
  65.         if(foundEntity ~= nil) then
  66.             return
  67.         end
  68.         sleep(scanInterval)
  69.     end
  70. end
  71.  
  72. local function getDirection(entity, player)
  73.     local ret = ""
  74.  
  75.     if(player == nil) then
  76.         return "???"
  77.     end
  78.  
  79.     local deltaZ = player.z - entity.z
  80.     local deltaX = player.x - entity.x
  81.     local deltaY = player.y - entity.y
  82.  
  83.     if(math.abs(deltaZ) > 3) then
  84.         if(deltaZ > 0) then
  85.             ret = "N"
  86.         else
  87.             ret = "S"
  88.         end
  89.     end
  90.  
  91.     if(math.abs(deltaX) > 3) then
  92.         if(deltaX > 0) then
  93.             ret = ret .. "W"
  94.         else
  95.             ret = ret .. "E"
  96.         end
  97.     end
  98.  
  99.     if(math.abs(deltaY) > 3) then
  100.         if(deltaY > 0) then
  101.             ret = ret .. " Down"
  102.         else
  103.             ret = ret .. " Up"
  104.         end
  105.     end
  106.  
  107.     if(ret == "") then
  108.         return "C"
  109.     end
  110.    
  111.     return ret
  112. end
  113.  
  114. local function getString(entity)
  115.     ret = entity.displayName
  116.     if(entity.health ~= nil) then
  117.         ret = ret .. "\t" .. entity.health
  118.     else
  119.         ret = ret .. "\t?"
  120.     end
  121.     if(entity.maxHealth ~= nil) then
  122.         ret = ret .. "/" .. entity.maxHealth
  123.     else
  124.         ret = ret .. "/?"
  125.     end
  126.  
  127.     return ret .. "\t" .. getDirection(entity, player)
  128. end
  129.  
  130.  
  131. local function render(entityToFind)
  132.     local lastLoop = false
  133.     local color = 0xFFFFFFFF
  134.     while(true) do
  135.         sleep(renderInterval)
  136.         local y = 50
  137.         canvas.clear()
  138.        
  139.         for i, entity in pairs(entities) do
  140.             canvas.addText({ 10, y}, getString(entity), color, size)
  141.             y = y + 10
  142.         end
  143.  
  144.         if(foundEntity ~= nil) then
  145.             return
  146.         end
  147.     end
  148. end
  149.  
  150. parallel.waitForAll(render, scan)
  151.  
  152. print(("Found %s!"):format(toFind))
  153. canvas.clear()
  154. canvas.addText({ 10, 30}, getString(foundEntity), 0xFFFFFFFF, 1)
  155.  
  156.  
  157.  
Add Comment
Please, Sign In to add comment