Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pri = peripheral.find("printer")
- if fs.isDir("home") then
- else fs.makeDir("home")
- end
- if fs.isDir("home/history")
- else fs.makeDir("home/history")
- end
- local stan = 1
- local prog = 1
- local br = 0
- local x10, y10 = term.getSize()
- --shell.setDir("home
- function event(event)
- local event, f, s, t, fo, fi = os.pullEvent(event)
- if event == "key" then
- if f == 200 then
- return "up"
- end
- if f == 208 then
- return "down"
- end
- if f == 28 then
- return "enter"
- end
- if f == 29 then
- return "ctrl"
- end
- end
- end
- function printerCheck(y5)
- if pri.getPaperLevel() < 2 then
- print("Not enough paper")
- return false
- else
- if pri.getInkLevel() < 2 then
- print("Not enough Ink")
- return false
- else
- local x,y = pri.getPageSize()
- if y5 == 21 then
- pri.endPage()
- if pri.newPage() then
- else
- print("Check printer")
- end
- end
- return true
- end
- end
- end
- function linia(lin,x,y)
- term.setCursorPos(x,y)
- pri.setCursorPos(x,y)
- term.setTextColor(colors.white)
- term.write(lin)
- h.writeLine(lin)
- pri.write(lin)
- end
- function dalej(y)
- term.setCursorPos(1,y)
- term.setTextColor(colors.yellow)
- term.write("By wpisac wiecej kliknij Enter")
- term.setCursorPos(1,y+1)
- term.write("By contynuowac kliknij Ctrl")
- term.setTextColor(colors.white)
- local elo = event("key")
- term.setCursorPos(1,y)
- term.write(" ")
- term.setCursorPos(1,y+1)
- term.write(" ")
- if elo =="ctrl" then
- return true
- else
- return false
- end
- end
- function create_file()
- local name = typ("File name")
- shell.setDir("home")
- shell.setDir("home/history")
- if fs.exists(name) then
- term.write("Error")
- return 1
- else
- pri.newPage()
- h = fs.open("home/history/" .. name,"w")
- term.clear()
- if printerCheck() then
- linia(name,1,1)
- linia("Umowa kupna",1,2)
- linia("Kupujacy:",1,3)
- linia(typ("Nick osoby kupujacej"),10,3)
- linia("Kupuje:",1,4)
- local y4 = 5
- repeat
- linia(typ("Produkty"),1,y4)
- y4 = y4+1
- until dalej(y4)
- linia("Placi:",1,y4)
- y4 = y4 +1
- repeat
- linia(typ("Zaplata"),1,y4)
- y4 = y4+1
- until dalej(y4)
- linia("Sprzedajacy:",1,y4)
- linia(typ("Nick osoby sprzedajacej"),13,y4)
- linia("UnPaid",1,y4+1)
- pri.endPage()
- h.writeLine(math.ceil(math.abs(math.tan(os.time())*1000000)))
- h.close()
- else
- br = 1
- end
- end
- prog = 1
- term.clear()
- print("Drukowanie")
- end
- function typ(text)
- term.setCursorPos(1,y10-1)
- term.write(" ")
- term.setCursorPos(1,y10-1)
- term.setCursorBlink(true)
- term.setTextColor(colors.yellow)
- term.write(text .. ">")
- term.setTextColor(colors.white)
- return read()
- end
- function decition()
- if prog == 1 then
- local ky = event()
- print(ky)
- term.clear()
- if ky == "up" then
- if stan == 1 then
- else
- stan = stan-1
- end
- end
- if ky == "down" then
- if stan == 3 then
- else
- stan = stan+1
- end
- end
- if ky == "enter" then
- prog = (stan + 1)
- end
- end
- dispay()
- end
- function zawarte()
- shell.setDir("home/history")
- function menu(x,y,op,s,text)
- if op == s then
- term.setCursorPos((x-((string.len(text)/2)-1)),y)
- term.setTextColor(colors.yellow)
- term.write(">")
- else
- term.setTextColor(colors.white)
- term.setCursorPos((x-(string.len(text)/2)+2),y)
- end
- term.write(text)
- if op == s then term.write("<") end
- end
- function dispay()
- if prog == 1 then
- local x, y = term.getSize()
- menu((x/2)-3,7,stan,1,"Umowa")
- menu((x/2)-3,8,stan,2,"Zawarte umowy")
- menu((x/2)-3,9,stan,3,"Konta")
- end
- if prog == 2 then
- term.clear()
- create_file()
- end
- if prog == 3 then
- term.clear()
- end
- repeat
- decition(prog)
- sleep(0.1)
- until terminated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement