Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local verze = "20.0904.R1"
- local anim = 0.1
- local RamCesta = ("/C/system/RAM/elektro")
- local dataPath = "/C/system/Users/Administrator/Desktop/database/"
- local w, h = term.getSize()
- ----------------------------------------------------
- local f=fs.open("/C/system/RAM/user","r")
- user=f.readLine()
- f.close()
- if fs.exists("/C/system/.core/defmodem") then
- local data = fs.open ("/C/system/.core/defmodem","r")
- modemPos = data.readLine()
- data.close()
- MyID = os.getComputerID()
- modem = peripheral.wrap("top")
- modem.open(MyID)
- if not modemPos then
- fs.delete("/C/system/.core/defmodem")
- modemPos = "offline"
- end
- else
- modemPos = "offline"
- end
- local function bgc(barvaP) term.setBackgroundColor(barvaP) end
- local function txc(barvaP) term.setTextColor(barvaP) end
- local function curs(xi,yi) term.setCursorPos(xi,yi) end
- local function Barvy()
- 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 BarPoz == nil or BarTxt == nil then BarPoz = 2048 BarTxt = 1 end
- end
- local function prc(text, y)
- local w = term.getSize()
- local _, cy = term.getCursorPos()
- curs(math.ceil((w-#text)/2), y or cy)
- write(text)
- end
- function ukonceni ()
- fs.delete (RamCesta)
- error()
- end
- function cbarva()
- lista.setTextColor(colors.black)
- lista.setBackgroundColor(colors.gray)
- end
- function defaultvalue()
- end
- function start()
- defaultvalue()
- Barvy()
- local myWindow = window.create(term.current(),w/2-11,h/2-5,25,9)
- myWindow.setBackgroundColor(colors.green)
- myWindow.setTextColor(colors.white)
- myWindow.clear()
- myWindow.setCursorPos (5, 5)
- myWindow.write"Spravce Elektra"
- myWindow.setCursorPos (1, 1)
- myWindow.write"Pepek@Soft"
- myWindow.setCursorPos (22, 9)
- myWindow.write"2023"
- sleep(1)
- menu()
- end
- function plocha()
- w, h = term.getSize()
- paintutils.drawLine(1, 1, 51, 1, BarPoz)
- paintutils.drawPixel (51,1, colors.red)
- term.setCursorPos (51,1)
- term.setTextColor(BarTxt)
- write "X"
- barW = window.create(term.current(),1,2,w,1)
- barW.setBackgroundColor(colors.gray)
- barW.clear()
- barW.setTextColor(colors.white)
- barW.setCursorPos(2,1)
- barW.write"Mereni spotreby >"
- pozadi = window.create(term.current(),13,3,w,h-2)
- pozadi.setBackgroundColor(colors.white)
- pozadi.setTextColor(colors.black)
- pozadi.clear()
- lista = window.create(term.current(),1,3,12,h-2)
- lista.setBackgroundColor(BarPoz)
- lista.setTextColor(BarTxt)
- lista.clear()
- lista.setCursorPos(2,3)
- lista.write"Prehled"
- lista.setCursorPos(2,5)
- lista.write"Fakturace"
- lista.setCursorPos(2,h-2)
- lista.setTextColor(colors.white)
- lista.write("Pepek@Soft")
- term.setBackgroundColor(colors.lightGray)
- end
- -----------------------------------------------------------------------------
- local page = "main"
- function main()
- barW.setCursorPos(21,1)
- barW.write"Prehled"
- barW.setCursorPos(19,1)
- barW.setCursorPos(w-7,1)
- barW.write"Refresh"
- SerT = window.create(term.current(),14,6,w-14,h-6)
- ww, hh = SerT.getSize()
- SerT.setBackgroundColor(colors.lightBlue)
- SerT.setTextColor(colors.black)
- SerT.clear()
- if fs.exists("/database/") then
- cUsr = fs.list("/database/")
- local a=1
- for i = 1, #cUsr do
- if tonumber(cUsr[i]) ~= nil then
- name = tostring(cUsr[i])
- SerT.setBackgroundColor(colors.lightBlue)
- SerT.setCursorPos(2,a)
- SerT.write(cUsr[i])
- SerT.write(",")
- if fs.exists ("/database/"..cUsr[i].."/info.txt") then
- local data = fs.open("/database/"..cUsr[i].."/info.txt", "r")
- SerT.setCursorPos(8,a)
- SerT.write(data.readLine())
- SerT.write(",")
- SerT.setBackgroundColor(colors.lightGray)
- SerT.setCursorPos(ww-3,a)
- SerT.write("Read")
- SerT.setCursorPos(ww-8,a)
- SerT.write("Null")
- end
- a = a+1
- end
- end
- end
- end
- function menu()
- plocha()
- if (page == "main") then
- main ()
- end
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if event == "mouse_click" and x >= 2 and x <= 12 and y == 5 then
- cbarva()
- lista.setCursorPos(1,3)--
- lista.write" Prehled "
- sleep(anim)
- page = "main"
- menu()
- elseif event == "mouse_click" and x >= 2 and x <= 12 and y == 7 then
- cbarva()
- lista.setCursorPos(1,5)--
- lista.write" Fakturace "
- sleep(anim)
- modem.transmit(132,8083,"test")
- page = "main"
- menu()
- elseif event == "mouse_click" and x >= w-10 and x <= w-1 and y >= 6 then
- if x>= w-10 and x <= w-6 then
- modem.transmit(tonumber(cUsr[y-5]),8083,"Nulovat")
- SerT.setBackgroundColor(colors.gray)
- SerT.setCursorPos(ww-8,y-5)
- SerT.write("Null")
- end
- if x>= w-5 and x <= w-1 then
- modem.transmit(tonumber(cUsr[y-5]),8082,"Precist")
- SerT.setBackgroundColor(colors.gray)
- SerT.setCursorPos(ww-3,y-5)
- SerT.write("Read")
- end
- sleep(anim)
- page = "main"
- menu()
- end
- if x == 51 and y == 1 then
- ukonceni ()
- else
- menu() -------- stejne jako nazev funkce
- end
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement