Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 r(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
- args = {...}
- msg = table.concat(args, " ")
- rednet.open("back")
- term.setTextColor(colors.gray)
- print("Sent: \"Checking amount of " ..msg .."\"")
- term.setTextColor(colors.white)
- rednet.broadcast("inv getAmount " ..msg)
- amount = nil
- while amount == nil do
- amount = r(msg)
- end
- print("Amount: " ..amount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement