Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verze = "21.0629.R1"
- local printer = nil
- local tArgs = { ... }
- local sound = false
- local w, h = term.getSize()
- local opakovat = false
- if fs.exists("/C/system/RAM/devices/speaker.tmp") then
- sound = true
- end
- function song(type)
- if sound then shell.run("/C/system/api/sound.api "..type) end
- end
- local function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- local f=fs.open("/C/system/RAM/user","r")
- user=f.readLine()
- pass=f.readLine()
- Fname=f.readLine()
- Lname=f.readLine()
- f.close()
- if fs.exists ("/C/system/Users/"..user.."/.Registry/colors") then
- local data = fs.open("/C/system/Users/"..user.."/.Registry/colors", "r")
- BarPoz = tonumber(data.readLine())
- BarTxt = tonumber(data.readLine())
- data.close()
- end
- if fs.exists("/C/system/RAM/devices/printer.tmp") then
- printers = {}
- printers = load("/C/system/RAM/devices/printer.tmp")
- printer = peripheral.wrap(tostring(printers[0]))
- if printer == nil then printer = peripheral.wrap(tostring(printers[1])) end
- else
- printer = peripheral.find("printer")
- end
- function chyba(duvod)
- myWindow = window.create(term.current(),w/2-8,h/2-2,20,6)
- myWindow.setBackgroundColor(colors.white)
- myWindow.setTextColor(colors.white)
- myWindow.clear()
- myWindow.setBackgroundColor(colors.red)
- myWindow.setCursorPos (20, 1)
- myWindow.write"X"
- myWindow.setCursorPos (1, 1)
- myWindow.setBackgroundColor(BarPoz)
- myWindow.setTextColor(BarTxt)
- myWindow.write" Print Error! "
- myWindow.setBackgroundColor(colors.white)
- myWindow.setTextColor(colors.red)
- if duvod == "papir" then
- myWindow.setCursorPos (1, 3)
- myWindow.write"Please check printer"
- myWindow.setTextColor(colors.black)
- myWindow.setBackgroundColor(colors.lightGray)
- myWindow.setCursorPos (3, 5)
- myWindow.write" Retry "
- myWindow.setCursorPos (11, 5)
- myWindow.write" Storno "
- end
- song("stop")
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if event == "mouse_click" and x == math.floor(w/2+11) and y == math.floor(h/2-2) and button == 1 then
- error()
- elseif event == "mouse_click" and x >= math.floor(w/2-6) and x <= math.floor(w/2) and y == math.floor(h/2+2) and button == 1 then
- myWindow.setBackgroundColor(colors.gray)
- myWindow.setCursorPos (3, 5)
- myWindow.write" Retry "
- success = printer.newPage()
- if not radek == nil then i = radek opakovat = true end
- sleep(0.2)
- rozlozit(tArgs[1])
- elseif event == "mouse_click" and x >= math.floor(w/2+2) and x <= math.floor(w/2+9) and y == math.floor(h/2+2) and button == 1 then
- myWindow.setBackgroundColor(colors.gray)
- myWindow.setCursorPos (11, 5)
- myWindow.write" Storno "
- sleep(0.2)
- error()
- end
- end
- end
- function rozlozit(dokument)
- if not opakovat then
- file = fs.open(dokument, "r")
- if fs.exists(dokument) then
- if file then
- i = 0
- while file.readLine() do
- i = i + 1
- end
- file.close()
- end
- end
- q = 1
- else
- opakovat = false
- end
- success = printer.newPage()
- if success then
- local data = fs.open (dokument, "r")
- for a=1,i do
- if success then
- printer.setCursorPos(1, q)
- text = data.readLine()
- printer.write(text)
- q = q+1
- if q > 21 then
- q = 1
- printer.endPage()
- success = printer.newPage()
- end
- end
- if not success then
- radek = i
- chyba("papir")
- end
- end
- printer.endPage()
- song("print")
- error()
- else
- chyba("papir")
- end
- end
- if #tArgs > 0 then
- rozlozit(tArgs[1])
- else
- song("error")
- end
Add Comment
Please, Sign In to add comment