Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ASK = true -- При false пишет все с адреса DISKS, при true спрашивает субфолдер
- DISKS = "/ft/" -- Абсолютный адрес фолдера с образами дисков
- SLEEP_TIME = 10 -- время между проверками новой дискеты в режиме ASK = false
- HOPPER_SIDE = 4 -- сторона провода к воронке от ПК/блока Redstone IO
- CHANGE_RES = true -- позволить изменять разрешение экрана
- fs = require("filesystem")
- table = require("table")
- os = require("os")
- shell = require("shell")
- event = require("event")
- component = require("component")
- rs = component.redstone
- if ASK == true then
- gpu = component.gpu
- term = require("term")
- isolist = {}
- for list in fs.list(DISKS) do
- table.insert(isolist,list)
- end
- resx, resy = gpu.getResolution()
- end
- filesystems = {}
- for list in fs.list("/mnt") do
- table.insert(filesystems, list)
- end
- function findNewDisk()
- newfslist = {}
- for list in fs.list("/mnt") do
- table.insert(newfslist, list)
- end
- for i=1,#newfslist,1 do
- if newfslist[i] ~= filesystems[i] then
- return newfslist[i]
- end
- end
- return false
- end
- function drawIface(redid)
- term.clear()
- for i=1,#isolist,1 do
- if redid == i then
- gpu.setBackground(0xFF0000)
- else
- gpu.setBackground(0x0000FF)
- end
- textlen = string.len(isolist[i]) - 1
- text = string.sub(isolist[i],1,textlen)
- if string.sub(text,1,1) == "_" then
- text = string.sub(text,2,textlen)
- textlen = textlen - 1
- end
- startx = ((resx - textlen) / 2) + 1
- starty = i * 2
- if starty > resy then
- print("Слишком много субфолдеров или слишком мало экранного места")
- error()
- end
- gpu.set(startx,starty,text)
- gpu.setBackground(0x000000)
- end
- end
- function burnDisk(disk,addr)
- addr = DISKS..addr -- теперь абсолютный
- if disk == false then return false end
- shell.setWorkingDirectory("/mnt/"..disk)
- if addr ~= DISKS.."_[EJECT]/" then
- shell.execute("rm -r ./*") -- чистим дискетку
- shell.execute("cp -r "..addr.."* ./")
- end
- rs.setOutput(HOPPER_SIDE,0)
- os.sleep(0.5)
- rs.setOutput(HOPPER_SIDE,15)
- end
- rs.setOutput(HOPPER_SIDE,15)
- if ASK == true then
- if CHANGE_RES == true then
- maxlen = string.len(isolist[1]) - 1
- if string.sub(isolist[1],1,1) == "_" then -- _[EJECT]/
- maxlen = maxlen - 1
- end
- for i=1,#isolist,1 do
- templen = string.len(isolist[i]) - 1
- if string.sub(isolist[i],1,1) == "_" then
- templen = templen - 1
- end
- if templen > maxlen then maxlen = templen end
- end
- newresx = maxlen + 2
- newresy = (#isolist * 2) + 1
- gpu.setResolution(newresx,newresy)
- resx,resy = gpu.getResolution()
- end
- while true do
- drawIface(99) -- чтобы точно не раскрасило ничего лишнего
- _, _, _, clicky = event.pull("touch")
- if clicky % 2 == 0 and clicky / 2 <= #isolist then
- drawIface(clicky/2)
- burnDisk(findNewDisk(),isolist[clicky/2])
- end
- end
- else
- while true do
- os.sleep(SLEEP_TIME)
- newDisk = findNewDisk()
- if newDisk ~= false then
- burnDisk(newDisk,".")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement