Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local colorscp = colorscp
- local colorsbp = colorsbp
- local paperp = paperp
- local component = require("component")
- local term = require("term")
- local computer = require("computer")
- local keyboard = require("keyboard")
- local gpu = component.gpu
- local colortable = {
- {name = "red", hex = 0xAA0000, hexs = "0xAA0000"},
- {name = "green", hex = 0x00AA00, hexs = "0x00AA00"},
- {name = "blue", hex = 0x0000AA, hexs = "0x0000AA"},
- {name = "black", hex = 0x000000, hexs = "0x000000"},
- {name = "gray", hex = 0xAAAAAA, hexs = "0xAAAAAA"},
- {name = "white", hex = 0xFFFFFF, hexs = "0xFFFFFF"},
- {name = "aqua", hex = 0x00AAAA, hexs = "0x00AAAA"},
- {name = "gold", hex = 0xFFAA00, hexs = "0xFFAA00"}
- }
- local curcolor = curlolor
- if component.isAvailable("openprinter") then
- local printer = component.openprinter
- local color = 0x0000ff
- while true do
- term.clear()
- --╔═╗╚╝║
- print(
- [[
- ╔═══════════════════════════╗
- ║add text : для добавления ║
- ║текста в очередь принтера. ║
- ║print : для начала печати ║
- ║color : для выбора цвета ║
- ║exit : для корректного ║
- ║выхода из программы. ║
- ╚═══════════════════════════╝
- ]])
- if printer.getColorInkLevel() == false then
- colorscp = 0
- else
- colorscp = math.floor( printer.getColorInkLevel() / 4000 * 100 )
- end
- if printer.getBlackInkLevel() == false then
- colorsbp = 0
- else
- colorsbp = math.floor( printer.getBlackInkLevel() / 4000 * 100 )
- end
- if printer.getPaperLevel() == false then
- paperp = 0
- else
- paperp = math.floor( printer.getPaperLevel() / 256 * 100 )
- end
- print("Цветная краска : "..colorscp.."% Черная краска : "..colorsbp.."%")
- print("Бумага : "..paperp.."%")
- io.write('printer >> ')
- local string = io.read()
- if string.sub(string, 1, 3) == "add" then
- term.clear()
- local text = {}
- printer.writeln(string.sub(string, 5),color,"center")
- end
- if string.sub(string, 1, 5) == "color" then
- term.clear()
- local curbackcolor = gpu.getBackground()
- local curtextcolor = gpu.getForeground()
- local I = 0
- if gpu.getDepth() > 1 then
- for k, v in pairs(colortable) do
- I = I + 1
- gpu.setBackground( v.hex )
- gpu.setForeground( 0xFFFFFF-v.hex )
- gpu.set(1,I,v.name)
- gpu.set(8,I,v.hexs)
- end
- gpu.setBackground(curbackcolor)
- gpu.setForeground(curtextcolor)
- else
- for k, v in pairs(colortable) do
- I = I + 1
- gpu.set(1,I,v.name)
- gpu.set(8,I,v.hexs)
- end
- end
- for _ = 1,#colortable/2 do
- print("\n")
- end
- io.write('color >> ')
- local string = io.read()
- for k, v in pairs(colortable) do
- if v.name == string then
- color = v.hex
- end
- end
- end
- if string.sub(string, 1, 5) == "print" then
- term.clear()
- print("Идет распечатка...")
- printer.print()
- os.sleep(2)
- end
- if string.sub(string, 1, 4) == "exit" then
- term.clear()
- print('Выход из программы произведен успешно. \n')
- break
- end
- end
- else
- component.computer.beep(100,0.1)
- component.computer.beep(100,0.1)
- io.stderr:write('Принтер не найден. \n')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement