Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for k,v in pairs(peripheral.getNames()) do
- if peripheral.getType(peripheral.getNames()[k]) == "modem" then
- rednet.open(peripheral.getNames()[k])
- end
- end
- chest = peripheral.wrap("bottom")
- while true do
- info1,info2,info3,info4 = os.pullEvent()
- if info1 == "rednet_message" then
- if type(info3) == "table" then
- if info3["action"] == "getItemCount" then
- itemCount = nil
- itemCount = chest.getItemDetail(info3["item"])
- if itemCount == nil then
- itemCount = 0
- else
- itemCount = itemCount["count"]
- end
- rednet.send(info2,{["action"]="sendingItemCount",["itemCount"]=itemCount})
- end
- if info3["action"] == "buy" then
- for k,v in pairs(info3["order"]) do
- repeat
- chest.pushItems("front",info3["order"][k]["slot"],info3["order"][k]["amount"])
- info3["order"][k]["amount"] = info3["order"][k]["amount"]-64
- until info3["order"][k]["amount"] < 1
- end
- end
- if info3["action"] == "getItemNames" then
- items = {}
- slots = {}
- for k,v in pairs(chest.list()) do
- table.insert(items,chest.getItemDetail(k)["displayName"])
- table.insert(slots,k)
- end
- rednet.send(info2,{["action"]="sendingItemNames",["itemNames"]=items,["itemSlots"]=slots})
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment