Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local trading = component.trading
- local modem = component.modem
- local E = require("event")
- local port, s, e, i, o = 789, 1
- local t = trading.getTrades()
- modem.open(port)
- if t.n == 0 then
- modem.broadcast(port, "I don't see the villagers.")
- os.exit()
- end
- while true do
- t = trading.getTrades()
- if t[s].isEnabled() then
- modem.broadcast(port, "#"..s)
- o, i, i2 = t[s].getOutput(), t[s].getInput()
- modem.broadcast(port, "You: "..i.label.." ["..i.size.."]")
- if i2 then
- modem.broadcast(port, " "..i2.label.." ["..i2.size.."]")
- end
- modem.broadcast(port, "\nVillager: "..o.label.." ["..o.size.."]")
- if o.enchantments then
- for k = 1, #o.enchantments do
- modem.broadcast(port, "\t", o.enchantments[k].label)
- end
- end
- end
- e = {E.pull("modem_message")}
- if e[6] == "200" then
- if s == t.n then
- s = 1
- else
- s = s + 1
- end
- elseif e[6] == "208" then
- if s == 1 then
- s = t.n
- else
- s = s - 1
- end
- elseif e[6] == "28" then
- modem.broadcast(port, t[s].trade())
- E.pull("modem_message")
- else
- os.exit()
- end
- end
Add Comment
Please, Sign In to add comment