Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- items = {{"Stone", 1}, {"Dirt", 3}, {"Cobble", 4}}
- function split(pString, pPattern) --("A_Small_Dog", "_")
- local Table = {}
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table, cap)
- end
- last_end = e + 1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- function getReply(uuid)
- id, message = rednet.receive()
- m = split(message, " ")
- if m[1] == "inv" then
- if m[2] == "replyAmount" then
- if tonumber(m[3]) == tonumber(uuid) then
- return m[4]
- end
- end
- end
- return nil
- end
- mon = peripheral.wrap("left")
- mon.clear()
- rednet.open("back")
- while true do
- for i=1, #items do
- rednet.broadcast("inv getAmount " ..items[i][2])
- amount = nil
- while amount == nil do
- amount = getReply(items[i][2])
- end
- mon.setCursorPos(1, i)
- mon.write(items[i][1] ..": " ..amount)
- end
- sleep(30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement