Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local win_main = window.create(term.current(),0,0,27,18)
- local win_menu = window.create(term.current(),0,18,27,3)
- local goe = peripheral.wrap("back")
- local x,y,z
- local edgex = 26
- local edgey = 20
- local centerx = 13
- local centerz = 9
- local fontColor = "0"
- win_main.setBackgroundColor(colors.white)
- win_main.clear()
- win_menu.setBackgroundColor(colors.black)
- win_menu.clear()
- -- 只需要在这里注册方块信息即可
- local items = {
- ["gold"] = "4",
- ["iron"] = "c",
- ["diamond"] = "3",
- ["zinc"] = "8",
- ["copper"] = "1",
- ["redstone"] = "e",
- ["lapis"] = "b",
- ["emerald"] = "d",
- ["debris"] = "7"
- }
- local locks = {}
- for i,j in pairs(items) do
- table.insert(locks,true)
- end
- local function resetlock(state)
- local cal = 1
- for i,j in pairs(locks) do
- locks[cal] = state
- cal = cal+1
- end
- end
- term.setCursorPos(1,edgey)
- for i,j in pairs(items) do
- term.blit(" ",fontColor,j)
- term.blit(" ",fontColor,j)
- end
- local pic_resetbtn = paintutils.loadImage("geodetect/pic/rsb.nfp")
- paintutils.drawImage(pic_resetbtn,24,19)
- local function mainloop()
- while 1 do
- win_main.clear()
- paintutils.drawPixel(centerx,centerz,colors.pink)
- local res = goe.scan(8)
- for i,j in pairs(res) do
- local target
- if (string.find(j["name"],"ore") or string.find(j["name"],"debris")) then
- local cal = 1;
- for k,l in pairs(items) do
- -- print(i)
- if (locks[cal] and string.find(j["name"], k)) then
- target = l
- break
- end
- cal = cal+1
- end
- end
- if(target ~= NULL ) then
- x = j["x"]
- y = j["y"]
- z = j["z"]
- local chd = " "
- if(y < 0) then
- chd = string.char(25)
- elseif (y > 0) then
- chd = string.char(24)
- end
- term.setCursorPos(centerx + x,centerz + z)
- term.blit(chd,fontColor,target)
- end
- end
- os.sleep(4)
- end
- end
- local function clickMonitor()
- while 1 do
- local event, button, mx, my = os.pullEvent("mouse_click")
- if (event ~= nil) then
- if(my > 19 and (mx <19 or mx >23)) then
- resetlock(false)
- local cal = 1
- if(mx > 23) then
- resetlock(true)
- else
- for i,j in pairs(items) do
- if (mx < cal*2 + 1) then
- locks[cal] = true
- break
- end
- cal = cal + 1
- end
- end
- end
- end
- end
- end
- parallel.waitForAll(mainloop, clickMonitor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement