Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a = peripheral.wrap('back')
- local sp = peripheral.find('speaker')
- local lastnum = 0
- local imp = {"minecraft:diamond_ore","minecraft:gold_ore"}
- while true do
- term.clear()
- local s = a.scan()
- local oretable = {}
- for i = 1,#s do
- if string.find(s[i].name,"ore") or string.find(s[i].name,"resource") then
- if not oretable[s[i].name] then
- oretable[s[i].name] = {}
- end
- oretable[s[i].name][table.maxn(oretable[s[i].name])+1] = s[i]
- local index = oretable[s[i].name][table.maxn(oretable[s[i].name])]
- if (not oretable[s[i].name].dist) or (math.abs(index.x)+math.abs(index.y)+math.abs(index.z) < oretable[s[i].name].dist) then
- oretable[s[i].name].dist = math.abs(index.x)+math.abs(index.y)+math.abs(index.z)
- oretable[s[i].name].index = table.maxn(oretable[s[i].name])
- end
- end
- end
- local i = 1
- local spec = false
- for k,v in pairs(oretable) do
- term.setCursorPos(1,i)
- term.write(k..": "..#v)
- for j = 1,#imp do
- if imp[j] == k then
- spec = true
- end
- end
- i = i+1
- end
- if sp and i > lastnum then
- sp.playNote("harp",1,6)
- sleep(0.1)
- sp.playNote("harp",1,10)
- sleep(0.1)
- sp.playNote("harp",1,13)
- elseif sp and i < lastnum then
- sp.playNote("harp",1,9)
- sleep(0.1)
- sp.playNote("harp",1,8)
- sleep(0.1)
- sp.playNote("harp",1,6)
- end
- if sp and spec then
- sp.playNote("harp",1,25)
- sleep(0.1)
- sp.playNote("harp",1,25)
- end
- lastnum = i
- os.startTimer(1)
- while true do
- local e,a,b,c = os.pullEvent()
- if e == "mouse_click" and #oretable <= c then
- local newtable = {}
- local i = 1
- for _,v in pairs(oretable) do
- newtable[i] = v
- i = i+1
- end
- term.clear()
- term.setCursorPos(1,1)
- local tbl = newtable[c][newtable[c].index]
- term.write("X: "..tbl.x.." Y: "..tbl.y.." Z: "..tbl.z)
- term.setCursorPos(1,2)
- term.write(tbl.name)
- sleep(0.5)
- os.pullEvent("mouse_click")
- break
- elseif e == "timer" then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement