Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- call function(s)
- input()
- wrap()
- send()
- -- predefined variables
- -- input
- function input()
- print("Frequency ?")
- local event, key = os.pullEvent(key)
- local sf = key
- print("complex number ?")
- local event, key = os.pullEvent(key)
- local complexnumber = key
- end
- -- wrap modem and drums
- function wrap()
- local modem = peripheral.wrap("left")
- local sides = {}
- sides[1] = "front"
- sides[2] = "right"
- sides[3] = "back"
- sides[4] = "bottom"
- sides[5] = "top"
- for k,_ in pairs(sides) do
- if peripheral.isPresent(sides[k]) then
- print(peripheral.getType(sides[k])," on ",sides[k]," found")
- drum = peripheral.wrap(sides[k])
- Tankinfo = drum.getTankInfo("down")
- -- checks if there is a fluid in the drum to avoid a nil value
- if Tankinfo[1].contents then
- if peripheral.getType(sides[k]) == "drum" then
- print(Tankinfo[1].contents.name," in drum ",sides[k])
- end
- else
- print("no fluid in drum ",sides[k])
- end
- else
- print("no item found on side ",sides[k])
- end
- end
- sleep(2)
- term.clear()
- term.setCursorPos(1,1)
- print("automation active")
- end
- function send()
- modem.closeAll()
- modem.open(sf)
- local drumcounter = 0
- for k,_ in pairs(sides) do
- if peripheral.isPresent(sides[k]) then
- drum = peripheral.wrap(sides[k])
- Tankinfo = drum.getTankInfo("down")
- -- checks if there is a fluid in the drum to avoid a nil value
- if peripheral.getType(sides[k]) == "drum" then
- if Tankinfo[1].contents then
- local drumcounter = drumcounter+1
- transmit(sf,1,complexnumber)
- transmit(sf,1,Tankinfo[1].content.name)
- transmit(sf,1,Tankinfo[1].content.amount)
- print("drumcounter: ",drumcounter," nonemptydrum"")
- else
- local drumcounter = drumcounter+1
- transmit(sf,1,complexnumber)
- tramsmit(sf,1,"empty")
- transmit(sf,1,0)
- print("drumcounter: ",drumcounter," emptydrum")
- end
- end
- end
- transmit(sf,1,drumcounter)
- tramsmit(sf,1,"done")
- print("end send")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement