Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trade = peripheral.wrap("right") -- The side of the trading post
- pages = {}
- function getId() -- Retuns the villager ids needed for trading
- return trade.getVillagerIds()
- end
- function getTradeInfo(id) -- Returns trading information needed
- local sold = trade.getItemSold(id,0)
- local bought = trade.getItemBought(id,0)
- return sold.name, sold.qty, sold.rawName, bought.name, bought.qty, id
- end
- loadPages()
- while true do
- ids = getId() -- First get the ids of all close villagers
- term.clear()
- term.setCursorPos(1,1)
- for index, idnum in pairs(ids) do -- Loop through the ids
- sold,soldQty ,rawName,bought,boughtQty, id = getTradeInfo(idnum) -- Get information on what the villagers is trading
- if rawName == "item.emerald" then -- if it is a page and i dont already have it
- if trade.performTrade(id, 0) then -- Then buy it
- print("New page added!")
- else
- print("Failed to buy page!") -- Probably not enough emeralds
- end
- end
- end
- sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment