Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.find("modem", rednet.open)
- local Ventana, LSApps
- local LSBotones = {}
- local backColor,appColor,textColor
- local Page = 1
- 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()
- --Auto install
- if (fs.exists("startup.lua") == false) then
- shell.execute("pastebin", "get", "Yir91aUq", "startup.lua")
- end
- --Options
- if (fs.exists("SysData/options.txt") == false) then
- file = fs.open("SysData/options.txt", "w")
- file.writeLine(colors.cyan) --Background color
- file.writeLine(colors.yellow) --App color
- file.writeLine(colors.white) --Text color
- file.close()
- end
- file = fs.open("SysData/options.txt", "r")
- backColor = tonumber(file.readLine()) --Background color
- appColor = tonumber(file.readLine()) --App color
- textColor = tonumber(file.readLine()) --Text color
- file.close()
- --Obligatory apps
- local LSApps ={
- {"Market", "U3vd1Qb5"},
- {"Options", "J9hVM3gx"}
- }
- for a=1,#LSApps,1 do
- if (fs.exists("Apps/" .. LSApps[a][1]) == false) then
- fs.delete("Apps/" .. LSApps[a][1])
- shell.execute("pastebin", "get", LSApps[a][2], "Apps/" .. LSApps[a][1] .. "/" .. LSApps[a][1] .. ".lua")
- local fUID = fs.open("Apps/" .. LSApps[a][1] .. "/UID.txt", "w")
- fUID.write(LSApps[a][2])
- fUID.close()
- end
- end
- end
- function Gui()
- term.setBackgroundColor(backColor)
- term.setTextColor(textColor)
- 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,1)
- IBar.setBackgroundColor(colors.green)
- IBar.clear()
- IBar.setCursorPos(1,1)
- IBar.setTextColor(textColor)
- IBar.write(textutils.formatTime(os.time(), false))
- IBar.setCursorPos(17,1)
- IBar.write("BlockDroid")
- --Crear botones
- LSBotones = {}
- LSApps = fs.list("Apps")
- local nApps = table.getn(LSApps)
- local height = 4
- for i=(6*(Page-1))+1,nApps,1
- do
- if (i > (6*Page)) then
- height = 4
- break
- end
- local path = "Apps/" .. LSApps[i] .. "/" .. LSApps[i] .. ".lua"
- if (i==(6*(Page-1))+1) then
- CreateButton(5, height, 11, height+2, appColor, LSApps[i], path)
- elseif (i%2==0) then
- CreateButton(5 + 11, height, 11 + 11, height+2, appColor, LSApps[i], path)
- else
- height = height+5
- CreateButton(5, height, 11, height+2, appColor, LSApps[i], path)
- end
- end
- --Page Navigation
- if (Page>1) then
- paintutils.drawFilledBox(1,19,7,20, appColor)
- term.setBackgroundColor(colors.yellow)
- term.setCursorPos(3,20)
- term.write("<---")
- end
- if (nApps > Page * 6) then
- paintutils.drawFilledBox(20,19,26,20, appColor)
- term.setBackgroundColor(colors.yellow)
- term.setCursorPos(21,20)
- term.write("--->")
- end
- --Page number
- term.setBackgroundColor(backColor)
- IBar.setTextColor(textColor)
- term.setCursorPos(13,20)
- term.write(Page)
- end
- function Events()
- while(true) do
- parallel.waitForAny(
- function()
- local e, button, x, y = os.pullEvent("mouse_click");
- Gui()
- if button == 1 then
- OpenApp(x, y)
- ChangePage(x, y)
- end
- end,
- function()
- sleep(.5)
- Gui()
- end,
- function()
- local ID,MSg = rednet.receive(1)
- if (Msg=="trkr") then
- rednet.send(ID, "Test")
- end
- end
- )
- end
- end
- function OpenApp(x, y)
- for o = 1,#LSBotones,1 do
- if (o > 6) then break end
- if x >= LSBotones[o][1] and y >= LSBotones[o][2] and x <= LSBotones[o][3] and y <= LSBotones[o][4]
- then
- multishell.setTitle(1, "Home")
- local pro = shell.openTab(LSBotones[o][6])
- multishell.setFocus(pro)
- multishell.setTitle(pro, LSBotones[o][5])
- end
- end
- end
- function ChangePage(x, y)
- if (x >= 1 and y >= 19 and x <= 7 and Page > 1) then -- Previous Page
- Page = Page-1
- Gui()
- elseif (x>= 20 and y >= 19 and x <= 26) then -- Next Page
- if (#LSApps > Page*6) then
- Page = Page+1
- Gui()
- end
- end
- end
- function CreateButton(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()
- paintutils.drawPixel(x1,y1)
- paintutils.drawPixel(x2,y1)
- paintutils.drawPixel(x1,y2)
- paintutils.drawPixel(x2,y2)
- term.setCursorPos(x1, y2+1)
- term.setTextColor(textColor)
- term.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