Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("apis/blittle")
- local file = "map"
- local mon = peripheral.wrap("top")
- local bg = colors.black
- local img = blittle.shrink(paintutils.loadImage(file),bg)
- local padX,padY = 7,2
- local ed = peripheral.find("EntityDetector")
- local range,ox,oy,oz = 20,-586,20,126
- local function drawBG()
- mon.setBackgroundColor(bg)
- mon.setTextScale(.5)
- mon.clear()
- blittle.draw(img,padX,padY,mon)
- end
- local function pix(x,y,c)
- c = c or "d" --lime=5 green=d
- mon.setCursorPos(x,y)
- mon.blit(" ","f","d")
- mon.setBackgroundColor(bg)
- end
- local function input()
- local tx,ty = term.getCursorPos()
- local _i,_z,_y
- while true do
- term.setCursorPos(tx,ty)
- term.clearLine()
- term.write("Z= ")
- _i = tonumber(read())
- if not _i then
- term.setCursorPos(tx,ty)
- term.clearLine()
- printError("Invalid Z coordinate")
- sleep(.5)
- else
- _z = _i
- break
- end
- end
- while true do
- term.setCursorPos(tx,ty+1)
- term.clearLine()
- term.write("Y= ")
- _i = tonumber(read())
- if not _i then
- term.setCursorPos(tx,ty+1)
- term.clearLine()
- printError("Invalid Y coordinate")
- sleep(.5)
- else
- _y = _i
- break
- end
- end
- return _z,_y
- end
- local _2t = 2/3
- local function convert(x,y)
- local _x = 18-(x - 118)
- local _y = math.floor((24-(y - 7))*_2t+.5)
- -- print("Conv ("..x..","..y..")->(".._x..",".._y..")")
- -- drawBG()
- -- pix(_x+padX+1,_y+padY)
- return _x+padX+1,_y+padY
- end
- local function lookup()
- local _x,_y
- local list,_,e = ed.getEntityList(range,ox,oy,oz)
- for _,mob in pairs(list) do
- if mob.name=="Zombie" then
- _x = math.floor(tonumber(mob.z))
- _y = math.floor(tonumber(mob.y))
- _x,_y = convert(_x,_y)
- pix(_x,_y,colors.green)
- end
- end
- end
- drawBG()
- local tick = os.startTimer(.1)
- local delay = .5
- while true do
- local e,p,x,y = os.pullEvent("timer")
- if e == "monitor_touch" then
- os.cancelTimer(tick)
- drawBG()
- pix(x,y)
- print("X:"..x.." | Y:"..y)
- sleep(.2)
- tick = os.startTimer(delay)
- elseif e=="key" and p==keys.enter then
- os.cancelTimer(tick)
- local x,y = input()
- convert(x,y,colors.lime)
- tick = os.startTimer(delay)
- elseif e=="timer" and p==tick then
- drawBG()
- lookup()
- tick = os.startTimer(delay)
- end
- end
Add Comment
Please, Sign In to add comment