Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variables
- local iS = peripheral.wrap("back")
- local iO = peripheral.wrap("left")
- local m = peripheral.wrap("monitor_38")
- local dataL = {}
- --Functions
- function load()
- local file = fs.open("data","r")
- if file ~= nil then
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- end
- function tfc()
- mmsg("Charging ",2,2,8)
- cha = true
- k = 0
- while cha do
- itz = iS.list(0)
- if itz ~= nil then
- for itzst, kk in pairs(itz) do
- for it0, st in pairs(dataL) do
- for i = 1, 27 do
- if itzst == st[i] then
- for j = 1, 26 do
- if dataL[it0][j] == itzst then
- mmsg(" "..(26-j)*(3.7).."% ",1,3,64)
- k = 1
- end
- end
- end
- end
- if it0 == itzst then
- mmsg(" Complete ",1,3,64)
- sleep(0.5)
- mmsg(" ",1,3,1)
- mmsg("MFSU Empty ",2,2,8)
- sleep(0.2)
- iS.extract(0,itzst,1,1)
- iO.setOutput(colors.green)
- cha = false
- end
- end
- end
- if k == 0 then cha = false end
- end
- sleep(0.2)
- end
- end
- function msg(mes,h,j,col)
- term.setCursorPos(h,j)
- term.setTextColor(col)
- print(mes)
- end
- function mmsg(mes,h,j,col)
- m.setCursorPos(h,j)
- m.setTextColor(col)
- m.write(mes)
- end
- function extract()
- ev = os.pullEvent("redstone")
- itz = iS.list(0)
- for v , t in pairs(itz) do
- iS.extract(0,v,1,1)
- end
- mmsg(" ",1,3,1)
- mmsg("MFSU Empty ",2,2,8)
- iO.setOutput(colors.green)
- sleep(2.7)
- end
- function input()
- p = true
- while p do
- k = 0
- l = iS.list(1)
- if l ~= nil then
- for itsS , kk in pairs(l) do
- for it0 , st in pairs(dataL) do
- for j = 1, 27 do
- if itsS == st[j] then
- k = 1
- mmsg("Put in MFSU ",2,2,8)
- iS.extract(1,itsS,0,1)
- iO.setOutput(colors.red)
- sleep(0.2)
- tfc()
- end
- end
- end
- end
- if k == 0 then p = false end
- else p = false
- end
- sleep(0.2)
- end
- end
- --Code
- m.clear()
- term.clear()
- msg("Working",5,1,colors.lime)
- mmsg("Working",5,1,colors.lime)
- dataL = load()
- if dataL ~= nil then
- while true do
- msg("Wait for item",3,2,8)
- ev, p1 = os.pullEvent()
- if ev == "redstone" then
- sleep(0.2)
- tfc()
- sleep(2.7)
- parallel.waitForAny(input,extract)
- end
- if (ev == "key") and ( p1 == 16 ) then
- iO.setOutput(0)
- msg("Stopped",5,3,colors.red)
- mmsg("Stopped",5,5,colors.red)
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement