Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Filter = "allthemodium"
- Scanner = peripheral.wrap("back")
- Cswitch = 12
- local function len(x , y)
- return math.sqrt(math.pow(x, 2) + math.pow(y, 2))
- end
- local function pow(b)
- return math.pow(b["x"], 2) + math.pow(b["y"], 2) + math.pow(b["z"],2)
- end
- local function lenb(b)
- local v = vector.new(b["x"], b["y"], b["z"])
- return v:length()
- end
- local function rot(x,y, a)
- local xr = math.cos(a) * x + math.sin(a) * y
- local yr = -math.sin(a) * x + math.cos(a) * y
- return xr , yr
- end
- local function norm(x,y)
- local len = len(x,y)
- return x / len, y / len
- end
- local function div(x,y , amount)
- return x / amount, y / amount
- end
- local function mul(x, y, amount)
- return x * amount, y * amount
- end
- local function middle()
- local width, height = term.getSize()
- return width / 2, height / 2
- end
- local function compass(x, y)
- local ox, oy = middle()
- local dis = len(x,y)
- if dis < Cswitch then
- print("normal")
- paintutils.drawPixel(ox , oy, colors.white)
- paintutils.drawPixel(ox + x, oy + y, colors.green)
- else
- print("zoomed out")
- paintutils.drawPixel(ox , oy, colors.white)
- local sx, sy = div(x,y,dis)
- local sx, sy = mul(sx,sy,5)
- paintutils.drawPixel(ox + sx, oy + sy, colors.red)
- end
- term.setBackgroundColor(colors.black)
- end
- local function findClose()
- local minb = nil
- local minlen = math.huge
- for id, block in pairs(Blocks) do
- if string.match(block["name"], Filter) then
- local len = pow(block)
- if len < minlen then
- minlen = len
- minb = block
- end
- end
- end
- return minb
- end
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- Blocks, Err = Scanner.scan(16)
- Found = false
- local block = findClose()
- if block ~= nil then
- term.setTextColor(colors.green)
- term.write(block["name"])
- term.setTextColor(colors.white)
- term.write(" at ")
- term.setTextColor(colors.blue)
- print(string.format("x:%d z:%d y:%d", block["x"], block["z"], block["y"]))
- compass(block["x"], block["z"])
- else
- print(os.clock())
- print("Nothing found")
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement