Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tdb = peripheral.wrap("right")
- local isto = peripheral.wrap("top")
- local osto = peripheral.wrap("bottom")
- local mot = peripheral.wrap("left")
- local motw, moth = mot.getSize()
- local zoom =2
- local function mainloop()
- while 1 do
- mot.clear()
- mot.setCursorPos(1,1)
- local ret,res = tdb.getTrades();
- mot.setTextScale(1)
- for i,j in pairs(res) do
- -- local y = (i-1)*2 + 1
- local y = (i-1)*zoom + 1
- for k,l in pairs(j["result"]) do
- local div = string.find(k,":")
- mot.setCursorPos(1,y)
- local result = j["result"]
- for key, value in pairs(result) do
- if key == "minecraft:enchanted_book" then
- -- find enchanted_book
- local enchants = value["enchants"]
- for key, value in pairs(enchants) do
- local ret = nil
- local pos = string.find(key,":")
- key = string.sub(key,pos+1)
- mot.write("book :"..key)
- end
- else
- mot.write(string.sub(k,div+1))
- end
- end
- -- mot.write(string.sub(k,div+1))
- -- end
- end
- end
- os.sleep(3);
- end
- end
- local function clickCatch()
- while 1 do
- local event, side, mx, my = os.pullEvent("monitor_touch")
- if (event ~= nil) then
- print("mx",mx,"my",my)
- local ret,res2 = tdb.getTrades()
- local tdsize = table.getn(res2)
- for i=zoom+1,moth,zoom do
- if((i-1)/zoom > tdsize) then
- break
- end
- if ( my < i ) then
- tdb.trade("top","bottom",(i-1)/zoom)
- break
- end
- end
- end
- end
- end
- parallel.waitForAll(mainloop,clickCatch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement