Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --emit List Feeder
- --written na Draddy
- local chest
- local file = "disk/emitList"
- local userRead = {}
- local me
- local cItem = nil
- local sItem
- function initPeripherals()
- local per = peripheral.getNames()
- for i=1,#per do
- --Monitor
- if peripheral.getType(per[i]) == "monitor" then
- monitor = peripheral.wrap(per[i])
- --Modem(s)
- elseif peripheral.getType(per[i]) == "modem" then
- m = peripheral.wrap(per[i])
- if m.isWireless() and useRemote then
- modem = peripheral.wrap(per[i])
- os.loadAPI("disk/wirelessSend.lua")
- else
- cModem = peripheral.wrap(per[i])
- end
- --bundeld Redstone cable
- elseif peripheral.getType(per[i]) == "ccmp:saved_multipart" then
- cablePos = per[i]
- --ME System
- elseif string.find(peripheral.getType(per[i]), "appliedenergistics2:") then
- me = peripheral.wrap(per[i])
- --Chest
- elseif string.find(peripheral.getType(per[i]), "chest") then
- chest = peripheral.wrap(per[i])
- end
- end
- end
- --check for item in chest
- function checkChest()
- if chest then cItem = chest.list() end
- end
- --find item in me system
- function checkMe()
- if cItem then sItem = me.findItem(cItem[1].name .."@" ..cItem[1].damage).getMetadata() end
- end
- --ask User and return answer
- function getUserInput(ask)
- print(ask)
- answer = read()
- return answer
- end
- --main - User Interaction
- function main()
- monitor.clear()
- monitor.setCursorPos(1,2)
- monitor.write("Put item in chest,")
- monitor.setCursorPos(1,3)
- monitor.write("and follow terminal")
- while true do
- userRead = {}
- cItem ={}
- checkChest()
- term.clear()
- term.setCursorPos(1,1)
- if #cItem == 0 then
- print("please put the Item you want to add in the Chest")
- else
- checkMe()
- ask = "found item ".. sItem.displayName .. " in chest. Add to emitList? (y/n)"
- ans = getUserInput(ask)
- if string.upper(ans) == "YES" or string.upper(ans) == "Y" or string.upper(ans) == "JA" or string.upper(ans) == "J" then
- userRead.displayName = sItem.displayName
- userRead.name = sItem.name
- userRead.damage = sItem.damage
- --print (userRead.displayName.. " " ..userRead.name.. " " ..userRead.damage)
- ask = "please enter the lower item limit"
- ans = getUserInput(ask)
- if tonumber(ans) ~= nil then userRead.min = tonumber(ans) else print(ans .." is not a number, set to 0") userRead.min = 0 end
- --print (userRead.min)
- ask = "please enter the upper item limit"
- ans = getUserInput(ask)
- if tonumber(ans) ~= nil then userRead.max = tonumber(ans) else print(ans .." is not a number, set to 1000") userRead.max = 1000 end
- --print (userRead.max)
- ask = "emit signal if (a)bove oder (b)elow limit?"
- ans = getUserInput(ask)
- if string.upper(ans) == "B" then userRead.emit = "low" elseif string.upper(ans) == "A" then userRead.emit = "high" else userRead.emit = "low" end
- --print (userRead.emit)
- ask = "what signal color?"
- ans = getUserInput(ask)
- userRead.color = ans
- --print (userRead.color)
- userRead.initEmit = false
- end
- rs.setOutput("bottom", true)
- end
- --print(userRead.displayName ..", "..userRead.name ..", "..userRead.damage ..", "..userRead.min ..", "..userRead.max ..", "..userRead.emit ..", "..userRead.color)
- ask = "write to file? (y/n)"
- ans = getUserInput(ask)
- if string.upper(ans) == "YES" or string.upper(ans) == "Y" or string.upper(ans) == "JA" or string.upper(ans) == "J" then
- fw = fs.open(file, "a")
- fw.writeLine("{displayName = "..textutils.serialise(userRead.displayName) .. ", name = " ..textutils.serialise(userRead.name) .. ", damage = " ..textutils.serialise(tostring(userRead.damage)) .. ", min = " ..textutils.serialise(userRead.min) .. ", max = " ..textutils.serialise(userRead.max) .. ", emit = " ..textutils.serialise(userRead.emit) .. ", color = " ..textutils.serialise(userRead.color) .. ", initEmit = " ..textutils.serialise(userRead.initEmit) .."}")
- fw.close()
- end
- sleep(10)
- rs.setOutput("bottom", false)
- end
- end
- initPeripherals()
- main()
Advertisement
Add Comment
Please, Sign In to add comment