Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Ventana
- local LSBotones = {}
- local backColor = colors.white
- local LSApps
- function SystemData()
- --File system
- if (fs.exists("Apps") == false) then
- fs.makeDir("Apps")
- end
- if (fs.exists("SysData") == false) then
- fs.makeDir("SysData")
- if(fs.exists("SysData/os.json")) then
- fs.delete("SysData/os.json")
- end
- end
- local file = fs.open("SysData/os.json", "w")
- file.writeLine("1.0") --os Version
- file.close()
- --Obligatory apps
- if (fs.exists("Apps/Market") == false) then
- fs.delete("Apps/Market")
- shell.execute("pastebin", "get", "U3vd1Qb5", "Apps/Market/Market.lua")
- end
- if (fs.exists("Apps/Tardis") == false) then
- fs.delete("Apps/Tardis")
- shell.execute("pastebin", "get", "yeXzddW4", "Apps/Tardis/Tardis.lua")
- end
- --Check for updates (rednet from server)
- local CurrentVersion = fs.open("SysData/os.json", "r").readLine() --os Version
- rednet.open("back")
- local ID,NewVersion = rednet.receive("Version", 1)
- rednet.close("back")
- if (NewVersion ~= nil) then
- if(NewVersion ~= CurrentVersion) then
- shell.execute("AutoUpdate.lua")
- end
- end
- end
- function Gui()
- term.clear()
- Ventana = window.create(term.current(), 1,1,26,20)
- Ventana.setBackgroundColor(backColor)
- Ventana.clear()
- --Info bar
- local IBar = window.create(term.current(),1,1,26,2)
- IBar.setBackgroundColor(colors.green)
- IBar.clear()
- IBar.write(textutils.formatTime(os.time(), false) .. " BlockDroid")
- --Crear botones
- LSBotones = {}
- LSApps = fs.list("Apps")
- local nApps = table.getn(LSApps)
- local height = 5
- for i=1,nApps,1
- do
- local path = "Apps/" .. LSApps[i] .. "/" .. LSApps[i] .. ".lua"
- if (i==1) then
- CrearBoton(5, height, 11, height+2, colors.yellow, LSApps[i], path)
- elseif (i%2==0) then
- CrearBoton(5 + 11, height, 11 + 11, height+2, colors.yellow, LSApps[i], path)
- else
- height = height+5
- CrearBoton(5, height, 11, height+2, colors.yellow, LSApps[i], path)
- end
- end
- end
- function Events()
- while(true) do
- parallel.waitForAny(
- function()
- local e, button, x, y = os.pullEvent("mouse_click");
- Gui()
- if button == 1 then
- AbrirApp(x, y)
- end
- end,
- function()
- sleep(2)
- Gui()
- end
- )
- end
- end
- function AbrirApp(x, y)
- for o = 1,#LSBotones,1 do
- if x >= LSBotones[o][1] and y >= LSBotones[o][2] and x <= LSBotones[o][3] and y <= LSBotones[o][4]
- then
- local pro = multishell.launch({}, LSBotones[o][6])
- multishell.setFocus(pro)
- multishell.setTitle(pro, LSBotones[o][5])
- end
- end
- end
- function CrearBoton(x1, y1, x2, y2, color, name, program)
- local Button = window.create(term.current(), x1, y1, x2-x1+1, y2-y1+1)
- Button.setBackgroundColor(color)
- Button.clear()
- Button.write(name)
- local i = table.getn(LSBotones) + 1
- LSBotones[i] = {x1, y1, x2, y2, name, program}
- end
- -- MAIN --
- SystemData()
- Gui()
- Events()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement