Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("iostabs")
- os.loadAPI("iosutils")
- os.loadAPI("iostabsinit")
- w, h = term.getSize()
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- iosutils.centerAlign("App Store", 1, colors.white, colors.lightBlue)
- iosutils.leftAlign("Image Filename: ", 3, colors.white, colors.lightBlue)
- iosutils.leftAlign("Program Filename: ", 4, colors.white, colors.lightBlue)
- iosutils.leftAlign("App Name: ", 5, colors.white, colors.lightBlue)
- term.setCursorPos(17, 3)
- iImage = read()
- term.setCursorPos(19, 4)
- iProgram = read()
- term.setCursorPos(11, 5)
- iName = read()
- iName = "\"" .. iName .. "\""
- --ensures that there aren't any broken string errors--
- if string.sub(iProgram, 0, 1) ~= "\"" then
- iProgram = "\"" .. iProgram
- end
- if string.sub(iProgram, string.len(iProgram)) ~= "\"" then
- iProgram = iProgram .. "\""
- end
- if string.sub(iImage, 0, 1) ~= "\"" then
- iImage = "\"" .. iImage
- end
- if string.sub(iImage, string.len(iImage)) ~= "\"" then
- iImage = iImage .. "\""
- end
- local error1 = ""
- local error2 = ""
- if not fs.exists(iProgram) then
- error1 = "ERROR: Program doesn't exist"
- end
- if not fs.exists(iImage) then
- error2 = "ERROR: Image file doesn't exist"
- end
- if error1 ~= "" or error2 ~= "" then
- term.setTextColor(colors.red)
- if error1 ~= "" then
- print(error1)
- end
- print(error2)
- sleep(2)
- oos.exit("appstore")
- end
- --collects page number based off the number of apps--
- local num = 1
- local pagenumcount = 1
- local pagenum = 0
- local triplenumcount = 1
- local triplenum = 0
- for i, v in pairs(iostabsinit.appslist) do
- num = num + 1
- pagenumcount = pagenumcount + 1
- triplenumcount = triplenumcount + 1
- if triplenumcount == 4 then
- triplenum = triplenum + 1
- triplenumcount = 1
- end
- if pagenumcount == 10 then
- pagenum = pagenum + 1
- pagenumcount = 1
- end
- end
- --collects image height and width--
- local ix = 1
- local iy = 1
- local ix2 = 0
- local iy2 = 0
- local ix2max = 0
- local iImageInfo = paintutils.loadImage(iImage)
- for i, v in pairs(iImageInfo) do
- iy2 = iy2 + 1
- ix2 = 0
- for k, e in pairs(iImageInfo[i]) do
- ix2 = ix2 + 1
- if ix2 > ix2max then
- ix2max = ix2
- end
- end
- end
- if ix2 > 8 or iy2 > 6 then
- term.setTextColor(colors.red)
- print("ERROR: Image is too big, must be 8*6px max")
- sleep(2)
- oos.exit("appstore")
- end
- --sets position for image--
- ix2 = ix2max
- ixOff = math.floor(4 - ix2 / 2)
- iyOff = math.floor(3 - iy2 / 2)
- --ix = ix + ((num - 1) % 3) * 9 + ixOff + (page - 1) * w
- local xtest = num - triplenum * 3
- local ixmultiply = 0
- if xtext == 1 then
- ixmultiply = 0
- elseif xtest == 2 then
- ixmultiply = 1
- elseif xtest == 3 then
- ixmultiply = 2
- end
- ix = math.floor(ix + ixmultiply * 9 + ixOff + pagenum * w)
- ix2 = math.floor(ix2 + ix) - 1
- --iy = iy + math.floor((((num - 1) - (page - 1) * 9) / 3) - 0.1) * 7 + iyOff
- local ytest = num - pagenum * 9
- local iymultiply = 0
- if ytest >= 1 and ytest <= 3 then
- iymultiply = 0
- elseif ytest >= 4 and ytest <= 6 then
- iymultiply = 1
- elseif ytest >= 7 and ytest <= 9 then
- iymultiply = 2
- end
- iy = math.floor(iy + iymultiply * 7 + iyOff)
- iy2 = math.floor(iy2 + iy) - 1
- --begins writing files--
- oTemp = fs.open("temp", "w")
- for line in io.lines("iostabsinit") do
- oTemp.writeLine(line)
- end
- oTemp.writeLine("appslist[" .. num .. "] = " .. iName)
- oTemp.flush()
- oTemp.close()
- shell.run("delete iostabsinit")
- shell.run("copy temp iostabsinit")
- shell.run("delete temp")
- os.loadAPI("iostabsinit")
- oTemp = fs.open("temp", "w")
- for line in io.lines("iostabs") do
- oTemp.writeLine(line)
- end
- oTemp.writeLine("appsinit[" .. num .. "][1] = " .. ix)
- oTemp.writeLine("appsinit[" .. num .. "][2] = " .. iy)
- oTemp.writeLine("appsinit[" .. num .. "][3] = " .. ix2)
- oTemp.writeLine("appsinit[" .. num .. "][4] = " .. iy2)
- oTemp.writeLine("appsinit[" .. num .. "][5] = paintutils.loadImage(" .. iImage .. ")")
- oTemp.writeLine("appsinit[" .. num .. "][6] = " .. iProgram)
- oTemp.flush()
- oTemp.close()
- shell.run("delete iostabs")
- shell.run("copy temp iostabs")
- shell.run("delete temp")
- os.loadAPI("iostabs")
- --completed, finalizing results--
- function debugPrint()
- for i, v in pairs(iostabs.appsinit) do
- for k, e in pairs(iostabs.appsinit[i]) do
- print(e)
- end
- end
- end
- print("App sucessfully installed!")
- sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement