Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = peripheral.wrap("back")
- m = peripheral.wrap("left")
- if os.getComputerLabel() == nil then
- os.setComputerLabel("lower")
- end
- thing = "cobble"
- Output = 2 -- 2 = North, 3 = South, 4 = West, 5 = East
- data = p.list(1)
- m.open(49794)
- function split(str, delim, maxNb)
- if string.find(str, delim) == nil then
- return { str }
- end
- if maxNb == nil or maxNb < 1 then
- maxNb = 0
- end
- local result = {}
- local pat = "(.-)" ..delim.. "()"
- local nb = 0
- local lastPos
- for part, pos in string.gmatch(str, pat) do
- nb = nb + 1
- result[nb] = part
- lastPos = pos
- if nb == maxNb then
- break
- end
- end
- if nb ~= maxNb then
- result[nb + 1] = string.sub(str,lastPos)
- end
- return result
- end
- for k, v in pairs(data) do
- id = k
- print(k)
- end
- while true do
- event, side, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- print(message)
- Table = {}
- Table = split(message, ":")
- item = tostring(Table[1])
- amount = tonumber(Table[2])
- print(item)
- print(amount)
- if item == thing then
- p.extract(1,id,Output,amount)
- m.transmit(32036, 49794, thing..":"..tostring(amount))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement