Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HopperMon = {
- hopper = peripheral.wrap("right"),
- modem = rednet.open("top"),
- sorterCompID = 5,
- }
- function HopperMon:checkHopper()
- local size = self.hopper.getSizeInventory()
- size = size - 1 -- slot number starts at 0 so subtract 1
- for slot = 0, size do
- local slotContents = self.hopper.getStackInSlot(slot)
- if slotContents == nil then
- return true
- end
- end
- return false
- end
- function HopperMon:hasSpace()
- local boolhasSpace = self:checkHopper()
- local hasSpace = ""
- if boolhasSpace then
- print("has space")
- hasSpace = "space"
- else
- print("has no space")
- hasSpace = "noSpace"
- end
- local message = '' .. tostring(os.getComputerID()) .. ':' .. hasSpace
- print("Sending " .. message)
- rednet.send(self.sorterCompID, message)
- end
- hm = HopperMon
- while true do
- event, param1, param2, param3 = os.pullEvent()
- if event == 'rednet_message' then -- number senderid, string message, number distance
- if param1 == hm.sorterCompID then
- print(param2)
- if param2:find('hasSpace') then
- hm:hasSpace()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement