Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tileset = {
- Enderman = {"E",2,colors.purple},
- Zombie = {"Z",1,colors.green},
- ZombieVillager = {"Z",1,colors.green},
- ZombiePigman = {"Z",1,colors.orange},
- Blaze = {"B",0,colors.yellow},
- Slime = {"S",0,colors.green},
- Creeper = {"C",1,colors.green},
- Skeleton = {"S",1,colors.lightGray},
- WitherSkeleton = {"W",1,colors.lightGray},
- Spider = {"S",0,colors.gray},
- Witch = {"W",1,colors.green},
- Villager = {"v",1,colors.brown},
- Cow = {"c",1,colors.brown},
- Chicken = {"c",0,colors.white},
- Pig = {"p",0,colors.pink},
- Sheep = {"s",1,colors.white},
- Dog = {"d",0,colors.white},
- Cat = {"c",0,colors.yellow},
- Wolf = {"w",0,colors.white},
- Ozelot = {"o",0,colors.yellow},
- Horse = {"h",1,colors.brown},
- Crab = {"c",0,colors.orange},
- }
- blacklist = {
- "minecraft:item_frame",
- "quark:glass_item_frame",
- "quark:colored_item_frame",
- "LeashKnot",
- }
- maxX,maxY = term.getSize()
- getMobs = function()
- level = {}
- sensor = nil
- if peripheral.find("neuralInterface") and peripheral.find("neuralInterface").hasModule("plethora:sensor") then
- sensor = peripheral.wrap("back")
- neural = true
- else sensor = peripheral.find("plethora:sensor") end
- if sensor == nil then
- term.setCursorPos(1,maxY)
- term.clearLine()
- print("Requires Plethora Entity Sensor!")
- else
- entities = sensor.sense()
- if selected == nil then selected = 0 end
- if size == nil then size = 17 end
- if selected > 8 then selected = 8
- elseif selected < -8 then selected = -8 end
- if size > 17 then size = 17
- elseif size < 1 then size = 1 end
- indent = math.floor((17-size)/2)
- if size < maxY then
- offset = 3 + math.floor((11-size)/2)
- else offset = 3 end
- for e = 1,#entities do
- isAllowed = true
- for b = 1,#blacklist do
- if entities[e].name == blacklist[b] then
- table.remove(entities[e])
- isAllowed = false
- end
- end
- if isAllowed then
- entities[e].y = math.floor(entities[e].y)
- if entities[e].x - math.floor(entities[e].x) > 0.85 then
- entities[e].x = math.ceil(entities[e].x)+9
- else entities[e].x = math.floor(entities[e].x)+9 end
- if entities[e].z - math.floor(entities[e].z) > 0.85 then
- entities[e].z = math.ceil(entities[e].z)+9
- else entities[e].z = math.floor(entities[e].z)+9 end
- tileFound = false
- for k,v in pairs(tileset) do
- if k == entities[e].name or k == entities[e].displayName then
- for l = 0,(v[2]) do
- if entities[e].y - l == selected then
- entities[e].tile = v[1]
- entities[e].colour = v[3]
- entities[e].y = selected
- table.insert(level, entities[e])
- tileFound = true
- end
- end
- end
- end
- if not tileFound and (entities[e].y == selected) then
- hungry = sensor.getMetaByName(entities[e].name).food
- if hungry == nil then
- entities[e].tile = "?"
- entities[e].colour = colors.white
- table.insert(level, entities[e])
- elseif (tonumber(entities[e].y) == selected) or (tonumber(entities[e].y) - 1 == selected) then
- entities[e].tile = "\2"
- entities[e].colour = colors.white
- table.insert(level, entities[e])
- end
- end
- end
- end
- end
- end
- writeText = function()
- if size > 17 then size = 17
- elseif size < 1 then size = 1 end
- if selected < 0 then lPref = "Y:"
- else lPref = "Y: " end
- if size < 10 then sPref = "S: "
- else sPref = "S:" end
- levelString = lPref..tostring(selected)
- scaleString = sPref..tostring(size)
- term.setCursorPos(maxX-#levelString+1,1)
- write(levelString)
- term.setCursorPos(maxX-#scaleString+1,2)
- write(scaleString)
- term.setCursorPos(1,maxY)
- term.clearLine()
- if selectedMob ~= nil then
- if #selectedMob < maxX then write(selectedMob)
- else write(string.sub(selectedMob,1,maxX-3).."...") end
- end
- end
- drawMap = function()
- for row = 1+offset,17-offset do
- for col = 1+indent,17-indent do
- filled = false
- term.setCursorPos(((col*2)-1),row-3)
- for mob = 1,#level do
- if (level[mob].z == row) and (level[mob].x == col) then
- if term.isColour() then term.setTextColour(tonumber(level[mob].colour)) end
- write(level[mob].tile)
- if term.isColour() then term.setTextColour(colors.white) end
- filled = true
- end
- end
- if not filled then write(" ") end
- end
- end
- end
- lastLevel = {false}
- checkMobs = function()
- while true do
- getMobs()
- if change or (textutils.serialise(level) ~= textutils.serialise(lastLevel)) then
- shell.run("clear")
- drawMap()
- writeText()
- lastLevel = level
- change = false
- end
- sleep(0)
- end
- end
- selectedMobs = {}
- checkKeys = function()
- while true do
- os.startTimer(1)
- evt, e1, e2, e3 = os.pullEvent()
- if evt == "key" then
- if e1 == keys.up then
- selected = selected + 1
- change = true
- elseif e1 == keys.down then
- selected = selected - 1
- change = true
- elseif e1 == keys.right then
- size = size + 2
- change = true
- elseif e1 == keys.left then
- size = size - 2
- change = true
- elseif e1 == keys.space then
- selectedMob = nil
- change = true
- end
- elseif evt == "mouse_scroll" then
- if e1 == 1 then
- selected = selected - 1
- change = true
- elseif e1 == -1 then
- selected = selected + 1
- change = true
- end
- elseif evt == "mouse_click" and (e1==1) then
- for i = 1,#level do
- if (tonumber(textutils.serialise(level[i].x))*2)-1 == tonumber(e2) then
- if tonumber(textutils.serialise(level[i].z))-3 == tonumber(e3) then
- if level[i].name ~= level[i].displayName:gsub(" ","") then
- selectedMob = level[i].displayName.." ("..level[i].name..")"
- else selectedMob = level[i].displayName end
- change = true
- end
- end
- if change == true then break end
- end
- end
- end
- end
- parallel.waitForAny(checkKeys, checkMobs)
Advertisement
Add Comment
Please, Sign In to add comment