|
Post by Tag365 on Apr 11, 2015 21:16:09 GMT
{"Applications\/BlockGame\/drawmain.lua":"if not terrain then require \"main\" end\n-- Some local variables\nlocal terrain = terrain\nlocal draw = draw\nlocal transformedimage = draw.transformedimage\nlocal rect = draw.rect\nlocal fillrect = draw.fillrect\nlocal blocksize = blocksize\nlocal drawblock = drawblock\nlocal drawblocksz = drawblocksz\nlocal pairs, ipairs = pairs, ipairs\n\n-- Colors\nlocal waterlg = {.64, .64, .9, .654}\nlocal background = {.4, .6, 1, 1}\nlocal lightblack = {}\n\nfor i=0, 15 do\n lightblack = {0, 0, 0, 1 - (i\/15)}\nend\n\n-- Draws a rectangle with the size of xs + ys.\nfunction draw.box(x, y, xs, ys, color)\n rect(x, y, x + xs, y + ys, color)\nend\nlocal box = draw.box\n\n-- Draws a rectangle with the size of xs + ys.\nfunction draw.fillbox(x, y, xs, ys, color)\n fillrect(x, y, x + xs, y + ys, color)\nend\nlocal fillbox = draw.fillbox\n\n-- Draws a button control on the screen.\nfunction drawbutton(str, x1, y1, x2, y2, state)\n fillrect(x1, y1, x2, y2, draw.darkgray)\n if state == 1 then -- draw pushed\n fillrect(x1 + 2, y1 + 2, x2 - 2, y2 - 2, {.22, .22, .22, 1})\n elseif state == 2 then -- draw end click\n\n else -- draw normal button\n fillrect(x1 + 2, y1 + 2, x2 - 2, y2 - 2, {.44, .44, .44, 1})\n end\n local strx, stry = draw.stringsize(str)\n local ysz = y2 - y1\n local y3, y4 = (ysz*.5 - stry*.5) + y1, (ysz*.5 + stry*.5) + y1\n draw.stringinrect(str, x1, y3, x2, y4, draw.white)\nend\nlocal drawbutton = drawbutton\n\nfunction drawitemslot(item, x, y)\n if not x then\n error(\"x is invalid (number expected, got \"..type(x)..\")\", 2)\n end\n if type(item) ~= \"table\" then\n error(\"item is not an item table (table expected, got \"..type(item)..\")\", 2)\n end\n if not item[3] then\n error(\"item is not a valid item table (item needs more values)\", 2)\n end\n --fillbox(x, y, 48, 48, draw.gray)\n drawbutton(\"\", x, y, x + 48, y + 48)\n if drawblock[item[1]] then\n transformedimage( \"@resources\/Block\" .. drawblock[item[1]]..\".png\", x + 24, y + 24, 48\/drawblocksz[item[1]], 0)\n end\n if itemdamagelimit[item[1]] then\n if item[2] > 0 then\n local maxdamage = itemdamagelimit[item[1]]\n draw.fillbox(x + 2, y + 40, ((maxdamage - item[2])\/maxdamage)*44, 6, {0, 0, ((maxdamage - item[2])\/maxdamage), 1})\n end\n end\n if item[3] > 1 then\n draw.string(item[3], x + 20, y + 30, draw.white)\n end\nend\n\nfunction drawinventoryinbox(scroll, x1, y1, x2, y2, inv)\n local inventory = inventory\n if inv then\n inventory = inv\n end\n draw.fillrect(x1, y1, x2, y2, draw.gray)\n local itemsperrow = math.floor((x2 - x1)\/48)\n local row = 0\n for k, v in pairs(inventory) do\n if k - (row*itemsperrow) > itemsperrow then\n row = row + 1\n end\n drawitemslot(inventory[k], x1 + ((k - 1) - (row*itemsperrow))*48, (y1 + (row*48)) - scroll)\n end\n draw.stringinrect(\"Inventory\", x1, y1 + 24, x2, y1 + 48, draw.white)\nend\n\nfunction drawinventoryside(scroll)\n drawinventoryinbox(scroll, 0, 0, scrx*.5, scry)\nend\n\n-- Draws the inventory bar.\nfunction drawinventory()\n local xcenter = 48*8 + 8\n local xstart = (scrx - xcenter)*.5 + 4\n fillbox(xstart - 4, scry - 84, 48*8 + 8, 56, draw.darkgray)\n for k, v in ipairs(inventory) do\n if k <= 7 then\n fillbox(xstart + 48*(k - 1), scry - 80, 48, 48, draw.lightgray)\n if drawblock[v[1]] then\n transformedimage( \"@resources\/Block\" .. drawblock[v[1]]..\".png\", xstart + (48*(k - 1) + 24), scry - 80 + 24, 48\/drawblocksz[v[1]], 0)\n end\n if itemdamagelimit[v[1]] then\n if v[2] > 0 then\n local maxdamage = itemdamagelimit[v[1]]\n draw.fillbox(xstart + (48*(k - 1) + 2), scry - 40, ((maxdamage - v[2])\/maxdamage)*44, 6, {0, 0, ((maxdamage - v[2])\/maxdamage), 1})\n end\n end\n if v[3] > 1 then\n draw.string(v[3], xstart + (48*(k - 1) + 20), scry - 80 + 30, draw.white)\n end\n if selected == k then\n draw.box(xstart + 48*(k - 1), scry - 80, 48, 48, draw.white)\n end\n end\n end\n fillbox(xstart + 48*7, scry - 80, 48, 48, draw.blue)\n draw.stringinrect( blocknames[inventory [selected][1]] or drawblock[inventory [selected][1]] or \"Block \"..inventory[selected][1], 48, scry - 128, scrx - 48, scry - 96, draw.white)\n if not buildmode then -- Draw Health\n\n end\nend\n\n-- Draws entities.\nfunction drawobjects()\n\nend\n\n--local xcutoff, ycutoff = scrx + blocksize*2, scry + blocksize*2\n\nfunction drawbackground()\n draw.clear(background)\nend\n\n-- Draws a selected chunk of terrain that is loaded.\nfunction drawterrainchunk(x, y)\n local posx, posy = posx - scrx*.5, posy - scry*.5\n local chunk = terrain[y][x]\n if not chunk then -- Assert\n error(\"attempt to draw chunk at vertical \"..y..\" and horzonal \"..x..\" which is not loaded.\", 2)\n end\n local xcutoff, ycutoff = scrx + blocksize*2, scry + blocksize*2\n local dx, dy = x*16, y*16\n if y > 0 then -- If this chunk is below level zero, draw a stone chunk instead.\n fillbox((dx*blocksize) - posx, (dy*blocksize) - posy, blocksize*16, blocksize*16, draw.gray)\n return\n end\n local row\n local light\n -- Draw each block in this chunk.\n for y2 = 1, 16 do\n if (dy + y2)*blocksize - posy > 0 and (dy + y2)*blocksize - posy + blocksize < ycutoff then\n row = chunk[y2]\n for x2 = 1, 16 do\n if row[x2][1] > 1 then\n if (dx + x2)*blocksize - posx > 0 and (dx + x2)*blocksize - posx + blocksize < xcutoff then\n if row[x2][KeyLightVal] then\n if row[x2][KeyLightVal] < 1 then\n goto SkipDrawing\n end\n end\n if row[x2][1] == 2 then\n draw.fillbox((dx + x2 - 1)*blocksize - posx, (dy + y2 - 1)*blocksize - posy, blocksize, blocksize, draw.gray)\n elseif row[x2][1] == 8 then\n draw.fillbox((dx + x2 - 1)*blocksize - posx, (dy + y2 - 1)*blocksize - posy, blocksize, blocksize, waterlg)\n elseif drawblock[row[x2][1]] then\n local sz = drawblocksz[row[x2][1]]\n transformedimage( \"@resources\/Block\" .. drawblock[row[x2][1]]..\".png\", (dx + x2)*blocksize - posx - (blocksize*.5), (dy + y2)*blocksize - posy - (blocksize*.5), blocksize\/sz, 0)\n end\n ::SkipDrawing::\n if row[x2][KeyLightVal] then\n light = row[x2][KeyLightVal]\n draw.fillbox((dx + x2 - 1)*blocksize - posx, (dy + y2 - 1)*blocksize - posy, blocksize, blocksize, lightblack[light])\n end\n end\n end\n end\n end\n end\n --draw.box((dx*blocksize) - posx, (dy*blocksize) - posy, blocksize*16, blocksize*16, draw.orange)\nend\n\n-- Draws the terrain on to the screen.\nfunction drawterrain()\n --[[\n for k, v in pairs(terrain) do\n for k2, v2 in pairs(v) do\n drawterrainchunk(k2, k)\n end\n end\n ]]\n draw.setantialias(false)\n for x=-1, 1 do\n if ((x + (posx\/16\/blocksize))*blocksize)*16 - posx > -16*blocksize - (scrx*.5) and ((x + (posx\/16\/blocksize))*blocksize)*16 - posx < 16*blocksize + (scrx*.5) then\n for y=-1, 1 do\n if ((y + (posy\/16\/blocksize))*blocksize)*16 - posy > -16*blocksize - (scry*.5) and ((y + (posy\/16\/blocksize))*blocksize)*16 - posy < 16*blocksize + (scry*.5) then\n drawterrainchunk(math.floor(posx\/16\/blocksize) + x, math.floor(posy\/16\/blocksize) + y)\n end\n end\n end\n end\n draw.setantialias(true)\nend\n\n-- Draws a border around the screen.\nfunction drawborder()\n draw.fillrect(-1, -1, 24, scry, draw.orange)\n draw.fillrect(-1, -1, scrx + 1, 24, draw.orange)\n draw.fillrect(-1, scry - 24, scrx + 1, scry, draw.orange)\n draw.fillrect(scrx - 24, -1, scrx, scry, draw.orange)\nend","Applications\/BlockGame\/SavedData":"nil","Applications\/HTMLViewer\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nHTML Page Viewer\nHTML Page Viewer\nThis is a simple page viewer.\nVersion\nAuthor\nmain\nicon.png","Applications\/Help\/help.lua":"-- Draws Help Explorer\nHelpPage = {[\"Text\"] = {}, [\"Pictures\"] = {}}\nHelpBook = {}\nPageTitle = \"\"\n\ndraw.setscreen(1)\napproot = approot or \"\"\n\nScreenX, ScreenY = draw.getport()\n\n-- Load Help\nfunction LoadBook()\n print(\"Loading Help Book...\")\n for k, v in ipairs(sys.dir(approot..\"Book\")) do\n if v ~= \"..\" and v ~= \".\" and string.sub(v, #v - 3) == \".lua\" then\n local func = loadfile(approot..\"Book\/\"..v)\n HelpBook[v] = func()\n print(\"Loaded \"..v)\n end\n end\n print(\"Done Loading Help Book...\")\nend\n\n-- Draws Help Page.\nfunction DrawHelp(ScrollX, ScrollY)\n local LineWidth = 0\n draw.fillrect(0, 0, ScreenX, 48, draw.lightgray)\n draw.stringinrect(PageTitle, 0, 16, ScreenX, 48, draw.black)\n -- Draw Text.\n for k, v in ipairs(HelpPage.Text) do\n if (k*20) - ScrollY > -20 and (k*20) - ScrollY < ScreenY then\n LineWidth = 0\n for k2, v2 in ipairs(v) do\n local text = tostring(v2)\n draw.string(text, (48 + LineWidth) - ScrollX, (k*20) - ScrollY + 48, draw.black)\n LineWidth = LineWidth + draw.stringsize(text)\n end\n end\n end\n -- Draw Images\n for k, v in ipairs(HelpPage.Pictures) do\n\n end\nend\n\n-- Draws Help Book Contents.\nfunction DrawContents(Scroll)\n\n\nend\n\n-- Switches Pages\nfunction SwitchPages(Title)\n HelpPage = HelpBook[Title]\n PageTitle = HelpPage.PageTitle\nend\n\nScrollX, ScrollY = 0, 0\n\nLoadBook()\nSwitchPages(\"Home.lua\")\n\n-- Operation Loop\nfor i=1, math.huge do\n draw.beginframe()\n draw.clear()\n DrawHelp(ScrollX, ScrollY)\n draw.endframe()\nend","LAMAPI\/lfsplus.lua":"local lfs = require \"lfs\"\n-- Returns if the path leads to a directory.\nfunction lfs.isDirectory(Path)\n return lfs.attributes(Path, \"mode\") == \"directory\"\nend\n\n-- Returns if the path leads to a file.\nfunction lfs.isFile(Path)\n if Path then\n return lfs.attributes(Path, \"mode\") == \"file\"\n end\nend\n\n-- Returns the file size of the file.\nfunction lfs.fileSize(Path)\n return lfs.attributes(Path, \"size\")\nend\n\n-- Returns the last update date of the file.\nfunction lfs.lastUpdated(Path)\n return lfs.attributes(Path, \"change\")\nend\nreturn lfs","Applications\/CubotsMarch!\/main.lua":"sys.clear()\ndraw.setscreen(1)\ndraw.settitle(\"Cubots March!\")\ndraw.clear(draw.black)\napproot = approot or \"\"\ntouch = {}\ngame = {}\nsave = {[\"data\"] = {}}\nScreenX, ScreenY = draw.getport()\ndraw.setantialias(false)\n\n-- Generate Resources\nrequire \"lfs\"\nfunction lfs.isDirectory(Path)\n return lfs.attributes(Path, \"mode\") == \"directory\"\nend\nif not lfs.isDirectory(approot..\"resources\") then\n require \"ResourceGenerator\"\nend\n\n-- Some basic gameplay variables\nblocksize = 36\nblfulldepth = 56\nmaxcommands = 8\nstagewidth = 16\nstageheight = 10\ndrawx, drawy = ScreenX - stagewidth*(blocksize + 3), ScreenY - stageheight*blocksize\ntimeperstep = 1\ntimetonextstep = timeperstep\ntimestepstart = 0\ntimestep = 0\nselectedcommand = 0\nstage = {}\nstagepaused = {}\nhidecoding = false\ncubot1 = {0, 0, 0, 0, 0, 0, 0, 0}\ncubot2 = {0, 0, 0, 0, 0, 0, 0, 0}\nfunct1 = {0, 0, 0, 0, 0, 0, 0, 0}\nfunct2 = {0, 0, 0, 0, 0, 0, 0, 0}\ncubot1dir, cubot2dir = 0, 0 -- Current direction each Cubot is facing.\ncurcubot1 = 0 -- Curent command Cubot 1 is running.\ncurcubot2 = 0\ncurfunct1c1 = 0 -- Curent command in function 1 Cubot 1 is running\ncurfunct1c2 = 0\ncurfunct2c1 = 0\ncurfunct2c2 = 0\ncubot1x, cubot1y = 0, 0 -- Cubot 1's position.\ncubot2x, cubot2y = 0, 0\ncubot1dx, cubot1dy = 0, 0\ncubot2dx, cubot2dy = 0, 0\n\nfunction assert(value, message, errlevel)\n message = message or \"assertion failed!\"\n if not value then\n error(message, errlevel)\n end\nend\n\n--------------------\n-- Save Functions --\n--------------------\n\n-- Save unsaved changes to save file.\nfunction save.updateSave()\n -- Show saving indicator.\n for i=1, 2 do\n draw.beginframe()\n draw.fillrect(0, ScreenY - 48, 48*3, ScreenY, draw.black)\n draw.fillrect(0, ScreenY - 48, 48, ScreenY, draw.white)\n draw.endframe()\n sys.sleep(100)\n draw.beginframe()\n draw.fillrect(0, ScreenY - 48, 48*3, ScreenY, draw.black)\n draw.fillrect(48, ScreenY - 48, 96, ScreenY, draw.white)\n draw.endframe()\n sys.sleep(100)\n draw.beginframe()\n draw.fillrect(0, ScreenY - 48, 128, ScreenY, draw.black)\n draw.fillrect(96, ScreenY - 48, 48*3, ScreenY, draw.white)\n draw.endframe()\n sys.sleep(100)\n end\n -- Save to the file.\n local file = io.open(approot..\"save.data\", \"w\")\n for k, v in ipairs(save.data) do\n file:write(tostring(v)..\"\\n\")\n end\n file:close()\nend\n\n-- Generate a new save file.\nfunction save.newData()\n -- generate default values.\n for i=1, 50 do\n save.data = 0\n end\n save.updateSave()\nend\n\n-- Reload saved data.\nfunction save.loadData()\n local file = io.open(approot..\"save.data\")\n if file then\n file:close()\n for line in io.lines(approot..\"save.data\") do\n save.data[#save.data + 1] = tonumber(line)\n end\n else -- Save data is not present\n save.newData()\n end\nend\n\nsave.loadData() -- Time to load data!\n\nrequire \"drawx\"\nrequire \"touchx\"\nrequire \"stages\"\n\n--------------------\n-- Game Functions --\n--------------------\n\n-- Function used for time\ngame.time = os.clock\n\n-- Resets the stage to paused position\nfunction game.resetStage()\n stage = {}\n for k, v in ipairs(stagepaused) do\n stage[k] = {}\n for k2, v2 in ipairs(v) do\n stage[k][k2] = v2\n end\n end\n curblock1x, curblock1y = nil, nil\n oldblock1x, oldblock1y = nil, nil\n newblock1x, newblock1y = nil, nil\n curcubot1 = 0\n curcubot2 = 0\n curfunct1c1 = 0\n curfunct1c2 = 0\n curfunct2c1 = 0\n curfunct2c2 = 0\n cubot1x, cubot1y = cubot1xold, cubot1yold\n cubot1dx, cubot1dy = cubot1x, cubot1y\n if key1x then\n door1locked = true\n end\n if cubot2y then\n cubot2x, cubot2y = cubot2xold, cubot2yold\n cubot2dx, cubot2dy = cubot2x, cubot2y\n end\nend\n\n-- Loads and prepares stage for gameplay.\nfunction game.prepareStage()\n levelexit = false\n selectedcommand = 0\n cubot1 = {0, 0, 0, 0, 0, 0, 0, 0}\n cubot2 = {0, 0, 0, 0, 0, 0, 0, 0}\n funct1 = {0, 0, 0, 0, 0, 0, 0, 0}\n funct2 = {0, 0, 0, 0, 0, 0, 0, 0}\n curcubot1 = 0\n curcubot2 = 0\n curfunct1c1 = 0\n curfunct1c2 = 0\n curfunct2c1 = 0\n curfunct2c2 = 0\n stage = stages[selectedlevel].data\n stagepaused = {}\n for k, v in ipairs(stage) do -- We can't just refrence the table, we need to clone it.\n stagepaused[k] = {}\n for k2, v2 in ipairs(v) do\n stagepaused[k][k2] = v2\n end\n end\n bonus = stages[selectedlevel].bonus\n availcommands = stages[selectedlevel].commands\n cubot1x, cubot1y = stages[selectedlevel].cubot1x, stages[selectedlevel].cubot1y\n door1x, door1y = stages[selectedlevel].door1x, stages[selectedlevel].door1y\n cubot1xold, cubot1yold = cubot1x, cubot1y\n cubot1xst, cubot1yst = cubot1x, cubot1y\n cubot1dx, cubot1dy = cubot1x, cubot1y\n if stages[selectedlevel].cubot2y then\n cubot2x, cubot2y = stages[selectedlevel].cubot2x, stages[selectedlevel].cubot2y\n cubot2xold, cubot2yold = cubot2x, cubot2y\n else\n cubot2x, cubot2y = nil, nil\n end\n if stages[selectedlevel].key1x then -- Should Door be locked?\n door1locked = true\n key1x = stages[selectedlevel].key1x\n key1y = stages[selectedlevel].key1y\n else\n door1locked = nil\n key1x, key1y = nil, nil\n end\nend\n\n-- Handle Cubot 1's current command\nfunction game.handleCubot1sub(ctype)\n if cubot1x < 1 and cubot1y > 10 then\n game.cubotEscaped()\n else -- Handle function\n local movedblock\n oldcubot1x = cubot1x\n if ctype == 1 or (ctype == 3 and cubot1dir < 0) then -- Move Left\n cubot1dir = -1\n if cubot1x < 2 then\n cubot1x, cubot1y = 0, 11\n else\n if not (stage[cubot1y][cubot1x - 1] == 1 or stage[cubot1y][cubot1x - 1] == 2) then\n oldcubot1y = cubot1y\n cubot1x = cubot1x - 1\n if key1x == cubot1x and key1y == oldcubot1y then\n door1locked = false\n end\n for k, v in ipairs(stage) do\n if k > cubot1y then\n if v[cubot1x] == 1 or v[cubot1x] == 2 then -- If solid block\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n break\n end\n end\n end\n if fall then\n print(\"put at floor\")\n cubot1y = 10\n end\n end\n end\n elseif ctype == 2 or ctype == 3 and cubot1dir > 0 then -- Move Right\n cubot1dir = 1\n if cubot1x > 15 then\n cubot1x = 16\n else\n if not (stage[cubot1y][cubot1x + 1] == 1 or stage[cubot1y][cubot1x + 1] == 2) then\n oldcubot1y = cubot1y\n fall = true\n cubot1x = cubot1x + 1\n for k, v in ipairs(stage) do\n if cubot1y < k then\n print(\"block at \"..cubot1x..\", \"..k..\"=\"..v[cubot1x])\n if v[cubot1x] == 1 or v[cubot1x] == 2 then -- If solid block\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n break\n end\n end\n end\n if fall then\n print(\"put at floor\")\n cubot1y = 10\n end\n end\n end\n elseif ctype == 4 then -- Turn Around\n cubot1dir = -cubot1dir\n elseif ctype == 5 then -- Push Block\n block1dir = cubot1dir\n oldcubot1x = cubot1x\n oldcubot1y = cubot1y\n if cubot1dir < 0 then\n if (stage[cubot1y][cubot1x - 1] == 2) then\n stage[cubot1y][cubot1x - 1] = 0\n oldblock1x, oldblock1y = cubot1x - 1, cubot1y\n curblock1x, curblock1y = oldblock1x, oldblock1y\n oldcubot1y = cubot1y\n fall = true\n cubot1x = cubot1x - 1\n for k, v in ipairs(stage) do\n if cubot1y < k then\n print(\"block at \"..cubot1x..\", \"..k..\"=\"..v[cubot1x])\n if v[cubot1x] == 1 or v[cubot1x] == 2 and cubot1y == oldcubot1y then -- If solid block\n if fall then\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n end\n end\n if v[cubot1x - 1] == 1 or v[cubot1x - 1] == 2 then -- If solid block\n if not movedblock then\n stage[k - 1][cubot1x - 1] = 2\n newblock1x, newblock1y = cubot1x - 1, k - 1\n print(\"put block at \"..k - 1)\n movedblock = true\n end\n end\n end\n end\n end\n elseif cubot1dir > 0 then\n if (stage[cubot1y][cubot1x + 1] == 2) then\n stage[cubot1y][cubot1x + 1] = 0\n oldblock1x, oldblock1y = cubot1x + 1, cubot1y\n curblock1x, curblock1y = oldblock1x, oldblock1y\n oldcubot1y = cubot1y\n fall = true\n cubot1x = cubot1x + 1\n for k, v in ipairs(stage) do\n if cubot1y < k then\n print(\"block at \"..cubot1x..\", \"..k..\"=\"..v[cubot1x])\n if v[cubot1x] == 1 or v[cubot1x] == 2 and cubot1y == oldcubot1y then -- If solid block\n if fall then\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n end\n end\n if v[cubot1x + 1] == 1 or v[cubot1x + 1] == 2 then -- If solid block\n if not movedblock then\n stage[k - 1][cubot1x + 1] = 2\n newblock1x, newblock1y = cubot1x + 1, k - 1\n print(\"put block at \"..k - 1)\n movedblock = true\n end\n end\n end\n end\n end\n end\n elseif ctype == 6 then -- Pull Block\n block1dir = -cubot1dir\n oldcubot1x = cubot1x\n oldcubot1y = cubot1y\n cubot1dx = cubot1x\n cubot1dy = cubot1y\n if cubot1dir < 0 then\n if (stage[cubot1y][cubot1x - 1] == 2) then\n stage[cubot1y][cubot1x - 1] = 0\n oldblock1x, oldblock1y = cubot1x - 1, cubot1y\n curblock1x, curblock1y = oldblock1x, oldblock1y\n oldcubot1y = cubot1y\n fall = true\n cubot1x = cubot1x + 1\n moving1 = 1\n for k, v in ipairs(stage) do\n if cubot1y < k then\n print(\"block at \"..cubot1x..\", \"..k..\"=\"..v[cubot1x])\n if v[cubot1x] == 1 or v[cubot1x] == 2 and cubot1y == oldcubot1y then -- If solid block\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n end\n if v[oldcubot1x] == 1 or v[oldcubot1x] == 2 then -- If solid block\n stage[oldcubot1y][oldcubot1x] = 2\n newblock1x, newblock1y = oldcubot1x, k - 1\n print(\"put block at \"..k - 1)\n break\n end\n end\n end\n end\n elseif cubot1dir > 0 then\n if (stage[cubot1y][cubot1x + 1] == 2) then\n stage[cubot1y][cubot1x + 1] = 0\n oldblock1x, oldblock1y = cubot1x + 1, cubot1y\n curblock1x, curblock1y = oldblock1x, oldblock1y\n oldcubot1y = cubot1y\n fall = true\n cubot1x = cubot1x - 1\n moving1 = -1\n for k, v in ipairs(stage) do\n if cubot1y < k then\n print(\"block at \"..cubot1x..\", \"..k..\"=\"..v[cubot1x])\n if v[cubot1x] == 1 or v[cubot1x] == 2 and cubot1y == oldcubot1y then -- If solid block\n cubot1y = k - 1\n print(\"put at \"..k - 1)\n fall = false\n end\n if v[oldcubot1x] == 1 or v[oldcubot1x] == 2 then -- If solid block\n stage[oldcubot1y][oldcubot1x] = 2\n newblock1x, newblock1y = oldcubot1x, k - 1\n print(\"put block at \"..k - 1)\n break\n end\n end\n end\n end\n end\n elseif ctype == 7 then -- Jump\n oldcubot1x = cubot1x\n oldcubot1y = cubot1y\n if cubot1dir < 0 then -- Facing left\n if (stage[cubot1y][cubot1x - 1] == 1 or stage[cubot1y][cubot1x - 1] == 2) and not (stage[cubot1y - 1][cubot1x - 1] == 1 or stage[cubot1y - 1][cubot1x - 1] == 2)then\n cubot1x = cubot1x - 1\n cubot1y = cubot1y - 1\n end\n elseif cubot1dir > 0 then -- right\n if (stage[cubot1y][cubot1x + 1] == 1 or stage[cubot1y][cubot1x + 1] == 2) and not (stage[cubot1y - 1][cubot1x + 1] == 1 or stage[cubot1y - 1][cubot1x + 1] == 2) then\n cubot1x = cubot1x + 1\n cubot1y = cubot1y - 1\n end\n end\n elseif ctype == 8 then -- Call Function 1\n curfunct1c1 = 1\n return 1\n elseif ctype == 9 then -- Call Function 2\n curfunct2c1 = 1\n return 2\n else\n oldcubot1x = cubot1x\n end\n end\nend\n\n-- Handle Cubot 1\nfunction game.handleCubot1()\n if curfunct1c1 > 0 then\n game.handleCubot1sub(funct1[curfunct1c1])\n cubot1hdlcmd = funct1[curfunct1c1]\n elseif curfunct2c1 > 0 then\n game.handleCubot1sub(funct2[curfunct2c1])\n cubot1hdlcmd = funct2[curfunct2c1]\n else\n local funct = game.handleCubot1sub(cubot1[curcubot1])\n if funct == 1 then\n game.handleCubot1sub(funct1[curfunct1c1])\n cubot1hdlcmd = funct1[curfunct1c1]\n elseif funct == 2 then\n game.handleCubot1sub(funct2[curfunct2c1])\n cubot1hdlcmd = funct2[curfunct2c1]\n end\n cubot1hdlcmd = cubot1[curcubot1]\n end\nend\n\n-- Handle Cubot 2\nfunction game.handleCubot2() end\n\n-- Runs the cubot commands if time has passed, or update the animations.\nfunction game.handlePlay()\n if curcubot1 == 0 then\n timestep = timetonextstep + 1\n end\n if timestep > timetonextstep then\n moving1 = nil\n curblock1x, curblock1y = nil, nil\n oldblock1x, oldblock1y = nil, nil\n newblock1x, newblock1y = nil, nil\n -- Handle next step\n timestep = 0\n timestepstart = game.time()\n if curfunct1c1 > 0 and curfunct1c1 < maxcommands then\n curfunct1c1 = curfunct1c1 + 1\n elseif curfunct1c1 >= maxcommands then\n curfunct1c1 = 0\n curcubot1 = curcubot1 + 1\n else\n curcubot1 = curcubot1 + 1\n end\n if cubot1x == door1x and cubot1y == door1y and not door1locked then\n if cubot2y then\n\n else\n return game.winLevel()\n end\n end\n game.handleCubot1() -- Handle Cubot 1\n if cubot2y then\n game.handleCubot2() -- Handle Cubot 2\n end\n else\n -- Handle animation\n timestep = (game.time() - timestepstart)*2\n if newblock1x then -- Handle Block 1\n curblock1x = oldblock1x + (timestep*block1dir)\n curblock1y = newblock1y\n end\n if cubot1x ~= oldcubot1x then\n local cubot1dir = moving1 or cubot1dir\n if oldcubot1y == cubot1y then\n timetonextstep = 1\n cubot1dx = cubot1x - cubot1dir + (timestep*cubot1dir)\n else\n timetonextstep = math.abs(cubot1y - oldcubot1y) + 1\n if timestep < 1 and oldcubot1y < cubot1y then\n cubot1dx = cubot1x + ((timestep - 1)*cubot1dir)\n elseif timestep < timetonextstep - 1 and oldcubot1y > cubot1y then\n cubot1dx = oldcubot1x\n cubot1dy = oldcubot1y - timestep\n elseif oldcubot1y < cubot1y then -- Time to change elevation\n cubot1dx = cubot1x\n upordown = math.min(math.max(cubot1y - oldcubot1y, -1), 1)\n cubot1dy = oldcubot1y + ((timestep - 1)*upordown)\n else\n cubot1dx = cubot1x - cubot1dir + ((timestep - (timetonextstep - 1))*cubot1dir)\n cubot1dy = cubot1y\n end\n end\n end\n end\nend\n\n-- Called when a cubot falls off the floor\nfunction game.cubotEscaped()\n -- erase file\n save.newData()\n -- show white screen of death\n for i=1, 255 do -- gameplay loop\n -- Draw Frame\n draw.beginframe()\n draw.clear({0, 0, 0, math.random()*.2})\n draw.endframe()\n end\n sys.sleep(math.huge)\nend\n\n-- When the player completes a level.\nfunction game.winLevel()\n if not helpmode then\n -- Determine how many commands have been used to complete the level.\n local commandsused = 0\n for k, v in ipairs(cubot1) do\n if v > 0 then\n commandsused = commandsused + 1\n end\n end\n for k, v in ipairs(cubot2) do\n if v > 0 then\n commandsused = commandsused + 1\n end\n end\n for k, v in ipairs(funct1) do\n if v > 0 then\n commandsused = commandsused + 1\n end\n end\n for k, v in ipairs(funct2) do\n if v > 0 then\n commandsused = commandsused + 1\n end\n end\n -- Check if player has earned the memory bonus, and if so, give the player full credit.\n if commandsused <= bonus then\n -- Player has obtained memory bonus.\n if save.data[selectedlevel] < 2 then\n save.data[selectedlevel] = 2\n game.calculateScore()\n save.updateSave()\n end\n else\n -- Player has not obtained memory bonus.\n if save.data[selectedlevel] < 1 then\n save.data[selectedlevel] = 1\n game.calculateScore()\n save.updateSave()\n end\n end\n -- end the level.\n levelexit = true\n print(\"Level Won\")\n for i=4, 128 do\n draw.beginframe()\n draw.clear({0, 0, 0, 4\/256})\n draw.endframe()\n end\n end\nend\n\nfstatime, fendtime, ftime = 0, 0, 0\n\n-- Calculate the player's score.\nfunction game.calculateScore()\n score = 0\n for k, v in ipairs(save.data) do\n score = score + v*50\n end\nend\n\n-- Player is in Gameplay mode.\nfunction game.gamePlay()\n -- Start Loading Level\n game.prepareStage()\n playing = false\n while true do -- gameplay loop\n ftime = fendtime - fstatime\n fstatime = game.time()\n draw.beginframe()\n draw.clear(draw.black)\n draw.stage()\n draw.memoryBonus()\n draw.code()\n --draw.fillrect(0, ScreenY, 24, ScreenY - ((ftime*20)*ScreenY), draw.red) -- Framerate bar\n draw.endframe()\n -- Track Touches\n draw.tracktouches(touch.beganGameplay, touch.movedGameplay, touch.endedGameplay)\n draw.doevents()\n -- Check if in play mode\n if playing then\n game.handlePlay()\n end\n fendtime = game.time()\n if levelexit then\n return\n end\n end\n sys.sleep(1)\nend\n\n-- Player is in the Level Menu.\nfunction game.levelMenu()\n set = 1\n while true do -- gameplay loop\n draw.beginframe()\n draw.clear(draw.black)\n draw.levelsMenu(set)\n draw.endframe()\n draw.tracktouches(touch.beganLevels, touch.movedLevels, touch.endedLevels)\n draw.doevents()\n if selectedlevel then\n game.gamePlay()\n selectedlevel = nil\n end\n end\nend\n\n-- Help Menu\nfunction game.helpMenu()\n page = 1\n helpmode = true\n selectedlevel = 1\n playing = false\n game.prepareStage()\n local oldtime = game.time()\n while true do -- gameplay loop\n time = game.time() - oldtime\n if time > 15 then\n oldtime = game.time()\n playing = false\n time = 0\n cubot1 = {0,0,0,0,0,0,0,0}\n game.resetStage()\n elseif time > 2.5 and time < 3.5 then\n playing = true\n elseif time > 5 and time < 5.5 then\n if playing then\n playing = false\n game.resetStage()\n end\n elseif time > 7 and time < 7.5 then\n playing = true\n end\n draw.beginframe()\n draw.clear(draw.black)\n if page == 1 then\n draw.helpMain(time)\n if playing then\n game.handlePlay()\n end\n elseif page == 2 then\n draw.helpMain2()\n elseif page == 3 then\n draw.helpCommands()\n end\n draw.endframe()\n draw.tracktouches(none, none, touch.endedHelp)\n draw.doevents()\n if nextPage then\n nextPage = false\n if page == 1 then\n page = 2\n elseif page == 2 then\n page = 3\n else\n page = 1\n end\n elseif back then\n back = nil\n Help = nil\n selectedlevel = nil\n return\n end\n end\nend\n\n-- Player is in the main menu.\nfunction game.mainMenu()\n while true do -- gameplay loop\n draw.beginframe()\n draw.clear(draw.black)\n draw.mainMenu()\n draw.endframe()\n -- Track Touches\n draw.tracktouches(touch.beganMenu, touch.movedMenu, touch.endedMenu)\n draw.doevents()\n if Play then\n game.levelMenu()\n elseif Help then\n game.helpMenu()\n end\n end\nend\n\n-- Final Preprations.\ngame.calculateScore() -- Calculate Score.\ngame.mainMenu() -- Game is ready to play!","Applications\/PaintApp\/LuaApp.lua":"--[[ This is a script used for Lua App Manager.\nPicture Maker\nPaint\nPaint a picture. You can then export it.\nVersion\nAuthor\nmain\nicon.png","Applications\/BlockGame":"nil","Applications\/CubotsMarch!\/resources":"nil","LAMAPI":"nil","Applications\/CubotsMarch!\/stages.lua":"if not game then require \"main\" end\n------------------\n-- Level Tables --\n------------------\nstages = {}\nlocal t, f = true, false\n-- Stage 1\nstages[1] = {[\"bonus\"] = 4}\nstages[1].commands = {t, t, f, f, f, f, f, f,f}\nstages[1].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[1].cubot1x = 10\nstages[1].cubot1y = 2\nstages[1].door1x = 14\nstages[1].door1y = 5\n\n-- Stage 2\nstages[2] = {[\"bonus\"] = 4}\nstages[2].commands = {t, t, f, f, f, f, f, f,f}\nstages[2].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[2].cubot1x = 13\nstages[2].cubot1y = 3\nstages[2].door1x = 13\nstages[2].door1y = 6\n\n-- Stage 3\nstages[3] = {[\"bonus\"] = 5}\nstages[3].commands = {t, t, f, f, f, f, t, f,f}\nstages[3].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[3].cubot1x = 10\nstages[3].cubot1y = 4\nstages[3].door1x = 15\nstages[3].door1y = 2\n\n-- Stage 4\nstages[4] = {[\"bonus\"] = 8}\nstages[4].commands = {t, t, f, f, f, f, t, f,f}\nstages[4].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[4].cubot1x = 14\nstages[4].cubot1y = 3\nstages[4].door1x = 14\nstages[4].door1y = 5\n\n-- Stage 5\nstages[5] = {[\"bonus\"] = 8}\nstages[5].commands = {t, t, f, f, t, f, t, f,f}\nstages[5].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[5].cubot1x = 14\nstages[5].cubot1y = 4\nstages[5].door1x = 15\nstages[5].door1y = 2\n\n-- Stage 6\nstages[6] = {[\"bonus\"] = 6}\nstages[6].commands = {t, t, f, f, f, t, t, f,f}\nstages[6].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[6].cubot1x = 14\nstages[6].cubot1y = 4\nstages[6].door1x = 12\nstages[6].door1y = 2\n\n-- Stage 7\nstages[7] = {[\"bonus\"] = 8}\nstages[7].commands = {t, t, f, f, t, t, t, f,f}\nstages[7].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[7].cubot1x = 12\nstages[7].cubot1y = 2\nstages[7].door1x = 14\nstages[7].door1y = 2\n\n-- Stage 8\nstages[8] = {[\"bonus\"] = 7}\nstages[8].commands = {t, t, f, f, t, t, t, f,f}\nstages[8].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[8].cubot1x = 14\nstages[8].cubot1y = 3\nstages[8].door1x = 13\nstages[8].door1y = 2\nstages[8].key1x = 11\nstages[8].key1y = 2\n\n-- Stage 11\nstages[11] = {[\"bonus\"] = 7}\nstages[11].commands = {t, t, f, f, t, t, t, f,f}\nstages[11].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[11].cubot1x = 12\nstages[11].cubot1y = 3\nstages[11].door1x = 11\nstages[11].door1y = 2\n\n-- Stage 12\nstages[12] = {[\"bonus\"] = 8}\nstages[12].commands = {t, t, f, f, t, t, t, f,f}\nstages[12].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,2,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[12].cubot1x = 11\nstages[12].cubot1y = 5\nstages[12].door1x = 15\nstages[12].door1y = 3\n\n-- Stage 13\nstages[13] = {[\"bonus\"] = 7}\nstages[13].commands = {t, t, f, f, t, t, t, f,f}\nstages[13].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[13].cubot1x = 12\nstages[13].cubot1y = 2\nstages[13].door1x = 12\nstages[13].door1y = 5\n\n-- Stage 14\nstages[14] = {[\"bonus\"] = 7}\nstages[14].commands = {t, t, f, f, t, t, t, f,f}\nstages[14].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[14].cubot1x = 13\nstages[14].cubot1y = 3\nstages[14].door1x = 11\nstages[14].door1y = 2\n\n-- Stage 15\nstages[15] = {[\"bonus\"] = 8}\nstages[15].commands = {t, t, f, f, t, t, t, f,f}\nstages[15].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[15].cubot1x = 12\nstages[15].cubot1y = 3\nstages[15].door1x = 12\nstages[15].door1y = 5\n\n-- Stage 16\nstages[16] = {[\"bonus\"] = 8}\nstages[16].commands = {t, t, f, f, t, t, t, f,f}\nstages[16].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[16].cubot1x = 10\nstages[16].cubot1y = 6\nstages[16].door1x = 14\nstages[16].door1y = 2\n\n-- Stage 17\nstages[17] = {[\"bonus\"] = 5}\nstages[17].commands = {t, t, f, f, t, t, t, f,f}\nstages[17].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,2,2,0,0,0,2,2,0,0},\n {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[17].cubot1x = 12\nstages[17].cubot1y = 4\nstages[17].door1x = 9\nstages[17].door1y = 4\n\n-- Stage 18\nstages[18] = {[\"bonus\"] = 8}\nstages[18].commands = {t, t, f, f, t, t, t, f,f}\nstages[18].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[18].cubot1x = 12\nstages[18].cubot1y = 3\nstages[18].door1x = 15\nstages[18].door1y = 1\n\nrequire \"stages3\"","Documents":"nil","Applications\/CubotsMarch!\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nCubots March!\nCubots March!\nThose forgetful cubots went and forgot their code again! Only you can help them acomplish their tasks and give their lives a sense of fulfillment.\nVersion\nAuthor\nmain\nicon.png","LAMAPI\/index.lua":"--[[This amazing piece of code can search inside your files.\nIt uses an index to search, so when you start the script it indexes all of your files.\nIndexing makes it run so blazing fast, it only takes 20 miliseconds to search the first time!\nSince it doesn't change if you need to see the results again it pulls the already calculated results from its index for instant researches. ]]\n-- Set local variables\nlfs = require \"lfsplus\"\nlocal index = {}\nlocal indexedFiles = {} -- This table is used to store indexed file contents.\nlocal fileContentIndex = {} -- This table is used to store file content matches.\nlocal fileNameIndex = {} -- This table is used to store file name matches.\nlocal indexed = false\n\n-- This is an internal function called by updateIndex to initalize the search index.\nlocal function updateIndexFile(path)\n indexedFiles[path] = \"\"\n local file = io.open(path, \"r\")\n if type(file) ~= \"string\" and file then\n local line = file:read(\"*a\")\n file.close()\n indexedFiles[path] = line\n else\n indexedFiles[path] = \"\"\n end\nend\n\n-- This is an internal function called by rebuildIndex to initalize the search index.\n-- It loops through the directory list and calls itself if it finds a directory.\nfunction index.updateIndex(path)\n if lfs.isDirectory(path) then\n if sys.dir(path) then\n for k, v in pairs(sys.dir(path)) do\n if v ~= \"..\" and v ~= \".\" then\n if lfs.isDirectory(path..\"\/\"..v) then\n index.updateIndex(path..\"\/\"..v)\n else\n updateIndexFile(path..\"\/\"..v)\n end\n end\n end\n end\n elseif lfs.isFile(path) then\n updateIndexFile(path)\n end\nend\n\n-- This is an internal function run by Lua Script System to initalize the search index.\n-- It is run on startup to initalize the index. If you are not using LuaSS then you need to run this before the\n-- first time you search files using the searchFiles or searchFileName functions given by this API.\n-- Currently it just calls updateIndex to index the root directory.\nfunction index.rebuildIndex()\n index.updateIndex(\"..\/\")\nend\n\n-- This is an internal function used to check if a file should be included in the table returned by searchFiles.\nfunction findStringInIndexSearchFiles(path, sSearch)\n local contents = indexedFiles[path]\n local startHere = 0\n while true do\n local nextSlash = string.find(string.sub(contents, startHere, -1), sSearch)\n if not nextSlash then\n return\n else\n fileContentIndex[sSearch][#fileContentIndex[sSearch] + 1] = path\n return true\n end\n nextSlash = nextSlash + startHere\n tab = tab + 1\n startHere = nextSlash\n end\nend\n\n-- This is an internal function used to check if a file should be included in the table returned by searchFileNames.\nfunction findStringInIndexSearchFileNames(path, sSearch)\n local match = string.find(path, sSearch)\n if match then\n fileNameIndex[sSearch][#fileNameIndex[sSearch] + 1] = path\n return true\n end\nend\n\nfunction checkIfIndexed()\n if not indexed then\n print(\"Indexing Files...\")\n index.rebuildIndex()\n indexed = true\n end\nend\n\n-- This function searches inside files for the searchstring sSearch.\nfunction index.searchFiles(sSearch)\n checkIfIndexed()\n local tab = fileContentIndex[sSearch]\n if tab then\n return tab\n else\n fileContentIndex[sSearch] = {}\n for k, v in pairs(indexedFiles) do\n findStringInIndexSearchFiles(k, sSearch)\n end\n return fileContentIndex[sSearch]\n end\nend\n\n-- This function searches for files with names that include the string sSearch.\nfunction index.searchFileNames(sSearch)\n checkIfIndexed()\n local tab = fileNameIndex[sSearch]\n if tab then\n return tab\n else\n fileNameIndex[sSearch] = {}\n for k, v in pairs(indexedFiles) do\n findStringInIndexSearchFileNames(k, sSearch)\n end\n return fileNameIndex[sSearch]\n end\nend\n\nreturn index","Applications\/SampleApp\/samplescript.lua":"draw.settitle('Hello World!')\ndraw.setscreen(1)\nlocal ScreenX, ScreenY = draw.getport()\nlocal str = \"Hello Lua Application Manager!\"\nlocal strx, stry = draw.stringsize(str)\n\nwhile true do\n draw.beginframe()\n draw.clear(draw.cyan)\n draw.string(str, math.random()*(ScreenX - strx), math.random()*(ScreenY - stry), draw.blue)\n draw.endframe()\n sys.sleep(40)\nend","Applications\/BlockGame\/drawblocks.lua":"print(\"Loading Blocks...\")\n\n-- Used in the string calculation to draw the correct image for each block. Also used for a fallback to show a name for unnamed blocks.\ndrawblock = {\"\", \"Stone\", \"Cobblestone\", \"Dirt\", \"Grass\", \"Wood\", \"Leaves\", \"Water\", \"Lava\", \"CoalOre\", \"IronOre\", \"SapphireOre\", \"RubyOre\", \"EmeraldOre\", \"TraceOre\", \"UraniumOre\", \"LapisOre\", \"Coal\", \"Iron\", \"Sapphire\", \"Ruby\", \"Emerald\", \"Trace\", \"Uranium\", \"Lapis\", \"WoodPlanks\", \"CraftingTable\", \"Furnance\", \"RubberTree\", \"RubberTreeSpot\", \"WoodPickaxe\", \"WoodAxe\", \"WoodSword\", \"WoodHoe\", \"StonePickaxe\", \"StoneAxe\", \"StoneSword\", \"StoneHoe\", \"IronPickaxe\", \"IronAxe\", \"IronSword\", \"IronHoe\", \"IronCable\", \"TinCable\", \"Computer\", \"Generator\", \"SolarPanel\", \"LavaGenerator\", \"WaterMill\", \"Windmill\", \"BatteryBox\", \"StorageBlock\", \"NTSU\", \"ElectricFurnance\", \"Extractor\", \"Macerator\", \"Compressor\", \"Chest\", \"CopperChest\", \"IronChest\", \"GoldChest\", \"SapphireChest\", \"RubyChest\", \"ElectricTreeTapper\", \"MiningDrill\", \"Chainsaw\", \"ElectricWrench\", \"Stick\", \"Torch\"}\n\n-- The actual names that each block will be called by in the game.\nblocknames = {\"Air\", \"Stone\"}\n\n-- This code caches images used when drawing blocks.\ndrawblocksz = {}\nfor k, v in ipairs(drawblock) do\n drawblocksz[k] = draw.cacheimage( \"@resources\/Block\" .. v..\".png\")\nend","Applications\/BlockGame\/computerENV.lua":"if not terrain then require \"main\" end\n-- Set up the environment for a new computer.\nlocal computerenv = {}\n\nfunction computerenv.getVersion()\n return \"Lua Script System Indev 1.0\"\nend\n\n-- Used to yield control to the computer\nfunction computerenv.doingEvents()\n coroutine.yield()\n return true\nend\n\n-- Copy tables from the global environment.\ncomputerenv.math = math\ncomputerenv.string = string\ncomputerenv.os = os\ncomputerenv.table = table\ncomputerenv.coroutine = coroutine\n\n-- Now to copy some allowed functions.\ncomputerenv.print = print\ncomputerenv.collectgarbage = collectgarbage\ncomputerenv.xpcall = xpcall\ncomputerenv.pcall = pcall\ncomputerenv.pairs = pairs\ncomputerenv.ipairs = ipairs\n\n-- Then create some extension tables related to the computer environment.\n\n-- Draw library --\ncomputerenv.draw = {}\ncomputerenv.draw.white = draw.white\ncomputerenv.draw.lightgray = draw.lightgray\ncomputerenv.draw.gray = draw.gray\ncomputerenv.draw.darkgray = draw.darkgray\ncomputerenv.draw.black = draw.black\ncomputerenv.draw.blue = draw.blue\ncomputerenv.draw.green = draw.green\ncomputerenv.draw.red = draw.red\ncomputerenv.draw.cyan = draw.cyan\ncomputerenv.draw.purple = draw.purple\ncomputerenv.draw.orange = draw.orange\ncomputerenv.draw.yellow = draw.yellow\ncomputerenv.draw.magenta = draw.magenta\n\n\nfunction computerenv.draw.getport()\n return scrx - 96, scry - 96\nend\n\nfunction computerenv.draw.clear(color)\n draw.clear(color)\nend\n\nfunction computerenv.draw.rect(x1, y1, x2, y2, color)\n x1, y1, x2, y2 = x1 + 48, y1 + 48, x2 + 48, y2 + 48\n draw.rect(x1, y1, x2, y2, color)\nend\n\nfunction computerenv.draw.fillrect(x1, y1, x2, y2, color)\n x1, y1, x2, y2 = x1 + 48, y1 + 48, x2 + 48, y2 + 48\n draw.fillrect(x1, y1, x2, y2, color)\nend\n\nfunction computerenv.draw.line(x1, y1, x2, y2, color)\n x1, y1, x2, y2 = x1 + 48, y1 + 48, x2 + 48, y2 + 48\n draw.line(x1, y1, x2, y2, color)\nend\n\nfunction computerenv.draw.point(x1, y1, color)\n x1, y1 = x1 + 48, y1 + 48\n draw.point(x1, y1, color)\nend\n\nfunction computerenv.draw.string(str, x, y, color)\n x1, y1 = x1 + 48, y1 + 48\n draw.string(str, x, y, color)\nend\n\nfunction computerenv.draw.beginframe()\n drawframe = false\nend\n\nfunction computerenv.draw.endframe()\n drawframe = true\nend\n\nfunction computerenv.draw.setscreenmode(screen)\n\nend\n\n-- World library --\ncomputerenv.world = {}\n\n\n-- Computer library --\ncomputerenv.com = {}\n\n-- Runs a script.\nfunction computerenv.com.runscript(path, env)\n local f = computerenv.io.getSystemPath(path)\n local script, err = loadfile(f, nil, env or computerenv)\n if script then\n local cor = coroutine.create(script)\n coroutine.resume(cor)\n return cor\n else\n print(err)\n end\nend\n\n-- Io library --\ncomputerenv.io = {}\n\nfunction computerenv.io.getSystemPath(path)\n local begin = approot..\"SavedData\/\"..savetofolder..\"\/computer\"..computerid..\"\/\"\n local location = \"Hard Drive\"\n if string.find(string.lower(path), \"rom\") == 1 then\n begin = approot..\"ComROM\/\"\n location = \"Global ROM\"\n local s, e = string.find(string.lower(path), \"rom\")\n return begin..string.sub(path, e + 2), location\n elseif string.find(string.lower(path), \"drive1\") == 1 then\n begin = approot..\"SavedData\/\"..savetofolder..\"\/drive\"..drive1..\"\/\"\n location = \"USB Drive 1\"\n end\n return begin..path, location\nend\n\nio.getSystemPath = computerenv.io.getSystemPath\nfunction computerenv.io.open(filename, mode)\n if not lfs.isDirectory(io.getSystemPath(\"\")) then\n lfs.mkdir(io.getSystemPath(\"\"))\n end\n filename = io.getSystemPath(filename)\n return io.open(filename, mode)\nend\n\n-- File system library\ncomputerenv.fs = {}\n\nfunction computerenv.fs.getFreeSpace(path)\n local fullpath, drive = computerenv.io.getSystemPath(path)\n local totalsize = 1024*1024*20\n local used = 0\n if drive == \"Hard Drive\" then\n path = computerenv.io.getSystemPath(\"\")\n for k, v in ipairs(sys.dir(path)) do\n if lfs.isFile(path..\"\/\"..v) then\n used = used + lfs.fileSize(path..\"\/\"..v)\n end\n end\n end\n return totalsize - used\nend\n\nreturn computerenv","Applications\/ScriptEditor\/ScriptEditor.lua":"draw.setscreen(1)\ndraw.settitle(\"Script Editor\")\nScreenX, ScreenY = draw.getport()\nif not libRoot then\n libRoot = \"..\/..\/..\/..\/\"\n defloc = \"..\/..\/Documents\"\nelse\n defloc = \"Documents\"\nend\nif not filebrowser then\n filebrowser = require \"filebrowser\"\nend\nrequire \"keyboard\"\nlocal location\nif arg then\n location = arg[1]\nend\n\n-- Load the Application configuration\n--App.LoadConfiguration(\"Script Editor\")\n\n-- Variables\n\nrequire \"ScriptEditor2\"\n\n\nScrollSpeed = 0\nScrollX, ScrollY = 0, 0\n\nfunction RunScript()\n sys.clear()\n local ScriptCode = \"\"\n for k, v in ipairs(Script) do\n ScriptCode = ScriptCode..v..\"\\n\"\n end\n Run, err = load(ScriptCode)\n if not Run then\n print(Run, err)\n end\n if not Run then\n draw.beginframe()\n draw.fillrect(48, 48, ScreenX - 48, ScreenY - 48, draw.lightgray)\n draw.string(\"There are errors in the script you are attempting to run.\\nYou need to fix these errors before running your script.\", 48, 48, draw.black)\n draw.stringinrect(err, 48, 96, ScreenX - 48, ScreenY - 48, draw.red)\n if string.find(err, \"'=' expected near\") then\n draw.stringinrect(\"Check to make sure that the line is spelled correctly.\", 48, 156, ScreenX - 48, ScreenY - 48, draw.red)\n end\n draw.string(\"Tap the screen to edit the errored line.\", 48, ScreenY - 64, draw.black)\n draw.endframe()\n draw.waittouch()\n local ShortText = string.sub(err, string.find(err, '...\"]:'), -1)\n EditLine(tonumber(string.sub(ShortText, 7, string.find(ShortText, ':') + 1)))\n return\n end\n draw.setscreen(0)\n ok, err = pcall(Run)\n if not ok then print(err) end\n draw.setscreen(1)\n draw.settitle(\"Script Editor\")\n draw.setantialias(true)\nend\n\nfunction SaveScript()\n if not filelocation then\n filelocation = filebrowser.loadfile(\"Save Script\", \"Documents\", true)\n end\n if filelocation then\n draw.beginframe()\n draw.clear()\n draw.stringinrect(\"Saving Script...\", 0, ScreenY*.5, ScreenX, ScreenY, draw.black)\n draw.endframe()\n local ScriptFile = io.open(filelocation, \"w\")\n for k, v in ipairs(Script) do\n ScriptFile:write(v..\"\\n\")\n end\n ScriptFile:close()\n end\nend\n\nfunction LoadScript(filelocation)\n if not filelocation then\n filelocation = filebrowser.loadfile(\"Load Script\", defloc)\n end\n if filelocation then\n draw.beginframe()\n draw.clear()\n draw.stringinrect(\"Please Wait...\", 0, ScreenY*.5, ScreenX, ScreenY, draw.black)\n draw.endframe()\n Script = {}\n local ScriptFile = io.open(filelocation)\n local Code = tostring(ScriptFile:read())\n while Code ~= \"nil\" do\n Script[#Script + 1] = Code\n Code = tostring(ScriptFile:read())\n end\n ScriptFile:close()\n RegenerateScriptColors()\n else\n ScrollMax = (#Script + 6)*20 - ScreenY\n end\nend\n\nfunction EditLine(Line)\n text = Key.Keyboard(\"You are editing Line \"..Line, Script[Line])\n if text then\n Script[Line] = text\n RegenerateScriptColors()\n end\nend\n\nfunction StartTouch(x, y)\n if x > ScreenX - 48 then\n Scrolling = true\n TypeIn = false\n else\n oldX, oldY = x, y\n Scrolling = false\n end\nend\n\nfunction Touch(x, y)\n local Max = ScrollMax\n if not Scrolling then\n if oldY then\n if y > oldY + 12 or y < oldY - 12 then\n TypeIn = false\n ScrollSpeed = (ScrollSpeed*.40) -((y - oldY)*.15)\n oldX, oldY = x, y\n else\n ScrollSpeed = 0\n TypeIn = true\n end\n end\n oldX, oldY = x, y\n elseif ScrollMax > 0 then\n local ScreenY = ScreenY - 48\n local Size = math.max((ScreenY\/Max)*(ScreenY\/3.3333), 48)\n if ScrollMax <= 0 then\n Size = ScreenY\n end\n --ScrollX = ((x - (Size*.5))*MaxX)\/(ScreenX - Size)\n ScrollY = ((y - (Size*.5))*Max)\/(ScreenY - Size)\n else\n ScrollSpeed = 0\n TypeIn = true\n end\nend\n\nfunction EndTouch(x, y)\n Scrolling = false\n local appnum = 0\n if y < 20 then\n ScrollY = 0\n elseif y > ScreenY - 48 then\n if x < 48 then\n RunScript()\n elseif x < 96 then\n SaveScript()\n elseif x < 128 then\n LoadScript()\n elseif x > ScreenX - 48 then\n run = false\n end\n elseif ScrollSpeed == 0 and TypeIn then\n TypeIn = false\n local Line = math.min(math.floor((y + ScrollY)\/20), #Script + 1)\n EditLine(Line)\n end\nend\n\nRegenerateScriptColors()\ndraw.tracktouches(StartTouch, Touch, EndTouch)\n\nfunction Scroll()\n if ScrollMax > 0 then\n if ScrollSpeed ~= 0 then\n InvalidateDrawing = true\n end\n ScrollY = ScrollY + ScrollSpeed\n if ScrollY < 0 then\n ScrollY = 0\n ScrollSpeed = 0\n elseif ScrollY > ScrollMax then\n ScrollY = ScrollMax\n ScrollSpeed = 0\n end\n if ScrollSpeed > .20 then\n ScrollSpeed = ScrollSpeed - .20\n elseif ScrollSpeed < -.20 then\n ScrollSpeed = ScrollSpeed + .20\n else\n ScrollSpeed = 0\n end\n else\n ScrollY = 0\n end\nend\n\nfunction ScrollBar(Scroll, Max)\n local ScreenY = ScreenY - 48\n local Size = math.max((ScreenY\/Max)*(ScreenY\/3.3333), 48)\n if Max <= 0 then\n Size = ScreenY\n end\n draw.fillrect(ScreenX - 48, (Scroll\/Max)*(ScreenY - Size), ScreenX, ((Scroll\/Max)*(ScreenY - Size)) + Size, draw.blue)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY, draw.black)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY, draw.black)\nend\n\nfunction MenuBar()\n draw.fillrect(0, ScreenY - 48, ScreenX, ScreenY, draw.gray)\n draw.filltriangle(0, ScreenY - 48, 0, ScreenY, 48, ScreenY - 24, draw.blue)\n draw.image(\"@resources\/LAMSave.png\", 48, ScreenY - 48)\n draw.transformedimage(\"@resources\/LAMFolder.png\", 96 + 24, ScreenY - 24, 1, 0)\n draw.transformedimage(\"@resources\/LAMSearch.png\", 144 + 24, ScreenY - 16, 1.5, 0)\nend\n\nif location then\n LoadScript(location)\nend\nrun = math.huge\nwhile run do\n draw.tracktouches(StartTouch, Touch, EndTouch)\n Scroll()\n draw.beginframe()\n draw.clear()\n DrawScriptCode(ScrollX, ScrollY)\n ScrollBar(ScrollY, ScrollMax)\n MenuBar()\n draw.endframe()\n draw.doevents()\nend","Applications\/ScriptEditor":"nil","Applications\/BlockGame\/ComROM\/shell.lua":"print(\"Shell started\")\n\nwhile doingEvents() do\n draw.beginframe()\n draw.fillrect(0, 0, 48, 48, draw.blue)\n draw.endframe()\nend","Applications\/HTMLViewer\/main.lua":"html = require \"htmlviewer\"\n\nlocal pagecontents = [[\n<!doctype html>\n<html>\n\t<head>\n\t\t<title>Title...<\/title>\n\t<\/head>\n\t<body>\n\t\tContent goes here...\n\t<\/body>\n<\/html>\n]]\n\ndraw.setscreen(1)\nhtml.preparePage(pagecontents)\nhtml.viewPage()","AutoInstall.lua":"local directory = \"InstallApplication\"\nprint(\"Checking for install files in \"..directory..\"...\")\n\nlocal function requireFromRoot(File)\n local Handle, err = io.open(\"..\/\"..File..\".lua\")\n local String, Funct = \"\", nil\n if Handle then\n String = \"require = requireFromRoot\\n\"..Handle:read(\"*a\")\n Handle:close()\n Funct = load(String)\n end\n --local Funct, err = loadfile(\"..\"..File..\".lua\")\n if Funct then\n local var1 = Funct()\n require = Require\n return var1 or true\n else\n oldrequire(File)\n end\nend\n\nlocal files = sys.dir(directory)\nif files then\n if #files > 2 then\n JSON = require \"JSON\"\n lfs = require \"lfs\"\n if #files - 2 > 1 then\n print(#files - 2 .. \" application stubs found.\")\n else\n print(#files - 2 .. \" application stub found.\")\n end\n print(\"Lua Application Manager is loading the stubs...\")\n local installstring = \"\"\n for k, v in ipairs(files) do\n if v ~= \".\" and v ~= \"..\" then\n local file = io.open(directory..\"\/\"..v)\n installstring = installstring..file:read(\"*a\")\n file:close()\n end\n end\n local Table = JSON.DecodeJSON(installstring)\n if Table[\"LuaApp.lua\"] then\n local namestart = string.find(Table[\"LuaApp.lua\"], \"\\n\") + 1\n local nameend = string.find(string.sub(Table[\"LuaApp.lua\"], namestart), \"\\n\") - 1\n local name = string.sub(Table[\"LuaApp.lua\"], namestart, namestart + nameend - 1)\n print(name..\" is now being installed...\")\n local InstallDir = \"Applications\/\"..name\n lfs.mkdir(InstallDir)\n for k, v in pairs(Table) do\n if string.find(k, \"\/\") then\n lfs.mkdir(InstallDir..\"\/\".. string.sub(k, 0, string.find(k, \"\/\")))\n end\n local file = io.open(InstallDir..\"\/\"..k, \"w\")\n file:write(v)\n file:close()\n end\n print(name..\" has been sucessfuly installed.\")\n end\n else\n print(\"No install files found.\")\n end\nend","Applications\/CubotsMarch!":"nil","main.lua":"sys.clear()\nif not draw.image then\n print(\"You are running an unsupported version of Touch Lua. You need to update Touch Lua to the latest version.\")\n print(\"If you are using iOS 6 or earlier you will need to update to iOS 7 or later to update Touch Lua. Thank you for trying this program.\")\n error(\"You need to update Touch Lua to run Lua Application Manager!\", -1)\nend\nprint(\"Preparing API...\")\nlibRoot = \"..\/..\/\"\nlamfolder = \"AALuaAppManager\"\nUseDrawLibrary = true\nShowSize = true\nButtonHeight = 48\nFPS = 90\nColor = draw.blue\nColor2 = draw.purple\nAppMan = {\n [\"Draw\"] = {},\n [\"Apps\"] = {},\n}\n\nrequire \"mainapi\"\n\nlfs = require \"lfsplus\"\nfilebrowser = require \"filebrowser\"\n\n-- Check for Install Stubs\nrequire \"AutoInstall\"\n\nfunction TappedButton(x1, y1, x2, y2, tx, ty)\n if tx >= x1 and tx <= x2 then\n if ty >= y1 and ty <= y2 then\n return true\n end\n end\n return false\nend\n\n-- This loads the app into the registry.\nfunction AppMan.LoadApp(Folder)\n File = io.open(Folder..\"\/LuaApp.lua\")\n if not File then\n return false\n end\n File:read()\n local Title = File:read()\n local ShortTitle = File:read()\n local Description = File:read()\n local Version = File:read()\n local Author = File:read()\n local StartScript = File:read()\n local Icon = File:read()\n File:close()\n AppMan[\"Apps\"][Title] = {\n [\"Folder\"] = Folder,\n [\"Short\"] = ShortTitle,\n [\"Descr\"] = Description,\n [\"Ver\"] = Version,\n [\"Author\"] = Author,\n [\"Start\"] = StartScript,\n [\"Icon\"] = Icon,\n }\n if ShowSize then\n local Size = 0\n for k, v in ipairs(sys.dir(Folder)) do\n File = lfs.isFile(Folder..\"\/\"..v)\n if File then\n local str = lfs.fileSize(Folder..\"\/\"..v)\n if str then\n Size = Size + str\n end\n end\n end\n AppMan[\"Apps\"][Title][\"Size\"] = Size\n end\n Apps = Apps + 1\nend\n\n-- This loads the apps in the default folder.\nfunction AppMan.LoadApps()\n Apps = 0\n for k, v in ipairs(sys.dir(\"Applications\")) do\n AppMan.LoadApp(\"Applications\/\"..v)\n end\nend\n\n-- This starts the correct application for the file selected.\nfunction AppMan.OpenFile(File)\n local str = string.reverse(File)\n local ending = string.find(str, \"%.\")\n local ext = string.sub(File, -ending)\n local AppToOpen = registry.getvalue(\"DefaultApp\", ext)\n if AppToOpen then\n AppMan.RunApp(AppToOpen, File)\n else\n AppMan.RunApp(\"Script Editor\", File)\n end\nend\n\n-- This starts the application.\nfunction AppMan.RunApp(Title, ...)\n local args = table.pack(...)\n if not AppMan.oldrequire then\n AppMan.oldrequire = require\n AppMan.requireTab = {}\n AppMan.approotTab = {}\n end\n if not AppMan.runningApps then\n AppMan.runningApps = 0\n end\n AppMan.runningApps = AppMan.runningApps + 1\n if AppMan.runningApps <= 1 then\n AppMan.Scroll = Scroll\n AppMan.ScrollMax = ScrollMax\n print(\"Exiting Main Menu.\")\n end\n if not AppMan.Apps[Title] then\n error(\"application \"..Title..\" does not exist or is not installed.\", 2)\n end\n approot = AppMan.Apps[Title][\"Folder\"]..\"\/\"\n function require(title)\n ok = table.pack(pcall(AppMan.oldrequire, title))\n if not ok[1] then\n return AppMan.oldrequire(approot..title)\n else\n table.remove(ok, 1)\n return table.unpack(ok)\n end\n end\n AppMan.requireTab[AppMan.runningApps] = require\n AppMan.approotTab[AppMan.runningApps] = approot\n arg = args\n local ok, err = AppMan.oldrequire(approot..AppMan.Apps[Title][\"Start\"], ...)\n if not ok then\n print(err)\n end\n AppMan.runningApps = AppMan.runningApps - 1\n approot = AppMan.approotTab[AppMan.runningApps]\n if AppMan.runningApps < 1 then\n print(\"\\n< All Applications Returned >\")\n print(\"Exiting to Main Menu.\")\n require = AppMan.oldrequire\n if UseDrawLibrary == true then\n draw.setscreen(1)\n InvalidateDrawing = true\n draw.settitle(\"Lua Application Manager\")\n end\n ScrollMax = AppMan.ScrollMax or (ButtonHeight*Apps)\n Scroll = AppMan.Scroll or 0\n SelectedApp = nil\n else\n require = AppMan.requireTab[AppMan.runningApps]\n end\nend\n\nlocal def = \"..\/..\/TouchLua.app\/Icon.png\"\n\nlocal dx, dy = draw.cacheimage(def)\n\n-- View the menu for the selected app.\nfunction AppMan.AppInfoMenu(Title)\n local app = AppMan.Apps[Title]\n local sizex, sizey = draw.cacheimage(app.Folder.. \"\/\"..app.Icon)\n while true do\n draw.beginframe()\n draw.clear()\n draw.transformedimage(def, 64, 80, 2, 0, 0)\n draw.transformedimage(app.Folder.. \"\/\"..app.Icon, 64, 80, 2, 0, 0)\n draw.setfont(\"Arial\", 24)\n draw.string(Title, 128, 24, draw.black)\n draw.setfont(\"Arial\", 16)\n draw.string(app[\"Ver\"], 128, 48, draw.black)\n draw.string(\"By \"..app[\"Author\"], 128, 64, draw.black)\n draw.string(app[\"Size\"]..\" bytes\", 128, 80, draw.black)\n draw.stringinrect(app[\"Descr\"], 128, 108, ScreenX - 24, 256, draw.black)\n draw.fillrect(0, ScreenY - 96, ScreenX, ScreenY, draw.gray)\n -- Draw Actions\n draw.filltriangle(6, ScreenY - 90, 6, ScreenY - 54, 42, ScreenY - 72, draw.white)\n draw.string(\"Run Application\", 48, ScreenY - 82, draw.black)\n draw.transformedimage(\"..\/..\/TouchLua.app\/trash@2x.png\", ScreenX*.5 + 24, ScreenY - 72, .75, 0)\n draw.string(\"Uninstall Application\", ScreenX*.5 + 48, ScreenY - 82, draw.red)\n draw.transformedimage(\"..\/..\/TouchLua.app\/pencil@2x.png\", 24, ScreenY - 24, .75, 0)\n draw.string(\"Configure Application\", 48, ScreenY - 34, draw.black)\n draw.transformedimage(\"@resources\/LAMSearch.png\", ScreenX*.5 + 24, ScreenY - 24, .75, 0)\n draw.string(\"View Application Folder\", ScreenX*.5 + 48, ScreenY - 34, draw.blue)\n draw.transformedimage(\"@resources\/LAMBack.png\", ScreenX - 24, 25, 2, 0)\n draw.endframe()\n local x, y = draw.waittouch()\n if y >= ScreenY - 96 then\n if x < ScreenX*.5 and y < ScreenY - 48 then -- Selected Run Application\n AppMan.RunApp(SelectedAppKey)\n elseif x >= ScreenX*.5 and y < ScreenY - 48 then -- Selected Uninstall Application\n\n elseif x < ScreenX*.5 and y > ScreenY - 48 then -- Selected Configure Application\n AppMan.RunApp(SelectedAppKey, \"Configuration Mode\")\n elseif x >= ScreenX*.5 and y > ScreenY - 48 then -- Selected View Application\n AppMan.RunApp(\"File Browser\", tostring(app[\"Folder\"]))\n end\n elseif x > ScreenX - 56 and y < 56 then\n InvalidateDrawing = true\n return\n end\n end\nend\n\n-- This draws the application list.\nfunction AppMan.Draw.AppList(Scroll)\n Scroll = Scroll - 20\n local appnum = 0\n for k, v in pairs(AppMan.Apps) do\n appnum = appnum + 1\n if (appnum*ButtonHeight) - Scroll >= 0 and ((appnum - 1)*ButtonHeight) - Scroll <= ScreenY - 48 then\n if SelectedApp == appnum then\n draw.fillrect(0, ((appnum - 1)*ButtonHeight) - Scroll, ScreenX - 48, (appnum*ButtonHeight) - Scroll, Color)\n end\n draw.line(0, (appnum*ButtonHeight) - Scroll, ScreenX - 48, (appnum*ButtonHeight) - Scroll, Color)\n draw.string(k, 48, ((appnum - 1)*ButtonHeight) - Scroll, draw.black)\n draw.string(v.Author, 48, (((appnum - 1)*ButtonHeight) + 24) - Scroll, draw.black)\n draw.string(v.Size..\" bytes\", 228, (((appnum - 1)*ButtonHeight) + 24) - Scroll, draw.black)\n draw.transformedimage(def, 24, ((appnum - 1)*ButtonHeight) - Scroll + 24, 1\/(math.min(dx, dy)\/48), 0, 0)\n draw.transformedimage(v.Folder.. \"\/\"..v.Icon, 24, ((appnum - 1)*ButtonHeight) - Scroll + 24, 1, 0, 0)\n end\n end\nend\n\nfunction AppMan.Draw.ScrollBar(Scroll, Max)\n local Size = math.min(math.max((ScreenY\/Max)*(ScreenY\/3.3333), 48), ScreenY - 48)\n if Max <= 0 then\n Size = ScreenY\n end\n draw.fillrect(ScreenX - 48, (Scroll\/Max)*(ScreenY - Size), ScreenX, ((Scroll\/Max)*(ScreenY - Size)) + Size, Color)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY, draw.black)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY, draw.black)\nend\n\nfunction AppMan.Draw.MenuBar()\n draw.fillrect(0, ScreenY - 64, ScreenX - 48, ScreenY, draw.darkgray)\n if SelectedApp then\n draw.filltriangle(8, ScreenY - 56, 8, ScreenY - 8, 56, ScreenY - 32, draw.white)\n draw.transformedimage(\"..\/..\/TouchLua.app\/book.png\", 96, ScreenY - 32, 2, 0)\n end\nend\n\nlocal function StartTouch(x, y)\n oldX, oldY = x, y\n if x > ScreenX - 48 then\n Scrolling = true\n else\n Scrolling = false\n end\nend\n\nlocal function Touch(x, y)\n if not Scrolling then\n if oldY then\n ScrollSpeed = (ScrollSpeed*.75) -((y - oldY)*.15)\n end\n oldX, oldY = x, y\n elseif ScrollMax > 0 then\n local Size = math.min(math.max((ScreenY\/Max)*(ScreenY\/3.3333), 48), ScreenY - 48)\n if Max <= 0 then\n Size = ScreenY\n end\n Scroll = ((y - (Size*.5))*Max)\/(ScreenY - Size)\n InvalidateDrawing = true\n end\nend\n\nlocal function EndTouch(x, y)\n Scrolling = false\n Scroll = Scroll\n local appnum = 0\n if x < ScreenX - 48 and y < ScreenY - 64 and ScrollSpeed < 5 and ScrollSpeed > -5 then\n for k, v in pairs(AppMan.Apps) do\n appnum = appnum + 1\n if (appnum*ButtonHeight) - Scroll >= y and ((appnum - 1)*ButtonHeight) - Scroll <= y then\n if SelectedApp == appnum then\n AppMan.RunApp(k)\n else\n SelectedApp = appnum\n SelectedAppKey = k\n InvalidateDrawing = true\n end\n end\n end\n elseif y > ScreenY - 64 then\n if SelectedApp then\n if x < 64 then\n AppMan.RunApp(SelectedAppKey)\n elseif x < 128 then\n AppMan.AppInfoMenu(SelectedAppKey)\n elseif x < 172 then\n SelectedApp = nil\n SelectedAppKey = nil\n InvalidateDrawing = true\n end\n else\n\n end\n end\nend\n\nprint(\"Loading Apps...\")\nAppMan.LoadApps()\n\nprint(\"Loading Registry...\")\nrequire \"registry\"\n\n-- Variables\nScroll, ScrollMax = 0, (ButtonHeight*Apps)\nScrollSpeed = 0\nSelectedApp = nil\n\nlocal Time1, Time2\nif UseDrawLibrary then\n draw.setscreen(1)\n draw.settitle(\"Lua Application Manager\")\n ScreenX, ScreenY = draw.getport()\n draw.tracktouches(StartTouch, Touch, EndTouch)\n ScrollMax = math.max((ButtonHeight*Apps) - (ScreenY - 96), 0)\n Max = ScrollMax\n InvalidateDrawing = true\n for k=1, math.huge do\n draw.tracktouches(StartTouch, Touch, EndTouch)\n Time1 = os.clock()\n oldscreenX = ScreenX\n ScreenX, ScreenY = draw.getport()\n if ScreenX ~= oldscreenX then\n InvalidateDrawing = true\n ScrollMax = math.max((ButtonHeight*Apps) - (ScreenY - 96), 0)\n end\n draw.doevents()\n if ScrollMax > 0 then\n if ScrollSpeed ~= 0 then\n InvalidateDrawing = true\n end\n Scroll = Scroll + ScrollSpeed\n if Scroll < 0 then\n Scroll = 0\n ScrollSpeed = 0\n elseif Scroll > ScrollMax then\n Scroll = ScrollMax\n ScrollSpeed = 0\n end\n if ScrollSpeed > .20 then\n ScrollSpeed = ScrollSpeed - .20\n elseif ScrollSpeed < -.20 then\n ScrollSpeed = ScrollSpeed + .20\n else\n ScrollSpeed = 0\n end\n else\n Scroll = 0\n end\n if InvalidateDrawing then\n draw.beginframe()\n draw.clear()\n AppMan.Draw.AppList(Scroll)\n AppMan.Draw.ScrollBar(Scroll, ScrollMax)\n AppMan.Draw.MenuBar()\n --draw.string(collectgarbage(\"count\"), 0, ScreenY - 48, draw.black)\n draw.endframe()\n InvalidateDrawing = false\n end\n Time2 = os.clock()\n sys.sleep((1000\/FPS) - (Time2 - Time1))\n end\nelse\n print(\"Application Support Updated.\")\nend","Documents\/DrawBenchmark.lua":"Draw = {}\ndraw.setscreen(1)\nTerrain = {}\nmath.randomseed(6)\n\nlocal D255 = 1\/255\nfunction Draw.Col255(R,G,B,A)\n A = A or 255 return {R*D255,G*D255,B*D255,A*D255}\nend\nCol255 = Draw.Col255\n\nlocal Col255 = Draw.Col255\nTerrainColors = {\n Col255(24, 255, 0), -- Grass\n Col255(24, 170, 0), -- Dark Grass\n Col255(255, 255, 0), -- Dirt\n Col255(170, 170, 0), -- Dark Dirt\n Col255(0, 0, 255), -- Tile 3\n Col255(255, 0, 255) -- Dark Tile 3\n}\n\nprint(\"Loading Terrain\")\n\nZAngleTimes = 45\nZCosTimes = 0\nZSinTimes = 2\nZTanTimes = 1\n\nwidth, height = draw.getport()\nxc = math.floor(width\/2)\nyc = math.floor(height\/2)\nunit = 30 -- Size of block --30\nzangle = ZAngleTimes \/ 180 * math.pi --35 \/ 180 * math.pi -- X Angle\nzcos = ZCosTimes*math.cos(zangle) -- Y roll\nzsin = ZSinTimes*math.sin(zangle) -- Z roll\nztan = ZTanTimes*zsin\/zcos\nd = .50\nsubX = ((.07302*(d*4))*(zangle\/0.785398163397)*(zcos\/0.1))\nlocal subX = subX\n\nfunction MapX(x, z)\n return xc + x * unit - z * unit * zcos\nend\nfunction MapY(y, z)\n return yc - y * unit + z * unit * zsin\nend\n\nfunction Fill3D(func, r, color, pos, pos2)\n draw.setantialias(false)\n pos, pos2 = pos or 0, pos2 or 0\n local d = d --.25*2 -- size of each grid\n local Blend\n --[[if math.floor(d*4) - d*4 ~= 0 then\nBlend = true\nend]]\n local y, mx, my, tx, ty, rx, ry -- drawing positions\n local yshadow, MapX, MapY = nil, MapX, MapY\n local nx, ny, nz -- temp for second and third pairs\n local co2\n local triangles = 0\n for z = -r + pos2, r + pos2, d do\n local x = -r\n for x = -r + pos, r + pos, d do\n -- First corner\n y, color = func(x, z, Blend)\n if not type(color) == \"table\" then\n color = draw.blue\n end\n mx = MapX(x, z)\n my = MapY(y, z)\n -- Second two\n nx = x - d\n nz = z + d\n ny = func(nx, nz, Blend)\n rx = MapX(nx, nz)\n ry = MapY(ny, nz)\n -- Third two\n ny = func(x, nz, Blend)\n tx = MapX(x, nz)\n ty = MapY(ny, nz)\n -- Fourth corner\n ny = func(nx, z, Blend)\n fx = MapX(nx - subX, nz)\n fy = MapY(ny, z)\n -- draw the Plane\n draw.filltriangle(mx, my, tx, ty, rx, ry, color)\n draw.filltriangle(rx, ry, fx, fy, mx, my, color)\n triangles = triangles + 2\n if DrawShadows then\n yshadow = (func(x, z - d) - y) * 48\n co2 = nil\n if yshadow > 8 then\n co2 = Draw.Col255(0,0,0,yshadow)\n elseif yshadow < 0 then\n co2 = Draw.Col255(255,255,255, yshadow*4)\n end\n if co2 then\n draw.filltriangle(mx, my, tx, ty, rx, ry, co2)\n draw.filltriangle(rx, ry, fx, fy, mx, my, co2)\n triangles = triangles + 2\n end\n end\n -- draw Polygon outlines\n --[[if DrawMesh then\n-- line 1\ndraw.moveto( mx, my)\ndraw.lineto( tx, ty, draw.yellow)\n-- line 2\ndraw.moveto( mx, my)\ndraw.lineto( rx, ry, draw.orange)\n-- line 3\ndraw.moveto( tx, ty)\ndraw.lineto( rx, ry, draw.lightgray)\n-- now draw the points\ndraw.point(mx, my, draw.red)\ndraw.point(tx, ty, draw.purple)\ndraw.point(rx, ry, draw.blue)\nend]]\n end\n end\n --[[for x = -r + pos, r + pos, d do\nlocal z = -r\nfor z = -r + pos2, r + pos2, d do\n-- First two\ny, color = func(x, z)\n--if type(color) ~= \"table\" then\ncolor = draw.blue\nend\nmx = MapX(x, z)\nmy = MapY(y, z)\n-- Second two\nnx = x - d\nnz = z + d\nny = func(nx, nz)\nrx = MapX(nx, nz)\nry = MapY(ny, nz)\n-- Third two\nny = func(nx, z)\ntx = MapX(nx, z)\nty = MapY(ny, z)\n-- draw the Plane\ndraw.filltriangle(mx, my, tx, ty, rx, ry, color)\ntriangles = triangles + 1\nif DrawShadows then\nyshadow = (func(x, z-d) - y) * 48\nif yshadow > 0 then\ndraw.filltriangle(mx, my, tx, ty, rx, ry, Draw.Col255(0,0,0,yshadow))\ntriangles = triangles + 1\nend\nend\nend\nend]]\n draw.setantialias(true)\n return triangles\nend\n\nfunction Plot3D(func, r, color, pos, pos2)\n pos, pos2 = pos or 0, pos2 or 0\n local d = .25\n local y, mx, my\n for z = -r + pos2, r + pos2, d do\n local x = -r\n y = func(x, z)\n mx = MapX(x, z)\n my = MapY(y, z)\n draw.moveto( mx, my)\n for x = -r + pos, r + pos, d do\n y = func(x, z)\n mx = MapX(x, z)\n my = MapY(y, z)\n draw.lineto( mx, my, draw.cyan)\n end\n end\n for x = -r + pos, r + pos, d do\n local z = -r\n y = func(x, z)\n mx = MapX(x, z)\n my = MapY(y, z)\n draw.moveto( mx, my)\n for z = -r + pos2, r + pos2, d do\n y = func(x, z)\n mx = MapX(x, z)\n my = MapY(y, z)\n draw.lineto( mx, my, color)\n end\n end\nend\n\nTerTab = {}\n\nfunction Terrain.CreateBlock(X, Z, Height, Color)\n local ZTab = TerTab[Z]\n ZTab[X] = {}\n local XTab = ZTab[X]\n ZTab[X] = {Height, Color}\nend\n\nTGrid = 30\n\nfunction Terrain.Flatten(H, Color)\n Color = Color or 1\n for TZ=0, TGrid, 1 do\n if not TerTab[TZ] then\n TerTab[TZ] = {}\n end\n if not TerTab[-TZ] then\n TerTab[-TZ] = {}\n end\n for TX=0, TGrid do\n Terrain.CreateBlock(TX, TZ, H, Color)\n Terrain.CreateBlock(TX, -TZ, H, Color)\n Terrain.CreateBlock(-TX, TZ, H, Color)\n Terrain.CreateBlock(-TX, -TZ, H, Color)\n end\n end\nend\n\nfunction Terrain.Randomize(H, Color)\n Color = Color or 1\n --math.randomseed(1)\n for TZ=0, TGrid do\n if not TerTab[TZ] then\n TerTab[TZ] = {}\n end\n if not TerTab[-TZ] then\n TerTab[-TZ] = {}\n end\n for TX=0, TGrid do\n Color = math.random(#TerrainColors)\n Terrain.CreateBlock(TX, TZ, math.random()*H, Color)\n Terrain.CreateBlock(TX, -TZ, math.random()*H, Color)\n Terrain.CreateBlock(-TX, TZ, math.random()*H, Color)\n Terrain.CreateBlock(-TX, -TZ, math.random()*H, Color)\n end\n end\nend\n\n--Terrain.Flatten(1)\nTerrain.Randomize(1)\n\nfunction Func(X, Z, Blend)\n --X2, Z2 = math.ceil(X), math.ceil(Z)\n if (X == math.floor(X) and Z == math.floor(Z)) or (not Blend) then\n X, Z = math.floor(X), math.floor(Z)\n local ZTab = TerTab[Z][X]\n if ZTab ~= nil then\n return tonumber(ZTab[1]), TerrainColors[ZTab[2]] or 0, draw.blue\n end\n return 0, draw.blue -- incase the other one breaks\n else\n local X2, Z2 = math.ceil(X), math.ceil(Z)\n local X3, Z3 = math.abs(X - X2), math.abs(X - Z2)\n X, Z = math.floor(X), math.floor(Z)\n local ZTab = TerTab[Z][X]\n local ZTab2 = TerTab[Z2][X2]\n if ZTab ~= nil and ZTab2 ~= nil then\n local val = math.max(ZTab[1], ZTab2[1]) - math.min(ZTab[1], ZTab2[1])\n return tonumber(math.min(ZTab[1], ZTab2[1]) + (val*X3)), TerrainColors[ZTab[2]]\n end\n return 0, draw.blue -- incase the other one breaks\n end\n return 0, draw.blue -- incase the other one breaks\nend\n\nlocal oldtime = os.clock()\nfor r=1, 24 do\n draw.beginframe()\n draw.clear()\n local oldtime = os.clock()\n Fill3D(Func, r, color, 0, 0)\n local newtime = os.clock()\n draw.string((newtime - oldtime), 0, 24, draw.black)\n draw.endframe()\nend\nlocal newtime = os.clock()\nprint(\"Total Time To Draw Terrain: \"..newtime - oldtime..\" seconds\")","LAMAPI\/drawcontrols.lua":"local controls = {}\n\nfunction levassert(value, message, errlevel)\n if not value then\n error(message, errlevel)\n end\nend\n\nfunction funassert(value, message)\n levassert(value, message, 1)\nend\n\nfunction draw.dpos(x1, y1, x2, y2)\n funassert(type(x1) == \"number\", \"bad argument #1 to 'dpos' (number expected, got \"..type(x1)..\")\" )\n return math.min(x1, x2), math.min(y1, y2), math.max(x1, x2), math.max(y1, y2)\nend\n\nfunction draw.inrange(v, vfloor, vceil)\n return math.max(math.min(v, vceil), vfloor)\nend\n\n-- Draws a horizonal progress bar.\nfunction controls.progBar(prog, x1, y1, x2, y2, color)\n color = color or draw.blue -- Set defaults\n x1, y1, x2, y2 = draw.dpos(x1, y1, x2, y2)\n local x3 = draw.inrange(x1 + (x2 - x1)*prog, x1, x2)\n draw.fillrect(x1, y1, x2, y2, draw.gray)\n draw.fillrect(x1, y1, x3, y2, color)\nend\n\n\n-- Draws a vertical progress bar.\nfunction controls.vertProgBar(prog, x1, y1, x2, y2, color)\n color = color or draw.blue -- Set defaults\n x1, y1, x2, y2 = draw.dpos(x1, y1, x2, y2)\n local y3 = draw.inrange(y1 + (y2 - y1)*prog, y1, y2)\n draw.fillrect(x1, y1, x2, y2, draw.gray)\n draw.fillrect(x1, y1, x2, y3, color)\nend\n\n\n-- Draws a horizonal scroll bar.\nfunction controls.scrollBar(scroll, scrollmax, x1, y1, x2, y2, color)\n color = color or draw.blue -- Set defaults\n x1, y1, x2, y2 = draw.dpos(x1, y1, x2, y2)\n local length = math.max(((x2 - x1)\/scrollmax)*((x2 - x1)\/3.3333), 48)\n local x3 = draw.inrange(x1 + (x2 - x1 - length)*(scroll\/scrollmax), x1, x2 - length)\n draw.fillrect(x1, y1, x2, y2, draw.gray)\n draw.fillrect(x3, y1, x3 + length, y2, color)\nend\n\n-- Draws a vertical scroll bar.\nfunction controls.verScrollBar(scroll, scrollmax, x1, y1, x2, y2, color)\n color = color or draw.blue -- Set defaults\n x1, y1, x2, y2 = draw.dpos(x1, y1, x2, y2)\n local height = math.max(((y2 - y1)\/scrollmax)*((y2 - y1)\/3.3333), 48)\n local y3 = draw.inrange(y1 + (y2 - y1 - height)*(scroll\/scrollmax), y1, y2 - height)\n draw.fillrect(x1, y1, x2, y2, draw.gray)\n draw.fillrect(x1, y3, x2, y3 + height, color)\nend\n\n\nreturn controls","InstallApplication":"nil","RegenerateImages.lua":"print(\"Regenerating Images...\")\ndraw.setscreen(1)\ndraw.settitle(\"Regenerating Images...\")\ndraw.setclearcolor(draw.magenta)\nlocal drawcolor = {.7, .7, .75, 1}\nlocal drawcolor2 = {.8, .8, .9, 1}\nlocal drawcolor3 = {.5, .55, .6, 1}\nlocal bluecolor = {.2, .2, .75, 1}\nlocal bluecolor2 = {.4, .4, .9, 1}\nlocal bluecolor3 = {.1, .1, .6, 1}\nlocal s = 1 -- scale\n\nfunction drawmail(color, shadow)\n draw.setlinestyle(1.1, \"butt\")\n draw.fillrect(4*s, 10*s, 44*s, 38*s, color)\n draw.filltriangle(4*s, 11*s, 24*s, 25*s, 44*s, 11*s, shadow)\n draw.filltriangle(4*s, 10*s, 24*s, 24*s, 44*s, 10*s, color)\n draw.setlinestyle(1, \"butt\")\nend\n\nfunction drawspeaker(color, bgcolor)\n local x = 23\n local top, bot = -math.pi*.3, math.pi*.3\n for i=0, 2*s do\n draw.arc(x*s, 25*s, 3*s + i, top, bot, color)\n end\n for i=0, 2*s do\n draw.arc(x*s, 25*s, 8*s + i, top, bot, color)\n end\n for i=0, 2*s do\n draw.arc(x*s, 25*s, 13*s + i, top, bot, color)\n end\n -- Remove traces of arc\n for i=1, 5 do\n draw.arc(x*s, 25*s, 2*s, top, bot, bgcolor)\n draw.arc(x*s, 25*s, 7*s, top, bot, bgcolor)\n draw.arc(x*s, 25*s, 12*s, top, bot, bgcolor)\n end\n -- Base\n draw.fillrect(10*s, 20*s, 12*s, 30*s, color)\n draw.filltriangle(13*s, 20*s, 24*s, 12*s, 13*s, 30*s, color)\n draw.filltriangle(24*s, 12*s, 13*s, 30*s, 24*s, 38*s, color)\nend\n\nfunction drawfileicon(drawcolor)\n draw.fillrect(6*s, 0, 32*s, 48*s, drawcolor)\n draw.fillrect(6*s, 10*s, 42*s, 48*s, drawcolor)\n draw.filltriangle(32*s, 0, 42*s, 10*s, 10*s, 10*s, drawcolor)\nend\n\nfunction drawfoldericon(drawcolor)\n draw.fillrect(2*s, 10*s, 46*s, 44*s, drawcolor)\n draw.fillrect(28*s, 4*s, 42*s, 44*s, drawcolor)\n draw.filltriangle(24*s, 10*s, 28*s, 4*s, 28*s, 10*s, drawcolor)\n draw.filltriangle(42*s, 4*s, 42*s, 10*s, 46*s, 10*s, drawcolor)\nend\n\n-- Draw Buttons --\n-- Draw Back Button\ndraw.beginframe()\ndraw.clearscreen()\ndraw.filltriangle(2*s, 12*s, 10*s, 4*s, 10*s, 20*s, drawcolor)\ndraw.fillrect(5*s, 9*s, 22*s, 15*s, drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMBack.png\", 0, 0, 24*s, 24*s)\n\n-- Draw Forward Button\ndraw.beginframe()\ndraw.clearscreen()\ndraw.transformedimage(\"@resources\/LAMBack.png\", 12*s, 12*s, 1, math.pi)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMForward.png\", 0, 0, 24*s, 24*s)\n\n-- Draw Refresh Button\n\n\n-- Draw Search Button\ndraw.beginframe()\ndraw.clearscreen()\ndraw.setlinestyle(3*s, \"butt\")\ndraw.circle(22*s, 14*s, 10*s, drawcolor)\ndraw.line(8*s, 32*s, 18*s, 22*s, drawcolor)\ndraw.setlinestyle(1, \"butt\")\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMSearch.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Home Button\ndraw.beginframe()\ndraw.clearscreen()\ndraw.filltriangle(0, 24*s, 24*s, 0, 48*s, 24*s, drawcolor)\ndraw.fillrect(12*s, 4*s, 16*s, 28*s, drawcolor)\ndraw.fillrect(10*s, 20*s, 38*s, 32*s, drawcolor)\ndraw.fillrect(10*s, 20*s, 20*s, 48*s, drawcolor)\ndraw.fillrect(28*s, 20*s, 38*s, 48*s, drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMHome.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Mail Button\ndraw.beginframe()\ndraw.clearscreen()\ndrawmail(drawcolor, drawcolor3)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMMail.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Save Button\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 48*s, 44*s, bluecolor)\ndraw.fillrect(4*s, 0, 48*s, 48*s, bluecolor)\ndraw.filltriangle(0*s, 44*s, 4*s, 44*s, 4*s, 48*s, bluecolor)\ndraw.fillrect(8*s, 28*s, 40*s, 48*s, bluecolor2)\ndraw.fillrect(12*s, 30*s, 20*s, 44*s, bluecolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMSave.png\", 0, 0, 48*s, 48*s)\n-- Draw Delete Button\n\n-- Draw Uninstall Button\n\n-- Draw Clear Button\n\n\n-- Draw Icons --\n-- Draw Draw Library Icon\n\n-- Draw Turtle Library Icon\n\n-- Draw Audio Library Icon\n\n-- Draw Unknown File Icon\ndraw.beginframe()\ndraw.clearscreen()\ndrawfileicon(drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMUnknownFile.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Image File Icon\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(4*s, 4*s, 44*s, 44*s, drawcolor2)\ndraw.fillrect(8*s, 8*s, 40*s, 40*s, drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMImageFile.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Sound File Icon\ndraw.beginframe()\ndraw.clearscreen()\ndrawfileicon(drawcolor)\ndrawspeaker(drawcolor2, drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMSoundFile.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Lua Script File Icon\ndraw.setfont(\"Arial\", 8*s)\ndraw.beginframe()\ndraw.clearscreen()\ndrawfileicon(drawcolor)\ndraw.stringinrect(\"print('Hello World!')\", 8*s, 10*s, 40*s, 48*s, draw.blue)\ndraw.endframe()\ndraw.setfont(\"Arial\", 16)\ndraw.imagesave(\"@resources\/LAMScriptFile.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Folder Icon\ndraw.beginframe()\ndraw.clearscreen()\ndrawfoldericon(drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMFolder.png\", 0, 0, 48*s, 48*s)\n\n-- Draw LAM Folder Icon\ndraw.beginframe()\ndraw.clearscreen()\ndrawfoldericon(drawcolor)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMInstallFold.png\", 0, 0, 48*s, 48*s)\n\n-- Draw Inbox Folder Icon\ndraw.beginframe()\ndraw.clearscreen()\ndrawfoldericon(drawcolor)\ndrawmail(drawcolor2, drawcolor3)\ndraw.endframe()\ndraw.imagesave(\"@resources\/LAMInboxFold.png\", 0, 0, 48*s, 48*s)\n\nprint(\"Done Regenerating Images.\")","LAMAPI\/luamovieviewer.lua":"print('Lua Movie Viewer!')\nlocal lmv = {}\nlmv.playaudio = false -- Enable this for sound!\nlmv.hvpfps = 24 -- Lua videos play at 24 frames per second.\nlmv.sleeptime = 1\/lmv.hvpfps\nlmv.totalframes = 120\n\n-- Draw Event\nlmv.draw = function(frame)\n draw.clear()\n draw.fillrect(0, 0, ScreenX, frame*2, draw.blue)\n draw.fillrect(0, 0, frame, frame, draw.red)\n draw.fillrect(math.random()*ScreenX, 0, math.random()*ScreenY, 96, draw.green)\n draw.string(\"Will Show Controls Later.\", 128, 128, draw.black)\nend\n\n-- Audio Event\nlmv.audio = function(frame) end\n\n-- Sets if LMV autocloses.\nfunction lmv.autoClose(value)\n lmv.autoclose = value\nend\n\n-- Viewer Function\nfunction lmv.basicviewer(drawfunc, audiofunc)\n draw.setscreen(1)\n ScreenX, ScreenY = draw.getport()\n local moviestart = sys.gettime()\n local movielength = lmv.totalframes\n local frame = 0\n local play = true\n local framestart, frameend = 0, 0\n while true do -- Loop Endlessly\n if play then\n frame = frame + 1\n if frame > lmv.totalframes and lmv.autoclose then\n return\n elseif frame > lmv.totalframes then\n play = false\n end\n if lmv.playaudio then -- Don't error if the user doesn't have the audio library.\n lmv.audio(frame)\n end\n end\n framestart = sys.gettime()\n draw.beginframe()\n lmv.draw(frame)\n -- Draw Player Controls\n draw.fillrect(0, 0, ScreenX, 48, draw.black)\n draw.fillroundedrect(64, 16, ScreenX - 64, 32, 8, draw.white)\n draw.fillcircle(64 + (frame\/lmv.totalframes)*(ScreenX - 128), 24, 16, draw.blue)\n draw.string(frame\/lmv.hvpfps, 16, 16, draw.white)\n draw.endframe()\n frameend = sys.gettime()\n sys.sleep((lmv.sleeptime - (frameend - framestart))*1000)\n end\nend\n\nlmv.basicviewer(drawfunc, audiofunc)\n\nreturn lmv","Applications\/FileBrowser\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nFile Browser\nFile Browser\nBrowse Files, view images, and play music.\nVersion 1.0\nLua Application Manager\nviewer\nicon.png","Applications\/BlockGame\/main.lua":"-- This game requires the draw library.\n-- Initalize variables.\nversion = \"Indev 0.2\"\nterrain = {}\nskylight = {}\nlightsources = {}\nposx, posy = 0, -64*128*1024\nblocksize = 64\nchunkloading = 2\nautosavetime = 60\nautosaveselected = 2\nautosave = {[0] = 0, [1] = 10, [2] = 60, [3] = 300, [4] = 900, [5] = 1800, [6] = 3600}\nsavingenabled = true\nsavedisabledbygame = true\nsavetofolder = \"New World\"\nbuildmode = true\nmaxjump = 12\ncurjump = 0\nlocal fps = 30\n\n-- Set the approot location so we can correctly acess the saved data location.\napproot = approot or \"\"\n\n-- Set the function used to get real-world time.\ngettime = os.clock\n\n-- Require the enhanced lfs library.\nlfs = require \"lfsplus\"\n\n-- Switch to graphics screen.\ndraw.setscreen(1)\ndraw.settitle(\"Block Game Test\")\nscrx, scry = draw.getport()\n\n-- Automaticly create the required resources for running the game.\nif not lfs.isDirectory(approot..\"SavedData\") then\n lfs.mkdir(approot..\"SavedData\")\n lfs.mkdir( approot .. \"SavedData\/\"..savetofolder)\n require \"blocktextures\"\nend\n\n-- Set some variables used when generating terrain.\nterrainflat = false\nmaxheight = 128*2048\nwaterheight = 64*2048\nseed = math.random()*(2^52)\nmath.randomseed(seed)\n\ngametime = 0\nplayerhealth = 20\nplayermaxhealth = 20\ninventory = {{2, 0, 100}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}\nwhile #inventory < 40 do\n inventory[#inventory + 1] = {0,0,0}\nend\nselected = 1\n\n-- Load Settings file from disk\nlocal file = io.open(approot..\"SavedData\/Settings.txt\")\nif file then\n savingenabled = file:read() == \"true\"\n chunkloading = tonumber(file:read())\n autosaveselected = tonumber(file:read())\n autosavetime = autosave[autosaveselected]\n buildmode = file:read() == \"true\"\n file:close()\nend\n\n-- Create local variables to increase speed.\nlocal math = math\nlocal draw = draw\nlocal transformedimage = draw.transformedimage\nlocal pairs, ipairs = pairs, ipairs\n\n-- This function is used to draw a loading screen.\nfunction drawloadingscreen()\n draw.beginframe()\n draw.clear(draw.black)\n draw.transformedimage(\"@resources\/BlockSaving.png\", scrx*.5, scry*.5, 3, gettime()*math.pi)\n draw.endframe()\nend\n\n-- Draw a loading screen while the player is forced to wait.\ndrawloadingscreen()\ndraw.cacheimage(\"@resources\/BlockSaving.png\")\n\n-- Require other modules used in the game.\nrequire \"drawblocks\"\nrequire \"drawmain\"\nrequire \"menus\"\nrequire \"blockmenus\"\nrequire \"saveload\"\nrequire \"computer\"\nrequire \"blockdata\"\nJSON = require \"JSON\"\nkeyboard = require \"keyboard\"\n\nlocal drawblock = drawblock\nlocal handleblock = handleblock\n\n-- This function checks if the time the player set before autosaving has expired, then when it expires it will automaticly autosave.\nfunction handleautosave()\n if autosavetime > 0 then\n if not timetonextautosave then\n timetonextautosave = gettime() + autosavetime\n end\n if savingenabled then\n if gettime() > timetonextautosave then\n -- Automaticly save the world.\n print(\"Autosaving World...\")\n saveworld()\n -- Set the time to next autosave.\n timetonextautosave = gettime() + autosavetime\n end\n end\n end\nend\n\n-- This function automaticly ilterates over all of the blocks in the region.\nfunction handlechunk(x, y)\n local chunk = terrain[y][x]\n for y2, v in ipairs(chunk) do\n for x2, v2 in ipairs(v) do\n if handleblock[v2[1]] then\n handleblock[v2[1]](v2,chunk,x,y, x2,y2)\n end\n end\n end\nend\n\nfunction pickupitem(id, damage, amount)\n local itemsleft = amount\n for k, v in ipairs(inventory) do\n if v[1] == id and v[3] < 100 then\n local itemstaken = math.min(itemsleft, 100 - v[3])\n itemsleft = itemsleft - itemstaken\n v[3] = v[3] + itemstaken\n elseif v[1] < 1 then\n v[1] = id or 0\n v[2] = damage or 0\n local itemstaken = math.min(itemsleft, 100 - v[3])\n itemsleft = itemsleft - itemstaken\n v[3] = v[3] + itemstaken\n end\n if itemsleft <= 0 then\n return true\n end\n end\n return itemsleft\nend\n\n-- This function is used to handle gameplay.\nfunction handlegame()\n local ccx, ccy = math.floor(posx\/16\/blocksize), math.floor(posy\/16\/blocksize)\n -- Handle terrain chunk streaming.\n -- Remember, the y comes first before x!\n for y = ccy - (chunkloading + 2), ccy + chunkloading + 2 do\n if y > ccy - chunkloading and y < ccy + chunkloading then\n if not terrain[y] then\n terrain[y] = {}\n end\n for x = ccx - (chunkloading + 2), ccx + chunkloading + 2 do\n if x > ccx - chunkloading and x < ccx + chunkloading then\n if not terrain[y][x] then\n loadterrain(x, y)\n else\n handlechunk(x, y)\n end\n else\n if terrain[y][x] then\n saveterrain(x, y)\n terrain[y][x] = nil\n skylight[x] = nil\n end\n end\n end\n elseif terrain[y] then\n for x = ccx - (chunkloading + 2), ccx + chunkloading + 2 do\n saveterrain(x, y)\n terrain[y][x] = nil\n end\n end\n end\n -- Handle block placement.\n if btx then -- If the player held a block.\n local chunk = terrain[math.floor(bty\/16)][math.floor(btx\/16)]\n if chunk then\n local blx, bly = (btx - math.floor(btx\/16)*16) + 1, (bty - math.floor(bty\/16)*16) + 1\n -- Attempt to place a block.\n if buildmode then\n if inventory[selected][1] > 0 then\n if chunk[bly][blx][1] ~= inventory[selected][1] then\n chunk[bly][blx] = {inventory[selected][1]}\n regenlighting( math.floor ( btx \/ 16), math.floor(bty\/16))\n end\n end\n else -- If in survival mode\n if chunk[bly][blx][1] == 1 then\n -- Place the block\n if inventory[selected][3] > 0 then\n if not toolmaterial[inventory[selected][1]] then\n chunk[bly][blx] = {inventory[selected][1]}\n inventory[selected][3] = inventory[selected][3] - 1\n if inventory[selected][3] < 1 then\n inventory[selected] = {0, 0, 0}\n end\n end\n end\n else -- Break the block\n if cbrx == btx and cbry == bty then\n framesheld = framesheld + 1\n if framestodestroy > -1 and framesheld > framestodestroy then\n pickupitem(chunk[bly][blx][1], chunk[bly][blx][2], 1)\n framesheld = 0\n chunk[bly][blx] = {1}\n if toolmaterial[inventory[selected][1]] then\n inventory[selected][2] = inventory[selected][2] + 1\n if itemdamagelimit[inventory[selected][1]] < inventory[selected][2] then\n inventory[selected][3] = inventory[selected][3] - 1\n inventory[selected][2] = 0\n if inventory[selected][2] <= 0 then\n inventory[selected][1] = 0\n end\n end\n end\n end\n else\n cbrx, cbry = btx, bty\n if blockmaterial[chunk[bly][blx][1]] then\n framestodestroy = timetodestroy(chunk[bly][blx][1], inventory[selected][1])\n else\n framestodestroy = -1\n end\n framesheld = 0\n end\n end\n end\n end\n end\n -- Handle tapping a block.\n if bex then\n local chunk = terrain[math.floor(bey\/16)][math.floor(bex\/16)]\n if chunk then\n local blx, bly = (bex - math.floor(bex\/16)*16) + 1, (bey - math.floor(bey\/16)*16) + 1\n if chunk[bly][blx] then\n -- Use a block\n if chunk[bly][blx][1] == 27 then\n -- Show crafting menu\n craftingmenu()\n elseif chunk[bly][blx][1] == 28 or chunk[bly][blx][1] == 54 then\n -- Show furnance menu\n furnancemenu(bex, bey)\n elseif chunk[bly][blx][1] == 45 then\n\n elseif chunk[bly][blx][1] == 51 or chunk[bly][blx][1] == 52 or chunk[bly][blx][1] == 53 then\n batteryboxmenu(bex, bey)\n elseif chunk[bly][blx][1] == 58 then\n chestmenu(bex, bey)\n end\n end\n end\n bex, bey = nil, nil\n end\n handleautosave()\n --collectgarbage() -- Collect extra memory.\nend\n\n-- If an attempt to load a chunk fails, then this function is called to generate it using the seed and other settings.\nfunction generateterrain(x, y)\n local dx, dy = x*16, y*16\n math.randomseed(seed + dx)\n -- Ensure that there will a table to store this chunk into.\n if not terrain[y] then\n terrain[y] = {}\n end\n -- Generate terrain height.\n local genheight = {}\n local gen = {}\n local trees = {}\n math.randomseed(seed + dx + 1 - 16)\n local terrainleft = math.max( math.random( maxheight - 24), 0) + 24\n math.randomseed(seed + dx + 1 + 16)\n local terrainright = math.max( math.random( maxheight - 24), 0) + 24\n for i=1, 16 do\n math.randomseed(seed + dx + 1)\n if terrainflat then\n genheight = maxheight\n else\n genheight = math.max(math.random(maxheight - 24), 0) + 24\n end\n end\n -- Blend the terrain to the left chunk.\n if not terrainflat then\n local blendterrain = 16\n local bt = blendterrain\n for i=1, bt do\n genheight = genheight - ((genheight - terrainleft)*((bt - i)\/bt))\n end\n end\n -- This does nothing.\n if os.date(\"%d.%m\") == \"01.04\" or os.date(\"%d.%m\") == \"1.04\" then\n seed = math.random()*2^52\n end\n --[[Build hills on the terrain.\n if not terrainflat then\n for i=2, 16 do\n math.randomseed(seed + dx + i)\n genheight = (genheight + ((math.random()*2) - 1))\n if genheight - math.floor(genheight) >= .5 then\n genheight = math.ceil(genheight)\n else\n genheight = math.floor(genheight)\n end\n end\n end\n -- Blend the terrain again.\n for i=1, bt do\n genheight = genheight - ((genheight - terrainleft)*((bt - i)\/bt))\n end]]\n -- Generate Lighting\n if not skylight[x] then\n skylight[x] = {}\n for i=1, 16 do\n skylight[x] = -genheight\n end\n end\n -- Create the table used to add the correct block used to fill the terrain for each column.\n for i=1, 16 do\n gen = {[\"grass\"] = genheight}\n gen[\"dirt\"] = genheight - 3\n --print(i + dx, genheight)\n end\n math.randomseed(seed + dx)\n -- Generate Trees\n for i=1, math.random(2, 4) do\n local treex = math.random(1, 16)\n local treey = genheight[treex] + 1\n math.randomseed(seed + dx + treex)\n local treeheight = math.random(4, 6)\n trees[treex] = {treex, treey, treeheight}\n end\n -- Add blocks to terrain\n terrain[y][x] = {}\n local chunk = terrain[y][x]\n for y2 = 1, 16 do\n chunk[y2] = {}\n if y2 + dy > 0 then\n for x2 = 1, 16 do\n chunk[y2][x2] = {}\n chunk[y2][x2][1] = 2\n end\n else\n for x2 = 1, 16 do\n chunk[y2][x2] = {}\n if math.abs(y2 + dy) > gen[x2][\"grass\"] then -- Place water, a tree, or air\n if math.abs(y2 + dy) <= waterheight then\n chunk[y2][x2][1] = 8\n else\n if trees[x2] then\n if -(trees[x2][2] + trees[x2][3]) < y2 + dy then\n chunk[y2][x2][1] = 6\n elseif -(trees[x2][2] + trees[x2][3]) - 2 < y2 + dy then\n chunk[y2][x2][1] = 7\n else\n chunk[y2][x2][1] = 1\n end\n elseif trees[x2 + 1] then\n if -(trees[x2 + 1][2] + trees[x2 + 1][3]) - 1 < y2 + dy and -(trees[x2 + 1][2] + trees[x2 + 1][3]) + 1 > y2 + dy then\n chunk[y2][x2][1] = 7\n else\n chunk[y2][x2][1] = 1\n end\n elseif trees[x2 - 1] then\n if -(trees[x2 - 1][2] + trees[x2 - 1][3]) - 1 < y2 + dy and -(trees[x2 - 1][2] + trees[x2 - 1][3]) + 1 > y2 + dy then\n chunk[y2][x2][1] = 7\n else\n chunk[y2][x2][1] = 1\n end\n else\n chunk[y2][x2][1] = 1\n end\n end\n elseif math.abs(y2 + dy) > gen[x2][\"grass\"] - 1 then -- Place grass\n chunk[y2][x2][1] = 5\n elseif math.abs(y2 + dy) >= gen[x2][\"dirt\"] then -- Place dirt\n chunk[y2][x2][1] = 4\n else -- Place stone\n math.randomseed(seed + dx + x2*y2)\n if math.random() > .98 then -- Place Sapphire Ore\n chunk[y2][x2][1] = 12\n elseif math.random() > .87 then -- Place Iron Ore\n chunk[y2][x2][1] = 11\n elseif math.random() > .86 then -- Place Coal Ore\n chunk[y2][x2][1] = 10\n else -- Place Stone Block\n chunk[y2][x2][1] = 2\n end\n end\n end\n end\n end\n regenlighting(x, y)\nend\n\n\n-- Game touch events.\nfunction gametouchbegin(x, y)\n\nend\n\n\n-- Game touch events.\nfunction gametouchbegin(x, y)\n\nend\n\nfunction gametouch(x, y)\n local posxl, posyl = posx - scrx*.5, posy - scry*.5\n if buildmode then\n if x > scrx - 48 and math.abs(posx) < 2^48 then\n posx = posx + 4\n elseif x > scrx - 48 then\n posx = posx + 64 --(8*math.abs(posx)\/(2^48))\n elseif x < 48 and math.abs(posx) < 2^48 then\n posx = posx - 4\n elseif x < 48 then\n posx = posx - 64 --(8*math.abs(posx)\/(2^48))\n end\n else\n --local posx, posy = posx - scrx*.5, posy - scry*.5\n local camx, camy = math.floor(posxl\/blocksize), math.floor(posyl\/blocksize)\n local chunk = terrain[math.floor(camy\/16)][math.floor(camx\/16)]\n if x > scrx - 48 then\n if camx - math.floor(camx\/16)*16 < 14 then\n if chunk[camy - math.floor(camy\/16)*16][math.floor(camx - math.floor(camx\/16)*16 + 2)][1] == 1 then\n posx = posx + 4\n end\n else\n posx = posx + 4\n end\n elseif x < 48 then\n if camx - math.floor(camx\/16)*16 > 3 then\n if chunk[camy - math.floor(camy\/16)*16][camx - math.floor(camx\/16)*16][1] == 1 then\n posx = posx - 4\n end\n else\n posx = posx - 4\n end\n end\n end\n if buildmode then\n if y > scry - 48 then\n posy = posy + 8\n elseif y < 48 then\n posy = posy - 8\n end\n else\n if y < 48 then\n if curjump <= 0 then\n curjump = curjump + 1\n end\n end\n end\n if y < scry - 96 and y > 48 and x > 48 and x < scrx - 48 then\n btx, bty = math.floor((x + posxl)\/blocksize), math.floor((y + posyl)\/blocksize)\n else\n btx, bty = nil\n end\nend\n\nfunction gametouchend(x, y)\n local xcenter = 48*8 + 8\n local xstart = (scrx - xcenter)*.5 + 4\n if y > scry - 80 and y < scry - 32 then\n if x > xstart and x < xstart + 48*7 then\n selected = math.max(math.min(math.floor((x - xstart)\/48) + 1, 7), 1)\n elseif x >= xstart + 48*7 and x < xstart + 48*8 then\n inventorymenu()\n end\n end\n btx, bty = nil\n local posxl, posyl = posx - scrx*.5, posy - scry*.5\n bex, bey = math.floor((x + posxl)\/blocksize), math.floor((y + posyl)\/blocksize)\nend\n\n-- This function is used to start gameplay.\nfunction playgame()\n posx, posy = startx, starty\n handlegame()\n draw.tracktouches(gametouchend, gametouch, gametouchend)\n draw.disablerefresh()\n -- Game Loop.\n while true do\n savedisabledbygame = false\n draw.tracktouches(gametouchend, gametouch, gametouchend)\n draw.doevents()\n beginframe = gettime()\n handlegame()\n draw.beginframe()\n drawbackground()\n drawterrain()\n if btx then\n local posxl, posyl = posx - scrx*.5, posy - scry*.5\n if buildmode then\n draw.fillbox((btx*blocksize) - posxl, (bty*blocksize) - posyl, blocksize, blocksize, {0,0,.24,.23})\n else\n draw.fillbox((btx*blocksize) - posxl, (bty*blocksize) - posyl, blocksize, blocksize, {0,0,.24,1*(framesheld\/framestodestroy)})\n end\n end\n drawinventory()\n -- Show debug text.\n draw.string(\"RAM Used: \"..math.ceil(collectgarbage(\"count\"))..\" kilobytes\", 0, 24, draw.white)\n draw.string(\"X: \"..posx..\" Y: \"..posy, 0, 48, draw.white)\n draw.string(\"Chunk X: \"..math.floor(posx\/16\/blocksize)..\" Y: \"..math.floor(posy\/16\/blocksize), 0, 64, draw.white)\n draw.string(version, 0, 96, draw.white)\n endframe = gettime()\n draw.string(\"FPS: \"..math.floor((1) \/ (endframe - beginframe)), 224, 24, draw.white)\n draw.endframe()\n if exitgame then\n saveworld()\n worldlistloaded = false\n loadworldlistco = coroutine.create(updateworldlist)\n coroutine.resume(loadworldlistco)\n return\n end\n sys.sleep(((1\/fps) - (endframe - beginframe))*1000)\n end\nend\n\n-- The Game Is Ready. Send the player to the main menu.\nerr, msg = pcall(mainmenu)\nif not err then\n print(msg)\n draw.beginframe()\n draw.fillrect(24, 24, scrx - 24, scry - 24, draw.white)\n draw.stringinrect(msg, 24, 24, scrx - 24, scry - 24, draw.black)\n draw.endframe()\n sys.sleep(math.huge)\nend","Applications\/BlockGame\/computerkeyboard.lua":"local ckey = {}\n\nfunction ckey.makeTappedSound()\n sys.alert(\"tock\")\nend\n\nfunction ckey.drawkey(str, x, y, xs, ys, color)\n draw.fillroundedrect(x, y, x + xs, y + ys, 6, color or draw.white)\n local stszx, stszy = draw.stringsize(str)\n draw.string(str, x + (xs - stszx)*.5, y + (ys - stszy)*.5, draw.black)\nend\n\nckey.x, ckey.y = 0, 0\nckey.xs, ckey.ys = 480, 160\nckey.slidetime = .4\nckey.curtext = \"\"\nckey.curpos = 0\nckey.mode = 0\nckey.row1 = {\"q\", \"w\", \"e\", \"r\", \"t\", \"y\", \"u\", \"i\", \"o\", \"p\"}\nckey.row2 = {\"a\", \"s\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\"}\nckey.row3 = {\"z\", \"x\", \"c\", \"v\", \"b\", \"n\", \"m\"}\nckey.nrow1 = {\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\"}\nckey.nrow2 = {\"-\", \"\/\", \":\", \";\", \"(\", \")\", \"$\", \"&\", \"@\", '\"'}\nckey.nrow3 = {\".\", \",\", \"?\", \"!\", \"'\"}\nckey.nrow4 = {\"[\", \"]\", \"{\", \"}\", \"#\", \"%\", \"^\", \"*\", \"+\", \"=\"}\nckey.nrow5 = {\"_\", \"\\\\ \", \"|\", \"~\", \"<\", \">\", \"€\", \"£\", \"¥\", \"•\"}\n\nfunction ckey.getRows()\n local row1, row2, row3 = ckey.row1, ckey.row2, ckey.row3\n if ckey.mode == 1 then\n row1 = ckey.nrow1\n row2 = ckey.nrow2\n row3 = ckey.nrow3\n elseif ckey.mode == 2 then\n row1 = ckey.nrow4\n row2 = ckey.nrow5\n row3 = ckey.nrow3\n end\n return row1, row2, row3\nend\n\nlocal ipairs = ipairs\n\nfunction ckey.drawKeyboard(x, y, xs, ys)\n x, y = x or ckey.x, y or ckey.y\n xs, ys = xs or ckey.xs, ys or ckey.ys\n draw.fillrect(x, y, x + xs, y + ys, draw.lightgray)\n local row1, row2, row3 = ckey.getRows()\n local r2s = ((#row1 - #row2)\/#row1)*(xs - 8)*.5\n local r3s = ((#row1 - #row3)\/#row1)*(xs - 8)*.5\n local wid = (1\/#row1)*xs - 6\n -- Draw Keys\n for k, v in ipairs(row1) do\n ckey.drawkey(v, 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4, wid, ys*.25 - 8)\n end\n for k, v in ipairs(row2) do\n ckey.drawkey(v, r2s + 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4 + (ys*.25), wid, ys*.25 - 8)\n end\n for k, v in ipairs(row3) do\n ckey.drawkey(v, r3s + 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4 + (ys*.5), wid, ys*.25 - 8)\n end\n ckey.drawkey(\"Shift\", 6 + x, y + 4 + (ys*.5), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n -- Draw Command Keys\n ckey.drawkey(\"Backs\", 6 + x + (xs - 6 - r3s), y + 4 + (ys*.5), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n ckey.drawkey(\"123\", 6 + x, y + 4 + (ys*.75), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n ckey.drawkey(\"•\", r3s + 6 + x + ((0)\/#ckey.row1)*(xs - 6), y + 4 + (ys*.75), (1\/#ckey.row1)*xs - 6, ys*.25 - 8)\n -- Draw global keys\n ckey.drawkey(\"Go\", 6 + x + (xs - 6 - r3s), y + 4 + (ys*.75), r3s - 6, ys*.25 - 8, draw.blue, draw.white)\n ckey.drawkey(\"space\", r3s + 6 + x + ((1)\/#ckey.row1)*(xs - 6), y + 4 + (ys*.75), (5\/#ckey.row1)*xs - 6, ys*.25 - 8)\nend\n\nfunction ckey.tappedKey(tx, ty)\n local xs, ys = ckey.xs, ckey.ys\n local row1, row2, row3 = ckey.getRows()\n local r2s = ((#row1 - #row2)\/#row1)*(xs - 8)*.5\n local r3s = ((#row1 - #row3)\/#row1)*(xs - 8)*.5\n local keytapped, keytappedvalue, rowtapped\n if ty > ckey.y and ty < ckey.y + ys*.25 then\n keytapped = math.floor(tx\/((1\/#row1)*(xs + 6))) + 1\n keytappedvalue = row1[keytapped]\n rowtapped = 1\n elseif ty > ckey.y + ys*.25 and ty < ckey.y + ys*.5 then\n keytapped = math.floor(((tx - r2s + 6)\/((1\/#row2)*xs)) + .5) + 1\n keytappedvalue = row2[keytapped]\n rowtapped = 2\n elseif ty > ckey.y + ys*.5 and ty < ckey.y + ys*.75 then\n keytapped = math.floor(tx\/((1\/#row1)*(xs + 6)))\n keytappedvalue = row3[keytapped]\n rowtapped = 3\n elseif ty > ckey.y + ys*.75 and ty < ckey.y + ys then\n keytapped = math.floor((tx - r3s)\/((1\/#row3)*(xs - 6))) + 1\n rowtapped = 4\n end\n ckey.keytapped, ckey.keytappedvalue, ckey.rowtapped = keytapped, keytappedvalue, rowtapped\nend\n\nfunction ckey.begintouch(x, y)\n ckey.tappedKey(x, y)\nend\n\nfunction ckey.touch(x, y)\n ckey.tappedKey(x, y)\nend\n\nfunction ckey.endtouch(x, y)\n ckey.tappedKey(x, y)\n local row1, row2, row3 = ckey.getRows()\n if ckey.keytapped then\n if ckey.rowtapped == 3 then\n if ckey.mode == 0 and ckey.keytapped <= 0 then\n ckey.shift = not shift\n elseif ckey.keytapped > #row3 then\n ckey.curtext = string.sub(ckey.curtext, 0, #ckey.curtext - 1)\n elseif ckey.keytappedvalue then\n ckey.curtext = ckey.curtext .. ckey.keytappedvalue\n ckey.makeTappedSound()\n end\n elseif ckey.rowtapped == 4 then\n if ckey.keytapped <= 0 then\n if ckey.mode >= 2 then\n ckey.mode = 0\n else\n ckey.mode = ckey.mode + 1\n end\n elseif ckey.keytapped == 1 then\n ckey.curtext = ckey.curtext .. \"•\"\n ckey.makeTappedSound()\n elseif ckey.keytapped < 6 then\n ckey.curtext = ckey.curtext .. \" \"\n ckey.makeTappedSound()\n end\n elseif ckey.keytappedvalue then\n ckey.curtext = ckey.curtext .. ckey.keytappedvalue\n ckey.makeTappedSound()\n end\n\n end\nend\n\nfunction ckey.keyboard()\n draw.tracktouches(ckey.begintouch, ckey.touch, ckey.endtouch)\n local scwidth, scheight = draw.getport()\n local begintime = sys.gettime()\n while not ckey.returnNow do\n if sys.gettime() < begintime + ckey.slidetime then\n ckey.y = scheight - (ckey.ys* ((sys.gettime() - begintime)\/ckey.slidetime))\n else\n ckey.y = scheight - ckey.ys\n end\n draw.doevents()\n draw.beginframe()\n draw.clear(draw.black)\n ckey.drawKeyboard()\n draw.string(ckey.curtext, 0, 0, draw.white)\n draw.endframe()\n end\nend\n\ndraw.setscreen(1)\nckey.keyboard()\nsys.sleep(198373737)","Applications\/PaintApp":"nil","Applications\/Help\/Book\/Home.lua":"local page = {}\npage.PageTitle = \"Home Page\"\npage.Text = {\n {\"The Help feature is not complete yet.\"},\n {\"More pages will be added as time goes on.\"},\n {\"Thank you for using Lua Application Manager.\"}\n}\npage.Pictures = {}\n\n\nreturn page","Applications\/BlockGame\/SavedData\/Settings.txt":"false\n2\n1\ntrue","Applications\/CubotsMarch!\/ResourceGenerator.lua":"-- Set Up Graphics Screen\ndraw.setscreen(1)\ndraw.setclearcolor(draw.magenta)\ndraw.setantialias(false)\ndraw.settitle(\"Generating Images\")\napproot = approot or \"\"\nrequire \"lfs\"\nlfs.mkdir(\"resources\")\n\n-- Setting Colors\nlocal blue1 = {0, 0, .7, 1}\nlocal blue2 = {.5, .5, .7, 1}\nlocal blue3 = {.1, .6, 1, 1}\nlocal yellow1 = {1, .5, 0, 1}\nlocal yellow2 = {1, .75, .5, 1}\nlocal pink1 = {1, 0, 1, 1}\nlocal pink2 = {1, .5, 1, 1}\nlocal red1 = {1, 0, 0, 1}\nlocal red2 = {1, .5, .5, 1}\nlocal green1 = {0, .8, 0, 1}\nlocal green2 = {.5, .8, .5, 1}\n\nfunction drawBlock(size, size2, color1, color2, color3)\n local size1 = size - size2\n draw.fillrect(0, 0, size1, size1, color3)\n draw.fillrect(0, 0, size2, size1, color2)\n draw.filltriangle(0, 0, size2, 0, size2, size2, color3)\n draw.filltriangle(size1, size2, size1, 0, size, size2, color3)\n draw.filltriangle(0, size1, size2, size1, size2, size, color2)\n draw.fillrect(size, size2, size2, size, color1)\nend\n\n-- Generate Blue Block\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(20, 6, blue1, blue2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/BlueBlock.png\", 0, 0, 20, 20)\n\n-- Generate Yellow Block\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(20, 6, yellow1, yellow2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/YellowBlock.png\", 0, 0, 20, 20)\n\n-- Generate Red Block\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(20, 6, red1, red2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/RedBlock.png\", 0, 0, 20, 20)\n\n-- Generate Green Block\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(20, 6, green1, green2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/GreenBlock.png\", 0, 0, 20, 20)\n\n-- Generate Pink PlayBlock\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(56, 56 - 32, pink1, pink2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/PinkBlockLarge.png\", 0, 0, 56, 56)\n\n-- Generate Green PlayBlock\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(56, 56 - 32, green1, green2, draw.white)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/GreenBlockLarge.png\", 0, 0, 56, 56)\n\n-- Generate Blue Door PlayBlock\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 36, 8, draw.blue)\ndraw.fillrect(0, 0, 8, 36, draw.blue)\ndraw.fillrect(28, 0, 36, 36, draw.blue)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/Door.png\", 0, 0, 36, 36)\n\n-- Generate Orange Door PlayBlock\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 32, 6, yellow1)\ndraw.fillrect(0, 0, 6, 32, yellow1)\ndraw.fillrect(26, 0, 32, 32, yellow1)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/OrangeDoor.png\", 0, 0, 36, 36)\n\n-- Generate Code Block\ndraw.beginframe()\ndraw.clearscreen()\ndrawBlock(36, 4, draw.darkgray, draw.lightgray, draw.white)\ndraw.fillrect(8, 8, 32, 32, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/CodeBlock.png\", 0, 0, 36, 36)\n\n-- Generate Move Left Command\ndraw.setantialias(true)\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, draw.green)\ndraw.filltriangle(2, 12, 10, 4, 10, 20, draw.black)\ndraw.fillrect(5, 9, 22, 15, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/MoveLeft.png\", 0, 0, 24, 24)\n\n-- Generate Move Forward Command\ndraw.beginframe()\ndraw.clearscreen()\ndraw.transformedimage(approot..\"resources\/MoveLeft.png\", 12, 12, 1, math.pi\/2)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/MoveForward.png\", 0, 0, 24, 24)\n\n-- Generate Move Right Command\ndraw.beginframe()\ndraw.clearscreen()\ndraw.transformedimage(approot..\"resources\/MoveLeft.png\", 12, 12, 1, math.pi)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/MoveRight.png\", 0, 0, 24, 24)\n\n-- Generate Turn Around Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, draw.green)\ndraw.transformedimage(approot..\"resources\/MoveLeft.png\", 6, 12, .5, 0)\ndraw.transformedimage(approot..\"resources\/MoveRight.png\", 18, 12, .5, 0)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/TurnAround.png\", 0, 0, 24, 24)\n\n-- Generate Push Pull Arrow\ndraw.setantialias(true)\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, blue3)\ndraw.filltriangle(2, 12, 10, 4, 10, 20, draw.black)\ndraw.fillrect(5, 9, 22, 15, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/PushPull.png\", 0, 0, 24, 24)\n\n-- Generate Push Block Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, blue3)\ndraw.transformedimage(approot..\"resources\/PushPull.png\", 6, 12, .5, math.pi)\ndraw.fillrect(12, 6, 24, 18, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/PushBlock.png\", 0, 0, 24, 24)\n\n-- Generate Pull Block Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, blue3)\ndraw.transformedimage(approot..\"resources\/PushPull.png\", 6, 12, .5, 0)\ndraw.fillrect(12, 6, 24, 18, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/PullBlock.png\", 0, 0, 24, 24)\n\n-- Generate Jump Over Block Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, blue3)\ndraw.transformedimage(approot..\"resources\/PushPull.png\", 12, 6, .5, math.pi)\ndraw.fillrect(12, 12, 24, 24, draw.black)\ndraw.fillrect(4.5, 4.5, 7.5, 18, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/JumpOverBlock.png\", 0, 0, 24, 24)\n\n-- Generate Call Function 1 Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, draw.yellow)\n-- Draw letter F\ndraw.fillrect(2.5, 4.5, 4.5, 19.5, draw.black)\ndraw.fillrect(2.5, 4.5, 11.5, 6.5, draw.black)\ndraw.fillrect(2.5, 11.5, 7.5, 13.5, draw.black)\n-- Draw Number 1\ndraw.fillrect(14.5, 4.5, 19.5, 7.5, draw.black)\ndraw.fillrect(17.5, 4.5, 19.5, 19.5, draw.black)\ndraw.fillrect(14.5, 17.5, 21.5, 19.5, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/Function1.png\", 0, 0, 24, 24)\n\n-- Generate Call Function 1 Command\ndraw.beginframe()\ndraw.clearscreen()\n--draw.fillrect(0, 0, 24, 24, draw.yellow)\n-- Draw letter F\ndraw.fillrect(2.5, 4.5, 4.5, 19.5, draw.black)\ndraw.fillrect(2.5, 4.5, 11.5, 6.5, draw.black)\ndraw.fillrect(2.5, 11.5, 7.5, 13.5, draw.black)\n-- Draw Number 2\ndraw.fillrect(14.5, 4.5, 21.5, 7.5, draw.black)\ndraw.fillrect(19.5, 4.5, 21.5, 11.5, draw.black)\ndraw.fillrect(14.5, 11.5, 21.5, 13.5, draw.black)\ndraw.fillrect(14.5, 13.5, 16.5, 19.5, draw.black)\ndraw.fillrect(14.5, 17.5, 21.5, 19.5, draw.black)\ndraw.endframe()\ndraw.imagesave(approot..\"resources\/Function2.png\", 0, 0, 24, 24)\n\n-- Generate Cubot 1 Front\n","Applications":"nil","Applications\/Help":"nil","Applications\/BlockGame\/blockmenus.lua":"if not terrain then require \"main\" end\n\n-- Touch event functions for chestmenu.\nfunction cbegintouch(x, y)\n local selectkey = tappedinventorybutton(invscroll, 0, 0, scrx*.5 - 48, scry, x, y)\n if selectkey then\n movingicon = selectkey\n movex, movey = x, y\n else\n selectkey = tappedinventorybutton(invscroll, scrx*.5, 0, scrx - 48, scry, x, y)\n if selectkey then\n movingicon = {selectkey}\n movex, movey = x, y\n end\n end\n oldy = y\nend\n\nfunction ctouch(x, y)\n if movingicon then\n movex, movey = x, y\n elseif oldy then\n invscroll = invscroll + (y - oldy)\n oldy = y\n end\nend\n\nfunction cendtouch(x, y)\n if x > scrx - 128 and y > scry - 48 then\n returntogame = true\n end\n if movingicon then\n replaceobject = tappedinventorybutton(invscroll, 0, 0, scrx*.5 - 48, scry, x, y)\n if not replaceobject then\n replaceobject = {tappedinventorybutton(invscroll, scrx*.5, 0, scrx - 48, scry, x, y) or 1}\n end\n end\n movex, movey = nil, nil\n oldy = nil\nend\n\nfunction chestmenu(blockx, blocky)\n local chunk = terrain[math.floor(blocky\/16)][math.floor(blockx\/16)]\n local block = chunk[blocky - (math.floor(blocky\/16)*16) + 1][blockx - (math.floor(blockx\/16)*16) + 1]\n if block[1] ~= 58 then\n error(\"block at y:\"..blocky..\" x:\"..blockx..\" is not a valid chest. (blockID is \"..block[1]..\")\", 2)\n end\n if not block[KeyChest] then\n block[KeyMetadata] = true\n block[KeyChest] = {}\n for k=1, 40 do\n block[KeyChest][k] = {0, 0, 0}\n end\n end\n invscroll = 0\n while true do\n draw.tracktouches(cbegintouch, ctouch, cendtouch)\n draw.doevents()\n if replaceobject and movingicon then\n if type(replaceobject) == \"table\" then\n if type(movingicon) == \"table\" then\n local blockitem = block[KeyChest][replaceobject[1]]\n block[KeyChest][replaceobject[1]] = block[KeyChest][movingicon[1]]\n block[KeyChest][movingicon[1]] = blockitem\n movingicon = nil\n replaceobject = nil\n else\n local blockitem = block[KeyChest][replaceobject[1]]\n block[KeyChest][replaceobject[1]] = inventory[movingicon]\n inventory[movingicon] = blockitem\n movingicon = nil\n replaceobject = nil\n end\n elseif type(replaceobject) == \"number\" then\n if type(movingicon) == \"table\" then\n local blockitem = inventory[replaceobject]\n inventory[replaceobject] = block[KeyChest][movingicon[1]]\n block[KeyChest][movingicon[1]] = blockitem\n movingicon = nil\n replaceobject = nil\n else\n local blockitem = inventory[replaceobject]\n inventory[replaceobject] = inventory[movingicon]\n inventory[movingicon] = blockitem\n movingicon = nil\n replaceobject = nil\n end\n end\n end\n -- Draw the frame.\n draw.beginframe()\n draw.clear(draw.black)\n draw.stringinrect(\"Chest at y:\"..blocky..\" x:\"..blockx, 0, 16, scrx, 48, draw.white)\n drawinventoryinbox(invscroll, 0, 0, scrx*.5 - 48, scry)\n drawinventoryinbox(invscroll, scrx*.5, 0, scrx - 48, scry, block[KeyChest])\n if movex then\n if type(movingicon) == \"number\" then\n drawitemslot(inventory[movingicon], movex, movey, true)\n elseif type(movingicon) == \"table\" then\n drawitemslot(block[KeyChest][movingicon[1]], movex, movey, true)\n end\n end\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n draw.endframe()\n -- Check if we need to return to the game.\n if returntogame then\n returntogame = false\n return\n end\n end\nend\n\nfunction batteryboxmenu(blockx, blocky)\n local chunk = terrain[math.floor(blocky\/16)][math.floor(blockx\/16)]\n local block = chunk[blocky - (math.floor(blocky\/16)*16) + 1][blockx - (math.floor(blockx\/16)*16) + 1]\n while true do\n draw.tracktouches(fbegintouch, ftouch, fendtouch)\n draw.doevents()\n if not block[KeyEnergy] then\n block[KeyEnergy] = 0\n end\n -- Draw the frame.\n draw.beginframe()\n draw.clear(draw.black)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n draw.string(\"Energy: \"..block[KeyEnergy], scrx*.5 + 48, 48, draw.white)\n draw.stringinrect(\"BatteryBox at y:\"..blocky..\" x:\"..blockx, 0, 16, scrx, 48, draw.white)\n draw.endframe()\n -- Check if we need to return to the game.\n if returntogame then\n returntogame = false\n return\n end\n end\nend\n\n-- Touch event functions for furnancemenu.\nfunction fbegintouch(x, y)\n local selectkey = tappedinventorybutton(invscroll, 0, 0, scrx*.5, scry, x, y)\n if selectkey then\n movingicon = selectkey\n elseif x > scrx - 128 and x < scrx - 128 + 48 and y > scry*.5 - 48 and y < scry*.5 then\n movingicon = {KeySmeltItem}\n elseif x > scrx - 128 and x < scrx - 128 + 48 and y > scry*.5 + 48 and y < scry*.5 + (48*2) then\n movingicon = {KeyFuelItem}\n elseif x > scrx - 128 and y > scry*.5 and x < scrx - 64 and y < scry*.5 + 64 then\n movingicon = {KeyOutputItem}\n else\n movingicon = nil\n end\n oldy = y\nend\n\nfunction ftouch(x, y)\n if movingicon then\n movex, movey = x, y\n elseif oldy then\n invscroll = invscroll + (y - oldy)\n oldy = y\n end\nend\n\nfunction fendtouch(x, y)\n if x > scrx - 128 and y > scry - 48 then\n returntogame = true\n end\n if movingicon ~= nil then\n local selectkey = tappedinventorybutton(invscroll, 0, 0, scrx*.5, scry, x, y)\n if selectkey ~= nil then\n replaceobject = selectkey\n elseif x > scrx - 128 and x < scrx - 128 + 48 and y > scry*.5 - 48 and y < scry*.5 then\n replaceobject = {KeySmeltItem}\n elseif x > scrx - 128 and x < scrx - 128 + 48 and y > scry*.5 + 48 and y < scry*.5 + (48*2) then\n replaceobject = {KeyFuelItem}\n else\n replaceobject = false\n end\n end\n oldy = nil\n movex, movey = nil, nil\nend\n\nfunction furnancemenu(blockx, blocky)\n local chunk = terrain[math.floor(blocky\/16)][math.floor(blockx\/16)]\n local block = chunk[blocky - (math.floor(blocky\/16)*16) + 1][blockx - (math.floor(blockx\/16)*16) + 1]\n invscroll = 0\n if not block[KeyEnergy] then\n HandleElecFurn(block, chunk, chx, chy, x, y, convtab)\n end\n while true do\n draw.tracktouches(fbegintouch, ftouch, fendtouch)\n draw.doevents()\n if replaceobject and movingicon then\n if type(replaceobject) == \"table\" then\n if type(movingicon) == \"table\" then\n local blockitem = block[replaceobject[1]]\n block[replaceobject[1]] = block[movingicon[1]]\n block[movingicon[1]] = blockitem\n movingicon = nil\n replaceobject = nil\n else\n local blockitem = block[replaceobject[1]]\n block[replaceobject[1]] = inventory[movingicon]\n inventory[movingicon] = blockitem\n movingicon = nil\n replaceobject = nil\n end\n elseif type(replaceobject) == \"number\" then\n if type(movingicon) == \"table\" then\n local blockitem = inventory[replaceobject]\n inventory[replaceobject] = block[movingicon[1]]\n block[movingicon[1]] = blockitem\n movingicon = nil\n replaceobject = nil\n else\n local blockitem = inventory[replaceobject]\n inventory[replaceobject] = inventory[movingicon]\n inventory[movingicon] = blockitem\n movingicon = nil\n replaceobject = nil\n end\n end\n end\n -- Draw the frame.\n draw.beginframe()\n draw.clear(draw.black)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n if block[1] == 28 then -- Furnance\n draw.setclip(scrx - 128, 0, scrx - 128 + ((block[KeyProgress]\/100)*48), scry)\n draw.fillrect(scrx - 128, scry*.5 - 24, scrx, scry*.5 + 24, draw.white)\n draw.clearclip()\n drawitemslot(block[KeySmeltItem], scrx - 128, scry*.5 - 48)\n drawitemslot(block[KeyFuelItem], scrx - 128, scry*.5 + 48)\n drawitemslot(block[KeyOutputItem], scrx - 64, scry*.5)\n else -- Electric Furnance\n draw.setclip(scrx - 128, 0, scrx - 128 + ((block[KeyProgress]\/100)*48), scry)\n draw.fillrect(scrx - 128, scry*.5 - 24, scrx, scry*.5 + 24, draw.white)\n draw.clearclip()\n drawitemslot(block[KeySmeltItem], scrx - 128, scry*.5 - 48)\n drawitemslot(block[KeyFuelItem], scrx - 128, scry*.5 + 48)\n drawitemslot(block[KeyOutputItem], scrx - 64, scry*.5)\n draw.string(\"Energy: \"..block[KeyEnergy], scrx*.5 + 48, 48, draw.white)\n end\n draw.stringinrect(\"Furnance at y:\"..blocky..\" x:\"..blockx, 0, 16, scrx, 48, draw.white)\n drawinventoryside(invscroll)\n if movex then\n if type(movingicon) == \"number\" then\n drawitemslot(inventory[movingicon], movex, movey, true)\n elseif type(movingicon) == \"table\" then\n drawitemslot(block[movingicon[1]], movex, movey, true)\n end\n end\n draw.endframe()\n -- Check if we need to return to the game.\n if returntogame then\n returntogame = false\n return\n end\n end\nend","registry.lua":"registry = {}\n\nregistry.entries = {\n [\"DefaultApp\"] = {\n [\".lua\"] = \"Script Editor\",\n [\".png\"] = \"Image Viewer\",\n [\".vid\"] = \"Lua Video Player\",\n }\n}\n\nfunction registry.getvalue(k1, k2, k3, k4)\n if k4 then\n return registry.entries[k1][k2][k3][k4]\n elseif k3 then\n return registry.entries[k1][k2][k3]\n elseif k2 then\n return registry.entries[k1][k2]\n else\n return registry.entries[k1]\n end\nend\n\nreturn registry","Applications\/BlockGame\/menus.lua":"if not terrain then require \"main\" end\n\n-- Mordal Menu\nfunction mordalmenu(title, description, button1, button2)\n while true do\n draw.beginframe()\n draw.fillrect(48, 48, scrx - 48, scry - 48, draw.gray)\n draw.string(title, 56, 56, draw.white)\n draw.stringinrect(description, 56, 96, scrx - 56, scry - 96, draw.white)\n if button2 then\n drawbutton(button1, 56, scry - 96, scrx*.5, scry - 56)\n drawbutton(button2, scrx*.5, scry - 96, scrx - 56, scry - 56)\n else\n drawbutton(button1, 56, scry - 96, scrx - 56, scry - 56)\n end\n draw.endframe()\n local tx, ty = draw.waittouch()\n if ty > scry - 96 and ty < scry - 48 then\n if button2 then\n if tx > 56 and tx < scrx*.5 then\n return true\n end\n if tx > scrx*.5 and tx < scrx - 56 then\n return false\n end\n else\n if tx > 56 and tx < scrx - 56 then\n return true\n end\n end\n end\n end\nend\n\n-- Touch event functions for craftingmenu.\nfunction cbegintouch(x, y)\n\n\nend\n\nfunction ctouch(x, y)\nend\n\nfunction cendtouch(x, y)\n if x > scrx - 128 and y > scry - 48 then\n returntogame = true\n end\nend\n\n-- This is the crafting menu function.\nfunction craftingmenu()\n draw.tracktouches(cbegintouch, ctouch, cendtouch)\n while true do\n draw.tracktouches(cbegintouch, ctouch, cendtouch)\n draw.doevents()\n -- Draw the frame\n draw.beginframe()\n draw.clear(draw.black)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n draw.stringinrect(\"Build Items\", 0, 16, scrx, 48, draw.white)\n draw.endframe()\n -- Check if we need to return to the game.\n if returntogame then\n returntogame = false\n return\n end\n end\nend\n\nfunction tappedinventorybutton(scroll, x1, y1, x2, y2, tx, ty)\n local itemsperrow = math.floor((x2 - x1)\/48)\n local row = 0\n for k, v in pairs(inventory) do\n if k - (row*itemsperrow) > itemsperrow then\n row = row + 1\n end\n if tx > (k - (row*itemsperrow) - 1)*48 + x1 and tx < (k - (row*itemsperrow))*48 + x1 then\n if ty > y1 + (row*48) - scroll and ty < y1 + ((row + 1)*48) - scroll then\n return k\n end\n end\n end\nend\n\n-- Touch event functions for inventorymenu.\nfunction ibegintouch(x, y)\n if not buildmode then\n selectkey = tappedinventorybutton(0, 0, 0, scrx, scry, x, y)\n end\nend\n\nfunction itouch(x, y)\n shownamex, shownamey = x, y - 48\n if y > scry - 48 then\n scroll = scroll + 8\n elseif y < 48 then\n scroll = scroll - 8\n end\n if buildmode then\n local xcenter = 48*8 + 8\n local xstart = (scrx - xcenter)*.5 + 4\n if y > scry - 96 and y < scry - 48 and x > xstart and x < xstart + 48*7 then\n selected = math.min(math.floor(x\/48), 7)\n blockhovering = inventory[selected][1]\n else\n local y = y + scroll\n local blocksperrow = scrx\/48\n blockhovering = math.floor((x\/48) + (blocksperrow*math.floor(y\/48)))\n end\n else\n\n end\nend\n\nfunction iendtouch(x, y)\n blockhovering, shownamex, shownamey = nil, nil, nil\n local xcenter = 48*8 + 8\n local xstart = (scrx - xcenter)*.5 + 4\n if x > scrx - 128 and y > scry - 48 then\n returntogame = true\n elseif x > scrx - 256 and y > scry - 48 then\n settings()\n elseif x > scrx - 128*3 and y > scry - 48 then\n returntogame = true\n exitgame = true\n elseif buildmode then -- If in build mode\n local xcenter = 48*8 + 8\n local xstart = (scrx - xcenter)*.5 + 4\n if y > scry - 96 and x > xstart and x < xstart + 48*7 then\n selected = math.max(math.min(math.floor((x - xstart)\/48) + 1, 7), 1)\n else\n local y = y + scroll\n local blocksperrow = scrx\/48\n local newblock = math.floor((x\/48) + (blocksperrow*math.floor(y\/48)))\n if drawblock[newblock] then\n inventory[selected] = {newblock, 0, 100}\n --[[elseif newblock == 0 then\n inventory[selected] = {0, 0, 0}]]\n end\n end\n else\n\n end\nend\n\n-- Main menu.\nfunction inventorymenu()\n scroll = 0\n draw.tracktouches(ibegintouch, itouch, iendtouch)\n while true do\n draw.tracktouches(ibegintouch, itouch, iendtouch)\n draw.doevents()\n -- Draw the frame\n draw.beginframe()\n draw.clear(draw.black)\n local blocksperrow = scrx\/48\n if buildmode then -- if in build mode\n for k, v in ipairs(drawblock) do\n if (math.floor(k\/blocksperrow)*48) + 24 - scroll > -24 and (math.floor(k\/blocksperrow)*48) + 24 - scroll < scry + 24 then\n draw.transformedimage( \"@resources\/Block\" .. drawblock[k]..\".png\", (48*(k - (math.floor(k\/blocksperrow)*blocksperrow)) + 24), (math.floor(k\/blocksperrow)*48) + 24 - scroll, 48\/drawblocksz[k], 0)\n end\n end\n draw.stringinrect(\"Build Mode Inventory\", 0, 16, scrx, 48, draw.white)\n else -- If not in build mode\n --draw.stringinrect(\"Inventory\", 0, 16, scrx, 48, draw.white)\n drawinventoryinbox(0, 0, 0, scrx, scry)\n end\n drawinventory()\n if blockhovering then\n drawstring = blocknames[blockhovering] or drawblock[blockhovering] or \"Block \"..blockhovering\n drawstring = drawstring..\" (\"..blockhovering..\")\"\n draw.fillbox(shownamex, shownamey, draw.stringsize(drawstring), 16, draw.white)\n draw.string(drawstring, shownamex, shownamey - 2, draw.black)\n end\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n drawbutton(\"Settings\", scrx - 256, scry - 48, scrx - 128, scry)\n drawbutton(\"Save and Exit\", scrx - 384, scry - 48, scrx - 256, scry)\n draw.endframe()\n -- Check if we need to return to the game.\n if returntogame then\n returntogame = false\n return\n end\n end\nend\n\n-- Touch event functions for mainmenu.\nfunction mbegintouch(x, y)\n\nend\n\nfunction mtouch(x, y)\n\nend\n\nfunction mendtouch(x, y)\n if x > scrx*.5 - 128 and x < scrx*.5 + 128 then\n if y > scry - 156 and y < scry - 120 then\n gotomenu = \"worlds\"\n elseif y > scry - 120 and y < scry - 84 then\n gotomenu = \"settings\"\n elseif y > scry - 84 and y < scry - 48 then\n returnfrommainmenu = true\n elseif y > scry - 48 and y < scry - 12 then\n gotomenu = \"computerTest\"\n end\n end\nend\n\n-- Main menu.\nfunction mainmenu()\n draw.tracktouches(mbegintouch, mtouch, mendtouch)\n startx, starty = posx, posy\n local loadworldco = coroutine.create(loadworldmainmenu)\n loadworldlistco = coroutine.create(updateworldlist)\n math.randomseed(sys.gettime())\n local movex, movey = math.random()*8 - 4, math.random()*8 - 4\n local timeperlocationchange = 30 + (math.random()*20 - 10)\n local trans = 2\n local timestart = gettime()\n local worldhasloaded = false\n worldlistloaded = false\n coroutine.resume(loadworldco)\n coroutine.resume(loadworldlistco)\n while true do\n draw.tracktouches(mbegintouch, mtouch, mendtouch)\n draw.doevents()\n coroutine.resume(loadworldlistco)\n -- Handle the animated main menu.\n if worldhasloaded then\n posx, posy = posx + movex, -math.abs(posy - movey)\n math.randomseed(sys.gettime())\n movex, movey = movex + (math.random()*1 - .5), movey + (math.random()*1 - .5)\n if gettime() - timestart > timeperlocationchange + trans then\n posx = math.random()*2000000 - 1000000\n posy = -math.random()*16000\n timestart = gettime()\n end\n handlegame()\n else\n err, worldhasloaded = coroutine.resume(loadworldco)\n err, worldlistloaded = coroutine.resume(loadworldlistco)\n --print(worldhasloaded)\n timestart = gettime()\n end\n savedisabledbygame = true\n -- Draw the main menu.\n draw.beginframe()\n if worldhasloaded then\n drawbackground()\n err, msg = pcall(drawterrain)\n if not err then\n print(\"error when drawing animated menu: \"..msg)\n end\n if gettime() - timestart > timeperlocationchange then\n draw.clear({0, 0, 0, (gettime() - timestart - timeperlocationchange)\/trans})\n elseif gettime() - timestart < trans then\n draw.clear({0, 0, 0, 1 - (gettime() - timestart)\/trans})\n end\n else\n draw.clear(draw.black)\n draw.setfont(\"Arial\", 48)\n draw.stringinrect(\"Touch Lua Builder\", 0, 36, scrx, scry*.5, draw.white)\n draw.setfont(\"Arial\", 16)\n end\n drawbutton(\"Play Game\", scrx*.5 - 128, scry - 156, scrx*.5 + 128, scry - 120)\n drawbutton(\"Settings\", scrx*.5 - 128, scry - 120, scrx*.5 + 128, scry - 84)\n drawbutton(\"Exit Game\", scrx*.5 - 128, scry - 84, scrx*.5 + 128, scry - 48)\n drawbutton(\"Computer Test\", scrx*.5 - 128, scry - 48, scrx*.5 + 128, scry - 12)\n draw.endframe()\n -- Check which menu we need to go to.\n if gotomenu then\n if gotomenu == \"settings\" then\n settings()\n elseif gotomenu == \"worlds\" then\n selectworldmenu()\n elseif gotomenu == \"computerTest\" then\n local id = computers.newComputer()\n computers.startComputer(id)\n computers.switchToComputer(id)\n end\n gotomenu = nil\n end\n if returnfrommainmenu then\n returnfrommainmenu = false\n return\n end\n end\nend\n\n-- Touch event functions for worldoptionsmenu.\nfunction wobegintouch(x, y)\nend\n\nfunction wotouch(x, y)\nend\n\nfunction woendtouch(x, y)\n if y > scry - 48 and x > scrx - 128 then\n returnfromworldsmenu = true\n end\nend\n\n-- Options for a world\nfunction worldoptionsmenu()\n draw.tracktouches(wobegintouch, wotouch, woendtouch)\n while true do\n draw.doevents()\n draw.beginframe()\n draw.clear(draw.black)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n draw.stringinrect(\"Options for \"..worlds[selectedworld][1], 0, 16, scrx, 48, draw.white)\n draw.endframe()\n -- Check if we need to return.\n if returnfromworldsmenu then\n returnfromworldsmenu = false\n return\n end\n end\nend\n\n-- Touch event functions for selectworldmenu.\nfunction wbegintouch(x, y)\n\nend\n\nfunction wtouch(x, y)\n if y > scry - 96 then\n scroll = scroll + 4\n elseif y < 96 then\n scroll = scroll - 4\n end\nend\n\nfunction wendtouch(x, y)\n if x > scrx*.5 - 128 and x < scrx*.5 + 128 and y < scry - 48 then -- If a world was selected\n worldtapped = math.floor((y + scroll)\/48) + 1\n elseif y > scry - 48 and x > scrx - 128 then\n returnfromworldsmenu = true\n elseif y > scry - 48 and x > scrx - 256 then\n -- Create New World\n local worldname = keyboard.Keyboard(\"World Name\", \"New World\")\n if worldname and worldname ~= \"\" then\n savetofolder = worldname\n lfs.mkdir(approot.. \"SavedData\/\"..savetofolder)\n lfs.mkdir(approot.. \"SavedData\/\"..savetofolder..\"\/chunks\")\n lfs.mkdir(approot.. \"SavedData\/\"..savetofolder..\"\/computer1\")\n loadworld(savetofolder)\n end\n elseif y > scry - 48 and x > scrx - 384 then\n -- World Options\n if selectedworld then\n if mordalmenu(\"Delete \"..worlds[selectedworld][1], \"Are you sure you want to delete this world? Deleted worlds cannot be recovered.\", \"Yes\", \"No\") then\n if worlds[selectedworld][2] > 2048*1024 then\n if not mordalmenu(\"Delete \"..worlds[selectedworld][1], \"Are you absolutely sure you want to delete this world? All progress on \" .. worlds[selectedworld][1] .. \" WILL BE LOST if you continue.\", \"Yes, I want to delete this world.\", \"No\") then\n return\n end\n end\n lfs.destroy( approot .. \"SavedData\/\" .. worlds[selectedworld][1])\n worldlistloaded = false\n loadworldlistco = coroutine.create(updateworldlist)\n coroutine.resume(loadworldlistco)\n end\n end\n end\nend\n\nfunction lfs.getFolderSize(path)\n local size = 0\n for k, v in ipairs(sys.dir(path)) do\n if v ~= \"..\" and v ~= \".\" then\n if lfs.isDirectory(path..v) then\n size = size + lfs.getFolderSize(path..\"\/\"..v)\n else\n size = size + lfs.fileSize(path..\"\/\"..v)\n end\n end\n end\n return size\nend\n\n-- Load the worlds list.\nfunction updateworldlist()\n local worldfolders = sys.dir(approot..\"SavedData\")\n worlds = {}\n local lastyield = gettime()\n coroutine.yield()\n for k, v in ipairs(worldfolders) do\n if v ~= \".\" and v ~= \"..\" then\n if lfs.isDirectory(approot..\"SavedData\/\"..v) then\n worlds[#worlds + 1] = {v, 0}\n for k2, v2 in ipairs(sys.dir(approot..\"SavedData\/\"..v)) do\n if v2 ~= \".\" and v2 ~= \"..\" then\n if not lfs.isDirectory(approot..\"SavedData\/\"..v..\"\/\"..v2) then\n worlds[#worlds][2] = worlds[#worlds][2] + lfs.fileSize(approot..\"SavedData\/\"..v..\"\/\"..v2)\n else\n worlds[#worlds][2] = worlds[#worlds][2] + lfs.getFolderSize(approot..\"SavedData\/\"..v..\"\/\"..v2)\n end\n end\n if gettime() - lastyield > (1\/20) then\n lastyield = gettime()\n coroutine.yield()\n end\n end\n end\n end\n end\n return true\nend\n\n-- Select World menu.\nfunction selectworldmenu()\n draw.tracktouches(wbegintouch, wtouch, wendtouch)\n scroll = -48\n while true do\n draw.tracktouches(wbegintouch, wtouch, wendtouch)\n draw.doevents()\n exitgame = false\n if not worldlistloaded then\n err, worldlistloaded = coroutine.resume(loadworldlistco)\n end\n -- Draw Worlds Menu\n draw.beginframe()\n draw.clear(draw.black)\n for k, v in ipairs(worlds) do\n if k*48 - scroll > 0 and (k - 1) - scroll < scry then\n draw.fillrect(scrx*.5 - 128, (k - 1)*48 - scroll, scrx*.5 + 128, k*48 - scroll, draw.gray)\n draw.string(v[1], scrx*.5 - 128, (k - 1)*48 - scroll, draw.white)\n draw.string(v[2]..\" bytes\", scrx*.5 - 128, (k - 1)*48 - scroll + 24, draw.white)\n if selectedworld == k then\n draw.rect(scrx*.5 - 128, (k - 1)*48 - scroll, scrx*.5 + 128, k*48 - scroll, draw.white)\n end\n end\n end\n if #worlds <= 0 then\n draw.string(\"Tap the new world button to continue.\", 48, 48, draw.white)\n end\n draw.fillrect(0, 0, scrx, 48, draw.darkgray)\n draw.stringinrect(\"Created Worlds\", 0, 16, scrx, 48, draw.white)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n drawbutton(\"New World\", scrx - 256, scry - 48, scrx - 128, scry)\n if selectedworld then\n drawbutton(\"Delete World\", scrx - 384, scry - 48, scrx - 256, scry)\n end\n draw.endframe()\n -- Check if a world was tapped.\n if worlds[worldtapped] then\n if worldtapped == selectedworld then\n err, msg = pcall(loadworld, worlds[worldtapped][1])\n if not err then\n print(msg)\n end\n else\n selectedworld = worldtapped\n end\n worldtapped = nil\n end\n -- Check if we need to return.\n if returnfromworldsmenu then\n returnfromworldsmenu = false\n return\n end\n end\nend\n\n-- Settings menu.\nfunction settings()\n -- Touch event functions.\n function begintouch(x, y)\n\n end\n\n function touch(x, y)\n if y > 48 and y < 96 then\n chunkloading = math.max(math.min(math.floor((x - 160)\/((sliderwidth)\/(maxchunksloaded - 2))), maxchunksloaded - 2), 0) + 2\n elseif y > 96 and y < 128 then\n autosaveselected = math.max(math.min(math.floor((x - 160)\/((sliderwidth)\/#autosave)), #autosave), 0)\n autosavetime = autosave[autosaveselected]\n end\n end\n\n function endtouch(x, y)\n if x > scrx - 128 and y > scry - 48 then\n returnfromsettings = true\n elseif x > scrx - 256 and y > scry - 48 then\n savingenabled = not savingenabled\n elseif x > scrx - 384 and y > scry - 48 then\n buildmode = not buildmode\n end\n end\n draw.tracktouches(begintouch, touch, endtouch)\n maxchunksloaded = 16\n sliderwidth = (scrx - 48) - 160\n -- Menu loop.\n while true do\n draw.doevents()\n draw.beginframe()\n draw.clear(draw.black)\n draw.stringinrect(\"Settings\", 16, 16, scrx - 16, 48, draw.white)\n drawbutton(\"Back\", scrx - 128, scry - 48, scrx, scry)\n -- Slider 1\n draw.string(\"Chunks Loaded\", 24, 56, draw.white)\n draw.string((chunkloading + 1)^2, 24, 72, draw.white)\n draw.fillrect(160, 56, scrx - 48, 88, draw.gray)\n draw.fillbox(148 + (((chunkloading - 2)\/(maxchunksloaded - 2))*(sliderwidth)), 48, 24, 48, draw.white)\n -- Slider 2\n draw.string(\"Autosave time\", 24, 56 + 48, draw.white)\n if autosavetime <= 0 then\n draw.string(\"Autosave disabled\", 24, 72 + 48, draw.white)\n elseif autosavetime < 60 then\n draw.string(autosavetime..\" seconds\", 24, 72 + 48, draw.white)\n elseif autosavetime == 60 then\n draw.string((autosavetime\/60)..\" minute\", 24, 72 + 48, draw.white)\n else\n draw.string((autosavetime\/60)..\" minutes\", 24, 72 + 48, draw.white)\n end\n draw.fillrect(160, 56 + 48, scrx - 48, 88 + 48, draw.gray)\n draw.fillbox(148 + ((autosaveselected\/#autosave)*(sliderwidth)), 48 + 48, 24, 48, draw.white)\n if savingenabled then\n drawbutton(\"Disable Saving\", scrx - 256, scry - 48, scrx - 128, scry)\n else\n drawbutton(\"Enable Saving\", scrx - 256, scry - 48, scrx - 128, scry, 1)\n end\n if buildmode then\n drawbutton(\"Change to Survival Mode\", scrx - 384, scry - 48, scrx - 256, scry)\n else\n drawbutton(\"Change to Build Mode\", scrx - 384, scry - 48, scrx - 256, scry, 1)\n end\n draw.endframe()\n -- Check if we need to return.\n if returnfromsettings then\n returnfromsettings = false\n local file = io.open(approot..\"SavedData\/Settings.txt\", \"w\")\n file:write(tostring(savingenabled))\n file:write(\"\\n\"..chunkloading)\n file:write(\"\\n\"..autosaveselected)\n file:write(\"\\n\"..tostring(buildmode))\n file:close()\n return\n end\n end\nend","Applications\/BlockGame\/ComROM\/bios.lua":"print('Computer started!')\n\ndraw.beginframe()\ndraw.clear(draw.darkgray)\ndraw.endframe()\n\n-- Start the shell\nshellco = com.runscript(\"Rom\/shell.lua\")\nwhile coroutine.status(shellco) ~= \"dead\" do\n ok, err = coroutine.resume(shellco)\n coroutine.yield()\nend\nif not ok then\n draw.string(err, 0, 0, draw.red)\nend\n\n-- End of BIOS","Applications\/HTMLViewer":"nil","Applications\/SampleApp\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nApplication Title\nShort Title\nDescription\nVersion\nAuthor\nsamplescript\nicon.png","Applications\/FileBrowser\/viewer.lua":"local location\nif arg then\n location = arg[1]\n arg = nil\nend\nprint(\"File Browser opened\")\nbrowser = require \"filebrowser\"\n\n-- Show Pop-Up Message\nfunction ShowMessage(Text)\n draw.beginframe()\n draw.fillroundedrect(48, 48, ScreenX - 48, ScreenY - 48, 8, draw.lightgray)\n draw.stringinrect(Text, 48, 48, ScreenX - 48, ScreenY - 48, draw.black)\n draw.endframe()\n sys.sleep(500)\n draw.waittouch()\nend\n\n-- When an image file is opened.\nfunction ViewImage(location)\n while true do\n local x, y = draw.cacheimage(location)\n local min = math.min(x, y)\n local min2 = math.min(ScreenX, ScreenY - 64)\n draw.beginframe()\n draw.clear()\n draw.transformedimage(location, ScreenX*.5, (ScreenY*.5) + 32, 1\/(min\/min2), 0, 0)\n draw.fillrect(0, 0, ScreenX, 64, draw.gray)\n draw.setfont(\"Arial\", 24)\n draw.stringinrect(location, 0, 32, ScreenX, 64, draw.black)\n draw.setfont(\"Arial\", 16)\n draw.image(\"@resources\/LAMBack.png\", ScreenX - 48, 32)\n draw.endframe()\n local tapx, tapy = draw.waittouch()\n if tapx > ScreenX - 48 and tapy < 48 then\n return\n end\n end\nend\n\n-- When a sound is played.\nfunction PlaySound(location)\n audio.playbg(location)\nend\n\n-- When a music file is played.\nfunction PlayMusic(location)\n audio.playbg(location, true)\nend\n\n-- Operation loop\nwhile true do\n draw.settitle(\"Lua Explorer\")\n local filename = browser.loadfile(\"File Browser\", location or \"..\/..\/\")\n draw.settitle(tostring(filename))\n if filename then\n if string.sub(filename, -4) == \".png\" then\n ViewImage(filename)\n elseif string.sub(filename, -4) == \".wav\" then\n PlaySound(filename)\n elseif string.sub(filename, -4) == \".mp3\" then\n PlayMusic(filename)\n else\n AppMan.OpenFile(filename)\n end\n else\n return\n end\nend","Applications\/BlockGame\/InstallStub":"nil","Applications\/ScriptEditor\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nScript Editor\nScript Editor\nCreate, edit, and run Lua scripts.\nVersion 1.0\nLua Application Manager\nScriptEditor\nicon.png","mainapi.lua":"os.remove(\"..\/..\/Library\/Application Support\/Applications\")\nos.remove(\"..\/..\/Library\/Application Support\/InstallStubs\")\nos.remove(\"..\/..\/Library\/Application Support\/AutoInstall.lua\")\nos.remove(\"..\/..\/Library\/Application Support\/InstallStub.lua\")\nos.remove(\"..\/..\/Library\/Application Support\/InstallStubs.lua\")\nos.remove(\"..\/..\/Library\/Application Support\/Install.lua\")\nos.remove(\"..\/..\/Library\/Application Support\/main.lua\")\n\n--[[for k, v in ipairs(sys.dir(\"..\/..\/Library\/Application Support\/\")) do\n print(k, v)\nend]]\n\n\nlfs = require \"lfs\"\nfunction lfs.isDirectory(Path)\n return lfs.attributes(Path, \"mode\") == \"directory\"\nend\n\nfor k, v in ipairs(sys.dir(\"LAMAPI\")) do\n if v ~= \".\" and v ~= \"..\" then\n if not lfs.isDirectory(\"LAMAPI\/\"..v) then\n local read = io.open(\"LAMAPI\/\"..v)\n local str = read:read(\"*a\")\n read:close()\n local file = io.open(\"..\/..\/Library\/Application Support\/\"..v, \"w\")\n file:write(str)\n file:close()\n end\n end\nend","Applications\/BlockGame\/ComROM":"nil","Applications\/BlockGame\/blockdata.lua":"if not terrain then require \"main\" end\n\n-- Local Material values\nMaterialAir = 0\nMaterialStone = 1\nMaterialWood = 2\nMaterialDirt = 3\nToolWood = 5\nToolStone = 4\nToolIron = 6\nToolLapis = 7\nToolHand = 8\n\nmA, mS, mW, mD, tW, tS, tI, tL = MaterialAir, MaterialStone, MaterialWood, MaterialDirt, ToolWood, ToolStone, ToolIron, ToolLapis\n\n-- Frames to destroy\nmaterialftd = {\n [MaterialStone] = {[ToolHand] = 100, [tW] = 18, [tS] = 12, [tI] = 9},\n [MaterialWood] = {[ToolHand] = 125, [tW] = 22, [tS] = 12, [tI] = 9},\n [MaterialDirt] = {[ToolHand] = 25, [tW] = 9, [tS] = 6, [tI] = 3}\n}\nblockmaterial = {mA, mS, mS, mD, mD, mW}\ntoolmaterial = {[31] = tW, [32] = tW, [33] = tW, [34] = tW, [35] = tS, [36] = tS, [37] = tS, [38] = tS, [39] = tI, [40] = tI, [41] = tI, [42] = tI}\n\nfunction timetodestroy(blockid, toolid)\n local Material = blockmaterial[blockid] or mS\n local ToolMat = toolmaterial[toolid] or ToolHand\n return materialftd[Material][ToolMat]\nend\n\n-- Local Key values\nKeyDamage = 2\nKeyFuel = 3\nKeyProgress = 4\nKeySmeltItem = 5\nKeyFuelItem = 6\nKeyOutputItem = 7\nKeyChest = 8\nKeySidesConn = 9\nKeyIsEnergyBlock = 10\nKeyEnergy = 11\nKeyEnergyLimit = 12\nKeyMetadata = 13\nKeyLightVal = 14\nKeySunlightBlocked = 15\nKeyOrigin = 16\n\n-- Shortcuts\nlocal KeyOutput = KeyOutputItem\nlocal IsEnergyBlock = KeyIsEnergyBlock\n\n-- Block Information\nitemdamagelimit = {\n [31] = 64, [32] = 64, [33] = 64, [34] = 64, [35] = 128, [36] = 128, [37] = 128, [38] = 128, [39] = 256, [40] = 256, [41] = 256, [42] = 256,\n}\ncraftingitems = {\n [27] = {26, 26, 0, 26, 26, 0, 0, 0, 0}\n}\nsmeltingitems = {\n [3] = 2, -- Cobblestone = Stone\n}\nfuelitems = {\n [18] = 1000\n}\n\nfunction regenlighting(chunkx, chunky)\n local ypos = chunky*16\n local chunk = terrain[chunky][chunkx]\n local ceilchunk = skylight[chunkx]\n if not lightsources[chunky] then\n lightsources[chunky] = {}\n end\n if not lightsources[chunky][chunkx] then\n lightsources[chunky][chunkx] = {}\n end\n local lights = lightsources[chunky][chunkx]\n if not lights[17] then\n lights[17] = {}\n end\n for y, v in ipairs(chunk) do\n if not lights[y] then\n lights[y] = {}\n end\n for x, v2 in ipairs(v) do\n if not lights[y][x] then\n lights[y][x] = false\n end\n if chunk[y][x][1] == 69 then\n --print(\"Torch\")\n if not lights[y][x] == true then\n lights[y][x] = true\n lights[17][#lights[17] + 1] = {y, x}\n end\n else\n lights[y][x] = false\n for k, v in ipairs(lights[17]) do\n if v[1] == y and v[2] == x then\n table.remove(lights[17], k)\n end\n end\n end\n if y + ypos > ceilchunk[x] then\n -- Lighting is blocked\n if #lights[17] > 0 then\n for k, v in ipairs(lights[17]) do\n v2[KeyLightVal] = math.max(15 - math.abs(x - v[2]) - math.abs(y - v[1]), v2[KeyLightVal] or math.max(math.floor(15 - math.abs((y + ypos) - ceilchunk[x])), 0))\n end\n else\n v2[KeyLightVal] = math.max(math.floor(15 - math.abs((y + ypos) - ceilchunk[x])), 0)\n end\n elseif (y + ypos) < ceilchunk[x] and v2[1] > 1 then\n -- Lighting is now blocked\n ceilchunk[x] = y + ypos\n --print(chunkx*16 + x..\" is now blocked at \"..ceilchunk[x])\n elseif (y + ypos) == ceilchunk[x] and v2[1] < 2 then\n -- Lighting is now unblocked\n ceilchunk[x] = y + ypos + 1\n --print(chunkx*16 + x..\" is now unblocked at \"..ceilchunk[x])\n else\n -- Lighting is not blocked\n v2[KeyLightVal] = 15\n end\n end\n end\nend\n\n-- Functions for handling a block\nhandleblock = {}\n\n-- Handle Furnance\nhandleblock[28] = function(v2, chunk, chx, chy, x, y)\n if not v2[KeyFuel] then\n v2[KeyFuel] = 0\n v2[KeyProgress] = 0\n v2[KeySmeltItem] = {0, 0, 0}\n v2[KeyFuelItem] = {0, 0, 0}\n v2[KeyOutputItem] = {0, 0, 0}\n end\n if v2[KeySmeltItem][3] > 0 and v2[KeyOutputItem][3] <= 0 then\n if smeltingitems[v2[KeySmeltItem][1]] then\n v2[KeyOutputItem] = {smeltingitems[v2[KeySmeltItem][1]], 0, 0}\n end\n end\n if v2[KeyProgress] > 100 and v2[KeySmeltItem][3] > 1 then\n -- Smelting is complete\n v2[KeyProgress] = 0\n v2[KeyOutput][3] = v2[KeyOutput][3] + 1\n v2[KeySmeltItem][3] = v2[KeySmeltItem][3] - 1\n elseif v2[KeyFuel] > 0 then\n -- Smelting is not complete, add progress\n v2[KeyProgress] = v2[KeyProgress] + 1\n elseif v2[KeyFuel] <= 0 and fuelitems[v2[KeyFuelItem][1]] then\n v2[KeyProgress] = v2[KeyProgress] + 1\n v2[KeyFuelItem][3] = v2[KeyFuelItem][3] - 1\n v2[KeyFuel] = fuelitems[v2[KeyFuelItem][1]]\n end\nend\n\n-- Handle All Wires\nfunction HandleWire(v2, chunk, chx, chy, x, y, maxpower)\n maxpower = maxpower or 4\n if not v2[KeyEnergy] then\n v2[KeyEnergy] = 100\n v2[KeyIsEnergyBlock] = true\n v2[KeyOrigin] = {0, 0}\n end\n if v2[KeyEnergy] > 0 then\n if chunk[y + 1] then -- Go Down\n if chunk[y + 1][x] then\n if chunk[y + 1][x][IsEnergyBlock] == true then\n --if chunk[y + 1][x][KeyOrigin][1] ~= x and chunk[y + 1][x][KeyOrigin][2] ~= y then\n chunk[y + 1][x][KeyEnergy] = chunk[y + 1][x][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n elseif terrain[chy + 1][chx] then\n if terrain[chy + 1][chx][1][x][IsEnergyBlock] == true then\n terrain[chy + 1][chx][1][x][KeyEnergy] = terrain[chy + 1][chx][1][x][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n if chunk[y - 1] then -- Go Up\n if chunk[y - 1][x] then\n if chunk[y - 1][x][IsEnergyBlock] == true then\n chunk[y - 1][x][KeyEnergy] = chunk[y - 1][x][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n elseif terrain[chy - 1][chx] then\n if terrain[chy - 1][chx][1][x][IsEnergyBlock] == true then\n terrain[chy - 1][chx][1][x][KeyEnergy] = terrain[y - 1][chx][1][x][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n if chunk[y][x - 1] then -- Go Left\n if chunk[y][x - 1][IsEnergyBlock] == true then\n chunk[y][x - 1][KeyEnergy] = chunk[y][x - 1][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n if chunk[y][x + 1] then -- Go Right\n if chunk[y][x + 1][IsEnergyBlock] == true then\n chunk[y][x + 1][KeyEnergy] = chunk[y][x + 1][KeyEnergy] + math.min(v2[KeyEnergy], maxpower)\n v2[KeyEnergy] = v2[KeyEnergy] - math.min(v2[KeyEnergy], maxpower)\n end\n end\n end\nend\n\nfunction HandleElecFurn(v2, chunk, chx, chy, x, y, convtab)\n if not v2[KeyEnergy] then\n v2[KeyEnergy] = 0\n v2[KeyProgress] = 0\n v2[KeyIsEnergyBlock] = true\n v2[KeySmeltItem] = {0, 0, 0}\n v2[KeyFuelItem] = {0, 0, 0}\n v2[KeyOutputItem] = {0, 0, 0}\n end\n if v2[KeySmeltItem][3] > 0 and v2[KeyOutputItem][3] <= 0 then\n if convtab[v2[KeySmeltItem][1]] then\n v2[KeyOutputItem] = {convtab[v2[KeySmeltItem][1]], 0, 0}\n end\n end\n if v2[KeyEnergy] > 0 then\n if v2[KeyProgress] > 100 and v2[KeySmeltItem][3] > 0 then\n -- Smelting is complete\n v2[KeyProgress] = 0\n v2[KeyOutput][3] = v2[KeyOutput][3] + 1\n v2[KeySmeltItem][3] = v2[KeySmeltItem][3] - 1\n elseif v2[KeySmeltItem][3] > 0 then\n -- Smelting is not complete, add progress\n v2[KeyProgress] = v2[KeyProgress] + 1\n v2[KeyEnergy] = v2[KeyEnergy] - 1\n end\n else\n\n end\nend\n\n-- Handle Wire\nhandleblock[43] = function(v2, chunk, chx, chy, x, y)\n HandleWire(v2, chunk, chx, chy, x, y, 2048)\nend\n\n-- Handle Wire\nhandleblock[44] = function(v2, chunk, chx, chy, x, y)\n HandleWire(v2, chunk, chx, chy, x, y, 8)\nend\n\n-- Handle Solar Panel\nhandleblock[47] = function(v2, chunk, chx, chy, x, y)\n if not v2[KeyEnergy] then\n v2[KeyEnergy] = 10\n v2[KeyIsEnergyBlock] = true\n v2[KeyOrigin] = {0, 0}\n end\n v2[KeyEnergy] = math.min(v2[KeyEnergy] + 1, 280)\n HandleWire(v2, chunk, chx, chy, x, y)\nend\n\n-- Handle BatteryBox\nhandleblock[51] = function(v2, chunk, chx, chy, x, y)\n HandleWire(v2, chunk, chx, chy, x, y, 32)\nend\n\n-- Handle BatteryBox\nhandleblock[52] = function(v2, chunk, chx, chy, x, y)\n HandleWire(v2, chunk, chx, chy, x, y, 128)\nend\n\n-- Handle BatteryBox\nhandleblock[53] = function(v2, chunk, chx, chy, x, y)\n HandleWire(v2, chunk, chx, chy, x, y, 512)\nend\n\n-- Handle Electric Furnance\nhandleblock[54] = function(v2, chunk, chx, chy, x, y)\n HandleElecFurn(v2, chunk, chx, chy, x, y, smeltingitems)\nend\n\n-- Handle Chest\nhandleblock[58] = function(v2, chunk, chx, chy, x, y)\n if not v2[KeyChest] then\n -- Generate empty chest contents\n v2[KeyMetadata] = true\n v2[KeyChest] = {}\n for k=1, 40 do\n v2[KeyChest][k] = {0, 0, 0}\n end\n end\nend","InstallStub":"nil","Applications\/BlockGame\/saveload.lua":"if not terrain then require \"main\" end\n\n-- This function completely removes all files and directories in a directory, then removes the directory itself.\nfunction lfs.destroy(path)\n if lfs.isDirectory(path) then\n for k, v in ipairs(sys.dir(path)) do\n if v ~= \"..\" and v ~= \".\" then\n if lfs.isDirectory(path..\"\/\"..v) then\n lfs.destroy(path..\"\/\"..v)\n else\n os.remove(path..\"\/\"..v)\n end\n end\n end\n lfs.rmdir(path)\n end\nend\n\n-- Save a chunk of terrain.\nfunction saveterrain(x, y)\n if not savedisabledbygame then\n local cx, cy = x, y\n if y > -1 then\n return false\n end\n if savingenabled then\n if not terrain[y] then\n terrain[y] = {}\n end\n local chunk = terrain[y][x]\n if chunk then\n local file = io.open(approot..\"SavedData\/\"..savetofolder..\"\/chunks\/\"..y..\"x\"..x..\".chunk\", \"w\")\n --print(\"Saving chunk at \"..y, x)\n local stringx = \"\"\n for y, v in ipairs(chunk) do\n stringx = \"\"\n if v then\n for x, v2 in ipairs(v) do\n if not v2[1] then\n v2[1] = 1\n end\n if #tostring(v2[1]) < 2 then\n stringx = stringx..\"00\"..tostring(v2[1])\n elseif #tostring(v2[1]) < 3 then\n stringx = stringx..\"0\"..tostring(v2[1])\n else\n stringx = stringx..tostring(v2[1])\n end\n --[[if v2[KeyMetadata] then\n local file2 = io.open(\"SavedData\/\"..savetofolder..\"\/\"..cy*16 + y..\"x\"..cx*16 + x..\".data\", \"w\")\n local tab = {}\n for k3, v3 in pairs(v2) do\n if k3 > 1 then\n tab[k3] = v3\n end\n end\n local str = JSON.EncodeJSON(tab)\n file2:write(str)\n file2:close()\n end]]\n end\n file:write(stringx..\"\\n\")\n end\n end\n file:close()\n end\n return true\n end\n end\nend\n\n-- Saves the whole world.\nfunction saveworld()\n if not savedisabledbygame then\n local file = io.open(approot..\"SavedData\/\"..savetofolder..\"\/Data.lua\", \"w\")\n file:write(seed..\"\\n\")\n file:write(posx..\"\\n\")\n file:write(posy..\"\\n\")\n local inv = JSON.EncodeJSON(inventory)\n file:write(inv)\n file:close()\n for y, v in pairs(terrain) do\n draw.beginframe()\n draw.clear({0, 0, .4, .1})\n draw.transformedimage(\"@resources\/BlockSaving.png\", scrx*.5, scry*.5, 2, gettime()*10)\n draw.endframe()\n for x, v2 in pairs(v) do\n saveterrain(x, y)\n end\n end\n end\nend\n\nfunction loadworld(name)\n drawloadingscreen()\n savetofolder = name\n name = savetofolder\n if lfs.isFile(approot..\"SavedData\/\"..name..\"\/Data.lua\") then\n local file = io.open(approot..\"SavedData\/\"..name..\"\/Data.lua\")\n seed = file:read()\n posx = file:read()\n posy = file:read()\n inventory = tostring(file:read())\n inventory = JSON.DecodeJSON(inventory)\n file:close()\n end\n local ccx, ccy = math.floor(posx\/16\/blocksize), math.floor(posy\/16\/blocksize)\n local chunksloaded = 0\n local max = math.abs((ccy - chunkloading) - (ccy + chunkloading) - 1)*math.abs((ccx - chunkloading) - (ccx + chunkloading) - 1)\n for y = ccy - chunkloading, ccy + chunkloading do\n terrain[y] = {}\n draw.beginframe()\n draw.clear(draw.black)\n drawloadingscreen()\n draw.stringinrect(\"Loading Chunks...\", 0, 16, scrx, 48, draw.white)\n draw.fillrect(0, scry - 48, (chunksloaded\/max)*scrx, scry, draw.blue)\n draw.endframe()\n for x = ccx - chunkloading, ccx + chunkloading do\n --print(\"Loading chunk at \"..y, x)\n loadterrain(x, y)\n chunksloaded = chunksloaded + 1\n end\n end\n playgame()\nend\n\n-- Loads the world while in the main menu.\nfunction loadworldmainmenu()\n local name = savetofolder\n if lfs.isFile(approot..\"SavedData\/\"..name..\"\/Data.lua\") then\n local file = io.open(approot..\"SavedData\/\"..name..\"\/Data.lua\")\n seed = file:read()\n posx = file:read()\n posy = file:read()\n inventory = tostring(file:read())\n inventory = JSON.DecodeJSON(inventory)\n file:close()\n end\n local ccx, ccy = math.floor(posx\/16\/blocksize), math.floor(posy\/16\/blocksize)\n local chunksloaded = 0\n local max = math.abs((ccy - chunkloading) - (ccy + chunkloading) - 1)*math.abs((ccx - chunkloading) - (ccx + chunkloading) - 1)\n local lastyield = sys.gettime()\n coroutine.yield()\n for y = ccy - chunkloading, ccy + chunkloading do\n terrain[y] = {}\n for x = ccx - chunkloading, ccx + chunkloading do\n --print(\"Loading chunk at \"..y, x)\n loadterrain(x, y)\n chunksloaded = chunksloaded + 1\n if sys.gettime() - lastyield > (1\/20) then\n lastyield = sys.gettime()\n coroutine.yield()\n end\n end\n end\n return true\nend\n\n-- Loads a chunk of terrain.\nfunction loadterrain(x, y)\n terrain[y][x] = {}\n local chunk = terrain[y][x]\n local file = io.open(approot..\"SavedData\/\"..savetofolder..\"\/chunks\/\"..y..\"x\"..x..\".chunk\")\n --local file2 = io.open(\"SavedData\/\"..savetofolder..\"\/\"..y..\"x\"..x..\".data\")\n if not file then\n --print(\"Generating Chunk \"..x, y..\"...\")\n generateterrain(x, y)\n else\n --print(\"Loading Chunk \"..x, y..\" from disk...\")\n local line\n for y2=1, 16 do\n line = file:read()\n chunk[y2] = {}\n for i=1, 16 do\n chunk[y2] = {}\n chunk[y2][1] = tonumber(string.sub(line, (i - 1)*3 + 1, i*3))\n --[[if lfs.isFile(\"SavedData\/\"..savetofolder..\"\/\"..y*16 + y2..\"x\"..x*16 + i..\".data\") then\n local file2 = io.open(\"SavedData\/\"..savetofolder..\"\/\"..y*16 + y2..\"x\"..x*16 + i..\".data\")\n chunk[y2] = JSON.DecodeJSON(file2:read(\"*a\"))\n chunk[y2][1] = tonumber(string.sub(line, (i - 1)*3 + 1, i*3))\n file2:close()\n end]]\n end\n end\n end\n if file then\n file:close()\n -- Regenerate Lighting\n if not skylight[x] then\n skylight[x] = {}\n for i=1, 16 do\n skylight[x] = 0\n end\n end\n regenlighting(x, y)\n end\nend","Applications\/CubotsMarch!\/stages3.lua":"if not game then require \"main\" end\nlocal t, f = true, false\n\n-- Stage 21\nstages[21] = {[\"bonus\"] = 7}\nstages[21].commands = {t, t, t, t, f, f, f, t,f}\nstages[21].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[21].cubot1x = 10\nstages[21].cubot1y = 3\nstages[21].door1x = 15\nstages[21].door1y = 7\n\n-- Stage 22\nstages[22] = {[\"bonus\"] = 10}\nstages[22].commands = {t, t, t, t, f, f, t, t,f}\nstages[22].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[22].cubot1x = 15\nstages[22].cubot1y = 3\nstages[22].door1x = 15\nstages[22].door1y = 3\nstages[22].key1x = 9\nstages[22].key1y = 3\n\n-- Stage 23\nstages[23] = {[\"bonus\"] = 10}\nstages[23].commands = {t, t, t, t, t, t, t, t,f}\nstages[23].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0},\n {0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[23].cubot1x = 10\nstages[23].cubot1y = 8\nstages[23].door1x = 15\nstages[23].door1y = 2\n\n-- Stage 24\nstages[24] = {[\"bonus\"] = 13}\nstages[24].commands = {t, t, t, t, t, t, t, t,f}\nstages[24].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[24].cubot1x = 12\nstages[24].cubot1y = 4\nstages[24].door1x = 14\nstages[24].door1y = 2\nstages[24].key1x = 16\nstages[24].key1y = 4\n\n-- Stage 25\nstages[25] = {[\"bonus\"] = 12}\nstages[25].commands = {t, t, t, t, t, t, t, t,f}\nstages[25].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[25].cubot1x = 12\nstages[25].cubot1y = 4\nstages[25].door1x = 14\nstages[25].door1y = 2\n\n-- Stage 31\nstages[31] = {[\"bonus\"] = 14}\nstages[31].commands = {t, t, t, t, f, f, t, t,f}\nstages[31].data = {\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0},\n {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},\n}\nstages[31].cubot1x = 10\nstages[31].cubot1y = 3\nstages[31].door1x = 10\nstages[31].door1y = 3\nstages[31].key1x = 16\nstages[31].key1y = 3\nstages[31].cubot2x = 10\nstages[31].cubot2y = 6\nstages[31].door2x = 10\nstages[31].door2y = 6\nstages[31].key2x = 16\nstages[31].key2y = 6\n\nstages[41] = stages[31]","Applications\/BlockGame\/computer.lua":"if not terrain then require \"main\" end\ndraw.setscreen(1)\n\n-- Set up computers.\ncomputers = {}\ncomputers.comtab = {}\n\n-- Sets up a new computer.\nfunction computers.newComputer(id)\n computers.comtab[id or #computers.comtab + 1] = {}\n local computer = computers.comtab[id or #computers.comtab]\n computer.env = require \"computerENV\"\n computer.env.computerid = id or #computers.comtab\n return id or #computers.comtab\nend\n\n-- Starts a computer.\nfunction computers.startComputer(id)\n local computer = computers.comtab[id]\nend\n\n-- Gives the player control of a computer.\nfunction computers.switchToComputer(id)\n draw.clear(draw.black)\n local computer = computers.comtab[id]\n computer.fsmode = true\n computerid = id\n local co = coroutine.create(computers.computerEnv)\n local co2 = coroutine.create(computers.handleComputer)\n local ok, err = coroutine.resume(co, computer)\n if not ok then\n error(err)\n end\n ok, err = coroutine.resume(co2, computer)\n if not ok then\n error(err)\n end\n while true do\n draw.beginframe()\n ok, err = coroutine.resume(co)\n if not ok then\n print(err)\n end\n ok, err = coroutine.resume(co2)\n if not ok then\n error(err)\n end\n for k, v in ipairs(computer.env) do\n print(k, v)\n end\n computers.drawBorder()\n draw.endframe()\n end\n computer.fsmode = false\n return\nend\n\nfunction computers.drawBorder()\n draw.fillrect(0, 0, scrx, 48, draw.gray)\n draw.fillrect(0, scry - 48, scrx, scry, draw.gray)\n draw.fillrect(0, 0, 48, scry, draw.gray)\n draw.fillrect(scrx - 48, 0, scrx, scry, draw.gray)\nend\n\n-- Coroutine to run computer operations.\nfunction computers.computerEnv(computer)\n computer.env.computer = computer\n local _ENV = computer.env\n curEnv = _ENV\n local co=com.runscript(\"ROM\/bios.lua\", _ENV)\n while true do\n coroutine.resume(co)\n coroutine.yield()\n end\nend\n\n-- Coroutine to handle stuff\nfunction computers.handleComputer(computer)\n --print(computer)\n while true do\n if computer.fsmode then\n -- Draw to the screen\n --[[draw.beginframe()\n draw.clear()\n computers.drawBorder()\n draw.endframe()]]\n end\n coroutine.yield()\n end\nend\n-- End of script","Applications\/BlockGame\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nTouch Lua Builder\nTouch Lua Builder\nExplore the infinite ranges of the two dimentional world.\nIndev 0.1.1\nAuthor\nmain\nicon.png","Applications\/ScriptEditor\/ScriptEditor2.lua":"if not ScreenX then require \"ScriptEditor\" end\nScript = {\n \"print('Hello World!') -- User Comment\",\n \"-- edit this script by tapping a line of text.\",\n \"function Test() end\"\n} -- Script Code\nScriptColors = {\n [\"Text\"] = draw.black,\n [\"Comment\"] = {0, 128\/255, 16\/255, 1},\n [\"String\"] = {0, 233\/255, 148\/255, 1},\n [\"Function\"] = {.3, .3, 0, 1},\n [\"Statement\"] = draw.blue,\n [\"Error\"] = {1, 0, 0, 1},\n [\"Bracket\"] = {.5, 0, 1, 1},\n}\nFunctions = {\n \"print\", \"pcall\", \"error\", \"draw\", \"sys\", \"math\"\n}\nStatements = {\"local\", \"end\", \"if\", \"function\", \"elseif\", \"for\", \"while\", \"return\", \"in\", \"do\"}\nScriptChunks = {}\nFormat = {}\n\n-- Formating String\nfunction Format.String(Str, ch)\n if not Str then\n error(\"Str is broken\", 2)\n elseif not ch then\n error(\"ch is broken\", 2)\n end\n if string.find(Str, ch) > 1 then\n local Str2 = string.sub(Str, string.find(Str, ch) + 1, -1) or \"\"\n local r1 = string.sub(Str, 0, string.find(Str, ch) - 1)\n local str2 = string.find(Str2, ch) or 0\n local r2 = ch..string.sub(Str2, 0, str2 - 1)..ch\n local r3 = string.sub(Str2, str2 + 1, -1)\n return r1 or \"\", r2 or \"\", r3 or \"\"\n --[[elseif string.find(Str, ch) then\n local Str2 = Str\n local r1 = string.sub(Str, 0, string.find(Str, ch) - 1)\n local r2 = ch..string.sub(Str2, 0, string.find(Str2, ch) - 1)..ch\n local r3 = string.sub(Str2, string.find(Str2, ch) + 1, -1)\n return \"\", r2, r3]]\n end\nend\n\nfunction Format.MatchInTable(Str, Table)\n for k, v in ipairs(Table) do\n if string.find(Str, v) then\n return v\n end\n end\nend\n\nfunction Statement(k, Rem, mat, Type)\n r1 = string.sub(Rem, 0, string.find(Rem, mat) - 1)\n r2 = string.sub(Rem, string.find(Rem, mat), string.find(Rem, mat) + #mat - 1)\n r3 = string.sub(Rem, string.find(Rem, mat) + #mat, -1)\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r1, \"Text\"}\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r2, Type}\n return r3 or \"\"\nend\n\n-- Regenerates the script colors.\nfunction RegenerateScriptColors()\n ScrollMax = (#Script + 6)*20 - ScreenY\n ScriptChunks = {}\n local Rem = \"\"\n for k, v in ipairs(Script) do\n ScriptChunks[k] = {}\n Rem = v\n while #Rem > 0 do\n if string.find(Rem, \"'\") then\n local r1, r2, r3 = Format.String(Rem, \"'\")\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r1, \"Text\"}\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r2, \"String\"}\n Rem = r3\n elseif string.find(Rem, '\"') then\n local r1, r2, r3 = Format.String(Rem, '\"')\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r1, \"Text\"}\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r2, \"String\"}\n Rem = r3\n elseif string.find(Rem, \"--\") > 1 then\n local r1 = string.sub(Rem, 0, string.find(Rem, \"--\") + 1)\n local r2 = string.sub(Rem, string.find(Rem, \"--\") + 2, -1)\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r1, \"Text\"}\n ScriptChunks[k][#ScriptChunks[k] + 1] = {r2, \"Comment\"}\n Rem = \"\"\n elseif Format.MatchInTable(Rem, Statements) then\n Rem = Statement(k, Rem, Format.MatchInTable(Rem, Statements), \"Statement\")\n elseif Format.MatchInTable(Rem, Functions) then\n Rem = Statement(k, Rem, Format.MatchInTable(Rem, Functions), \"Function\")\n else\n ScriptChunks[k][#ScriptChunks[k] + 1] = {Rem, \"Text\"}\n Rem = \"\"\n end\n end\n end\nend\n\n-- Draws the script code.\nfunction DrawScriptCode(ScrollX, ScrollY)\n local LineWidth = 0\n draw.fillrect(0, 0, 48, ScreenY, draw.lightgray)\n for k, v in ipairs(ScriptChunks) do\n if (k*20) - ScrollY > -20 and (k*20) - ScrollY < ScreenY then\n draw.string(k, 0, (k*20) - ScrollY, draw.black)\n LineWidth = 0\n for k2, v2 in ipairs(v) do -- Actual lines\n local text = tostring(v2[1])\n local color = ScriptColors[v2[2]]\n draw.string(text, (48 + LineWidth) - ScrollX, (k*20) - ScrollY, color)\n LineWidth = LineWidth + draw.stringsize(v2[1])\n end\n end\n end\nend","Applications\/PaintApp\/main.lua":"print('Hello World!')\n","Applications\/HTMLViewer\/htmlviewer.lua":"local html = {}\nhtml.pagecontents = \"\"\nhtml.pagetitle = \"No title\"\nhtml.pageelements = {}\nhtml.scrx, html.maxscrx = 0, 0\nhtml.scry, html.maxscry = 0, 0\n\ncontrols = require \"drawcontrols\"\n\n-- Prepares a page for viewing.\nfunction html.preparePage(contents)\n\nend\n\n-- Draws a page.\nfunction html.drawPage(x1, y1, x2, y2, contents, scry, maxscry, scrx, maxscrx)\n if not contents then\n contents = html.pageelements\n end\n if not scry then\n scry = html.scry\n maxscry = html.maxscry\n end\n if not scrx then\n scrx = html.scrx\n maxscrx = html.maxscrx\n end\n -- Draw the page.\n\n\n -- Draw the scrollbar.\n if maxscry > 0 then\n controls.verScrollBar(scry, maxscry, x2 - 48, y1, x2, y2)\n end\n if maxscrx > 0 then\n\n end\nend\n\n-- Views a page.\nfunction html.viewPage()\n while true do\n ScreenX, ScreenY = draw.getport()\n draw.beginframe()\n draw.clear()\n html.drawPage(0, 48, ScreenX, ScreenY)\n draw.endframe()\n end\nend\n\n\n\nreturn html","Applications\/Help\/LuaApp.lua":"-- This is a script used for Lua App Manager.\nHelp\nHelp\nNeed Help? Visit this application.\nVersion 1.0\nLua Application Manager\nhelp\nicon.png","Applications\/BlockGame\/blocktexture.lua":"-- Generate Blocks\ndraw.setscreen(1)\ndraw.setclearcolor(draw.magenta)\n\n-- Set Colors\nlocal graybg = {.5, .5, .5, .3}\nlocal gray0 = {.7, .7, .7, 1}\nlocal gray1 = {.6, .6, .6, .7}\nlocal gray2 = {.5, .5, .55, .6}\nlocal gray3 = {.45, .45, .45, .5}\nlocal gray4 = {.3, .3, .35, .74}\nlocal gray5 = {.35, .35, .35, .75}\nlocal graysh = {.4, .4, .4, .33}\nlocal brown = {.6, .4, 0, 1}\nlocal brownsh = {.3, .1, 0, .33}\nlocal brownlg = {.8, .6, 0, .33}\nlocal wood = {.4, .2, 0, 1}\nlocal woodplank = {.6, .5, .2, 1}\nlocal greensh = {.1, .5, 0, .33}\nlocal waterlg = {.64, .64, .9, .654}\nlocal iron = {.8, .8, .9, 1}\n\nfunction cobblerock(x, y)\n draw.fillrect(x, y, x + 3, y + 3, gray3)\n draw.fillrect(x, y, x + 2, y + 2, gray2)\n draw.line(x + 1, y + 1, x + 3, y + 1, gray1)\n draw.line(x, y, x, y + 3, gray1)\n draw.point(x, y, draw.gray)\n draw.line(x + 1, y + 4, x + 3, y + 4, gray5)\n draw.line(x + 3, y + 1, x + 3, y + 3, gray4)\n draw.point(x + 3, y + 3, gray5)\nend\n\n-- Tool functions\n\nfunction stick()\n draw.line(0, 15, 15, 0, brown)\n draw.line(0, 16, 15, 1, wood)\nend\n\nfunction pickaxe(color)\n stick()\n draw.fillrect(4, 1, 14, 3, color)\n draw.fillrect(12, 1, 14, 12, color)\nend\n\nfunction axe(color)\n stick()\n draw.fillrect(8, 1, 14, 6, color)\nend\n\nfunction sword(color)\n stick()\n for i=-2, 3 do\n draw.line(5, 11 + i, 15, -3 + i, color)\n end\nend\n\nfunction shovel(color)\n stick()\nend\n\nfunction hoe(color)\n stick()\nend\n\n-- Draw Saving Icon\n--[=[\ndraw.beginframe()\ndraw.setlinestyle(2, \"butt\")\ndraw.circle(24, 24, 16, draw.white)\ndraw.clearrect(24, 0, 48, 24)\ndraw.line(16, 0, 24, 8, draw.white)\ndraw.lineto(16, 16, draw.white)\ndraw.endframe()\ndraw.setlinestyle(1, \"butt\")\ndraw.imagesave(\"@resources\/BlockSaving.png\", 0, 0, 48, 48)\n]=]\n\ndraw.setantialias(false)\n\n--[[ Draw Stone\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockStone.png\", 0, 0, 1, 1)]]\n\n--[=[\n-- Draw Cobblestone\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\nfor x=0, 16, 4 do\n for y=0, 16, 4 do\n cobblerock(x + 2, y + 2)\n cobblerock(x, y)\n end\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockCobblestone.png\", 0, 0, 4, 4)\nsys.sleep(math.huge)\n\n-- Draw Dirt\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.brown)\nmath.randomseed(363)\n--draw.rect(0, 1, 3, 4, draw.brown)\n--[[for i=1, 33 do\n x = math.random()*16\n draw.line(x, math.random()*16, x, math.random()*16, brownsh)\nend]]\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockDirt.png\", 0, 0, 4, 4)\n\n-- Draw Grass\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.brown)\nmath.randomseed(363)\nfor y=0, 16, 2 do\n for x=0, 16, 2 do\n draw.point(x, y, brownsh)\n draw.point(x + 1, y + 1, brownsh)\n end\nend\ndraw.rect(0, 1, 3, 4, draw.brown)\n--[[for i=1, 33 do\n x = math.random()*16\n draw.line(x, math.random()*16, x, math.random()*16, brownsh)\nend]]\ndraw.line(0, 0, 48, 0, draw.green)\ndraw.line(0, 1, 48, 1, draw.green)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockGrass.png\", 0, 0, 4, 4)\n\n-- Draw Wood\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, wood)\nmath.randomseed(363)\nfor i=1, 33 do\n x = math.random()*16\n draw.line(x, math.random()*16, x, math.random()*16, brownlg)\n draw.line(x, math.random()*16, x, math.random()*16, brownsh)\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockWood.png\", 0, 0, 4, 4)\n\n-- Draw Leaves\ndraw.beginframe()\ndraw.clearscreen()\nfor y=0, 16, 2 do\n for x=0, 16, 2 do\n draw.point(x, y, draw.green)\n draw.point(x + 1, y + 1, draw.green)\n end\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockLeaves.png\", 0, 0, 4, 4)\n\n-- Draw Water\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, waterlg)\nmath.randomseed(222)\nfor i=1, 33 do\n x = math.random()*16\n draw.line(x, math.random()*16, x, math.random()*16, waterlg)\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockWater.png\", 0, 0, 1, 1)\n\n-- Draw Lava\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.red)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockLava.png\", 0, 0, 1, 1)\n\n-- Draw Coal Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 1, 15, 15, draw.black)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockCoalOre.png\", 0, 0, 3, 3)\n\n-- Draw Iron Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 1, 15, 15, {.4, .5, 0, 1})\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockIronOre.png\", 0, 0, 3, 3)\n\n-- Draw Sapphire Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 1, 15, 15, draw.blue)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockSapphireOre.png\", 0, 0, 3, 3)\n\n-- Draw Ruby Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 1, 15, 15, draw.red)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockRubyOre.png\", 0, 0, 3, 3)\n\n-- Draw Emerald Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 1, 15, 15, {0, 1, 0, 1})\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockEmeraldOre.png\", 0, 0, 3, 3)\n\n-- Draw Trace Ore\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\nfor x=1, 16, 2 do\n for y=1, 16, 2 do\n draw.point(x, y, draw.red)\n end\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockTraceOre.png\", 0, 0, 3, 3)\n\n-- Draw Coal\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 47, 48, draw.black)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockCoal.png\", 0, 0, 4, 4)\n\n-- Draw Wood Planks\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, woodplank)\nfor i=3, 15, 4 do\n draw.line(0, i, 16, i, wood)\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockWoodPlanks.png\", 0, 0, 4, 4)\n\n-- Draw Crafting Table\ndraw.beginframe()\n--draw.clearscreen()\ndraw.fillrect(0, 0, 16, 2, woodplank)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockCraftingTable.png\", 0, 0, 15, 15)\n\n-- Draw Furnance\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.gray)\ndraw.fillrect(1, 8, 14, 14, draw.lightgray)\ndraw.rect(0, 8, 14, 15, graysh)\ndraw.rect(0, 1, 14, 15, graysh)\ndraw.rect(0, 1, 14, 15, graysh)\ndraw.rect(4, 10, 10, 15, graysh)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockFurnance.png\", 0, 0, 15, 15)\n\n-- Draw Iron Cable\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 5, 16, 11, draw.darkgray)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockIronCable.png\", 0, 0, 15, 15)\n\n-- Draw Tin Cable\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 6, 16, 10, draw.gray)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockTinCable.png\", 0, 0, 15, 15)\n\n-- Draw Computer Block\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, draw.black)\ndraw.fillrect(1, 11, 14, 14, draw.darkgray)\ndraw.rect(0, 12, 14, 15, graysh)\ndraw.rect(0, 1, 14, 15, graysh)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockComputer.png\", 0, 0, 15, 15)\n\n-- Draw Generator\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, {.95, .95, .95, 1})\ndraw.fillrect(1, 1, 14, 15, {.9, .9, .9, 1})\ndraw.fillrect(0, 8, 16, 16, {.75, .75, .75, 1})\ndraw.fillrect(1, 9, 14, 14, {.85, .85, .85, 1})\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockGenerator.png\", 0, 0, 15, 15)\n\n-- Draw Solar Panel\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, {.95, .95, .95, 1})\ndraw.fillrect(1, 1, 14, 15, {.9, .9, .9, 1})\ndraw.fillrect(0, 8, 16, 16, {.75, .75, .75, 1})\ndraw.fillrect(1, 9, 14, 14, {.85, .85, .85, 1})\ndraw.fillrect(1, 0, 14, 1, draw.blue)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockSolarPanel.png\", 0, 0, 15, 15)\n\n-- Draw Battery Box\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, wood)\ndraw.fillrect(0, 8, 16, 16, {.75, .75, .75, 1})\ndraw.fillrect(1, 9, 14, 14, {.85, .85, .85, 1})\nfor y=9, 16, 2 do\n for x=1, 13, 2 do\n draw.point(x, y, draw.red)\n draw.point(x + 1, y + 1, draw.red)\n end\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockBatteryBox.png\", 0, 0, 15, 15)\n\n-- Draw Electric Furnance\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(0, 0, 16, 16, {.95, .95, .95, 1})\ndraw.fillrect(1, 1, 14, 15, {.9, .9, .9, 1})\ndraw.fillrect(0, 8, 16, 16, {.75, .75, .75, 1})\ndraw.fillrect(1, 9, 14, 14, {.85, .85, .85, 1})\nfor y=9, 16, 2 do\n for x=1, 13, 2 do\n draw.point(x, y, draw.red)\n draw.point(x + 1, y + 1, draw.red)\n end\nend\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockElectricFurnance.png\", 0, 0, 15, 15)\n\n\n-- Draw Chest\ndraw.beginframe()\ndraw.clearscreen()\ndraw.setantialias(false)\ndraw.fillrect(1, 4, 13, 15, woodplank)\ndraw.rect(1, 4, 13, 15, wood)\ndraw.rect(1, 4, 13, 7, wood)\ndraw.fillrect(6, 6, 8, 10, {.9, .9, .9, 1})\ndraw.rect(6, 6, 8, 10, {.8, .8, .8, 1})\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockChest.png\", 0, 0, 15, 15)\n\n]=]\nlocal dtooltable = {\n axe, \"Axe\", pickaxe, \"Pickaxe\", sword, \"Sword\", shovel, \"Shovel\", hoe, \"Hoe\"\n}\n--dtooltable = {sword, \"Sword\", shovel, \"Shovel\", hoe, \"Hoe\"}\n-- Draw Basic Tools\nfor i=1, #dtooltable, 2 do\n local toolf, tool = dtooltable, dtooltable,\n draw.beginframe()\n draw.clearscreen()\n toolf(wood)\n draw.endframe()\n draw.imagesave(\"@resources\/BlockWood\"..tool..\".png\", 0, 0, 15, 15)\n draw.beginframe()\n draw.clearscreen()\n toolf(gray2)\n draw.endframe()\n draw.imagesave(\"@resources\/BlockStone\"..tool..\".png\", 0, 0, 15, 15)\n draw.beginframe()\n draw.clearscreen()\n toolf(iron)\n draw.endframe()\n draw.imagesave(\"@resources\/BlockIron\"..tool..\".png\", 0, 0, 15, 15)\nend\n\n-- Stick\ndraw.beginframe()\ndraw.clearscreen()\nstick()\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockStick.png\", 0, 0, 15, 15)\n\n-- Torch\ndraw.beginframe()\ndraw.clearscreen()\ndraw.fillrect(7, 7, 9, 16, wood)\ndraw.fillrect(7, 7, 9, 9, draw.red)\ndraw.endframe()\ndraw.imagesave(\"@resources\/BlockTorch.png\", 0, 0, 15, 15)\n--sys.sleep(math.huge)\n\n-- Done Generating Images","Applications\/CubotsMarch!\/drawx.lua":"if not game then require \"main\" end\n--------------------\n-- Draw Functions --\n--------------------\n\n-- Basic Colors\nblue1 = {0, 0, .77, 1}\nblue2 = {.5, .5, .8, 1}\nblue3 = {.1, .6, 1, 1}\nyellow1 = {1, .45, 0, 1}\nyellow2 = {1, .85, .35, 1}\npink1 = {1, 0, 1, 1}\npink2 = {1, .5, 1, 1}\nred1 = {1, 0, 0, 1}\nred2 = {1, .5, .5, 1}\ngreen1 = {0, .8, 0, 1}\ngreen2 = {.4, 1, .6, 1}\ngreen3 = {0, .8, 0, 1}\ngreen4 = {.4, 1, .6, 1}\npurple1 = {.58, 0, .8, 1}\npurple2 = {.65, .5, .95, 1}\n\n-- Draws a rectangle the size of sx and sy.\nfunction draw.box(orgx, orgy, sx, sy, col)\n draw.rect(orgx, orgy, orgx + sx, orgy + sy, col)\nend\n\n-- Draws a rectangle the size of sx and sy.\nfunction draw.fillbox(orgx, orgy, sx, sy, col)\n draw.fillrect(orgx, orgy, orgx + sx, orgy + sy, col)\nend\n\n-- Preload Resources\nfunction draw.preloadResources()\n for k, v in ipairs(sys.dir(approot..\"resources\")) do\n if v ~= \".\" and v ~= \"..\" then -- Check that it is not the current or parent directories.\n if string.sub(v, -4) == \".png\" then\n draw.cacheimage(approot .. \"resources\/\" .. v)\n end\n end\n end\nend\n\n-- Draw an isometric block\nfunction draw.block(x, y, size, size2, color1, color2, color3)\n local size1 = size - size2\n draw.fillrect(x, y, size1 + x, size1 + y, color3)\n draw.fillrect(x, y, size2 + x, size1 + y, color2)\n draw.filltriangle(x, y, size2 + x, y, size2 + x, size2 + y, color3)\n draw.filltriangle(size1 + x, size2 + y, size1 + x, y, size + x, size2 + y, color3)\n draw.filltriangle(x, size1 + y, size2 + x, size1 + y, size2 + x, size + y, color2)\n draw.fillrect(size + x, size2 + y, size2 + x, size + y, color1)\nend\n\n-- Draw an isometric block with varying width.\nfunction draw.block2(x, y, sizex, sizey, depth, color1, color2, color3)\n local size1x = sizex - depth\n local size1y = sizey - depth\n draw.fillrect(x, y, size1x + x, size1y + y, color3)\n draw.fillrect(x, y, depth + x, size1y + y, color2)\n draw.filltriangle(x, y, depth + x, y, depth + x, depth + y, color3)\n draw.filltriangle(size1x + x, depth + y, size1x + x, y, sizex + x, depth + y, color3)\n draw.filltriangle(x, size1x + y, depth + x, size1y + y, depth + x, sizey + y, color2)\n draw.fillrect(sizex + x, depth + y, depth + x, sizey + y, color1)\nend\n\n-- Draw the blue cubot\nfunction draw.cubot1(x, y, picture)\n x, y = x - 8, y - 20\n if picture == 1 then\n\n else\n -- Draw Body and Legs\n draw.block2(x + 26, y + 19, 5, 15, 2, draw.darkgray, draw.gray, draw.white)\n draw.block2(x + 23, y + 19, 8, 5, 2, draw.darkgray, draw.gray, draw.white)\n\n draw.block2(x + 18, y + 28, 7, 16, 3, draw.darkgray, draw.gray, draw.black)\n draw.block2(x + 12, y + 28, 7, 16, 3, draw.darkgray, draw.gray, draw.black)\n\n draw.block2(x + 12, y + 17, 13, 18, 3, blue1, blue2, draw.white)\n\n draw.block2(x + 7, y + 19, 8, 5, 2, draw.darkgray, draw.gray, draw.white)\n draw.block2(x + 7, y + 19, 5, 15, 2, draw.darkgray, draw.gray, draw.white)\n\n -- Draw Head\n draw.fillbox(x + 18, y + 16, 4, 6, blue1)\n draw.block(x + 10, y, 17, 3, blue1, blue2, draw.white)\n draw.fillbox(x + 15, y + 6, 3, 3, draw.cyan)\n draw.fillbox(x + 22, y + 6, 3, 3, draw.cyan)\n draw.fillbox(x + 15, y + 12, 10, 3, {1, .2, .6, 1})\n end\nend\n\n-- Draw the orange cubot\nfunction draw.cubot2(x, y, picture)\n x, y = x - 16, y + 24\n draw.box(x, y, blocksize, blocksize, green)\nend\n\n-- Draw the Stage.\nfunction draw.stage()\n local color1, color2 = blue1, blue2\n local color3, color4 = yellow1, yellow2\n if selectedlevel <= 10 then\n color1, color2 = blue1, blue2\n elseif selectedlevel <= 20 then\n color1, color2 = pink1, pink2\n elseif selectedlevel <= 30 then\n color1, color2 = red1, red2\n elseif selectedlevel <= 40 then\n color1, color2 = green3, green4\n elseif selectedlevel <= 50 then\n color1, color2 = purple1, purple2\n end\n local v -- This is the table of the stage row to draw.\n -- Draw all of the rows of the stage.\n for k=#stage, 1, -1 do\n v = stage[k]\n if door1y == k then\n if door1locked then\n draw.fillbox((door1x)*blocksize + drawx - 24, k*blocksize + drawy - 24, 32, 32, draw.gray)\n end\n draw.image(approot..\"resources\/Door.png\", (door1x)*blocksize + drawx - 28, k*blocksize + drawy - 28)\n end\n for k2=#v, 1, -1 do\n --draw.box(k2*blocksize + drawx - (blocksize - 32), k*blocksize + drawy - (blocksize - 32), blocksize, blocksize, draw.red)\n if v[k2] == 1 then -- Draw Static Block\n draw.block(k2*blocksize + drawx - (blocksize - 8), k*blocksize + drawy - (blocksize - 8), 56, 56 - blocksize, color1, color2, draw.white)\n --draw.fillbox(k2*blocksize + drawx - (blocksize - 32), k*blocksize + drawy - (blocksize - 32), blocksize, blocksize, draw.red)\n elseif v[k2] == 2 then -- Draw Dynamic Block\n if not (k == newblock1y and k2 == newblock1x) then\n draw.block(k2*blocksize + drawx - (blocksize - 8), k*blocksize + drawy - (blocksize - 8), 56, 56 - blocksize, color3, color4, draw.white)\n end\n end\n end\n if curblock1y then\n if math.floor(curblock1y) == k then\n -- Draw Moving Block\n draw.block(curblock1x*blocksize + drawx - (blocksize - 8), curblock1y*blocksize + drawy - (blocksize - 8), 56, 56 - blocksize, color3, color4, draw.white)\n\n end\n end\n if math.floor(cubot1dy) == k then\n draw.cubot1(cubot1dx*blocksize + drawx - 4, cubot1dy*blocksize + drawy - 4, cubot1dir)\n end\n if math.floor(cubot2dy) == k then\n draw.cubot2(cubot2dx*blocksize + drawx, cubot2dy*blocksize + drawy, picture)\n end\n end\n if door1locked then\n draw.fillbox((key1x)*blocksize + drawx - 28, key1y*blocksize + drawy - 28, 32, 32, draw.gray)\n end\nend\n\n-- Draws an icon for a command.\nfunction draw.drawcodeicon(number, x, y)\n local name = \"\"\n if number == 1 then\n name = \"MoveLeft\"\n elseif number == 2 then\n name = \"MoveRight\"\n elseif number == 3 then\n name = \"MoveForward\"\n elseif number == 4 then\n name = \"TurnAround\"\n elseif number == 5 then\n name = \"PushBlock\"\n elseif number == 6 then\n name = \"PullBlock\"\n elseif number == 7 then\n name = \"JumpOverBlock\"\n elseif number == 8 then\n name = \"Function1\"\n elseif number == 9 then\n name = \"Function2\"\n end\n draw.image(approot..\"resources\/\".. name ..\".png\", x, y)\nend\n\nfunction draw.codeiconcolor(number)\n if number > 0 then\n if number <= 4 then\n return draw.green\n elseif number < 8 then\n return blue3\n elseif number == 8 then\n return draw.yellow\n elseif number == 9 then\n return draw.magenta\n end end\n return draw.black\nend\n\nlocal unavailcolor = {.60, .60, .60, 1}\nfunction draw.code()\n if playing then\n draw.filltriangle(ScreenX - 40, 0, ScreenX - 40, 48, ScreenX - 8, 24, draw.green)\n else\n draw.fillrect(ScreenX - 48, 0, ScreenX - (48 - 48\/3), 48, draw.red)\n draw.fillrect(ScreenX - (48 - 48\/3*2), 0, ScreenX, 48, draw.red)\n end\n draw.box(ScreenX - 48, 48, 48, 48, draw.white)\n -- Draw Commands List\n draw.block(0, 20, 36, 4, draw.darkgray, draw.lightgray, draw.white)\n draw.fillbox(8, 28, 24, 24, draw.black)\n --draw.image(approot..\"resources\/CodeBlock.png\", 0, 20)\n for k, v in ipairs(availcommands) do\n if v == true then -- if available\n local color = draw.darkgray\n if selectedcommand == k then\n color = draw.red\n end\n draw.block(k*36, 20, 36, 4, color, draw.lightgray, draw.white)\n --draw.image(approot..\"resources\/CodeBlock.png\", k*36, 20, 20)\n draw.fillbox(k*36 + 8, 20 + 8, 24, 24, draw.codeiconcolor(k))\n draw.drawcodeicon(k, k*36 + 8, 28)\n end\n end\n if not hidecoding then\n -- Draw Cubot 1's commands\n for k, v in ipairs(cubot1) do\n draw.block((k - 1)*36, 64, 36, 4, blue1, blue2, draw.white)\n if curcubot1 == k then\n -- indicate that it is running this command\n draw.fillbox((k - 1)*36 + 8, 64 + 8, 24, 24, draw.white)\n else\n -- draw the default color instead\n draw.fillbox((k - 1)*36 + 8, 64 + 8, 24, 24, draw.codeiconcolor(v))\n end\n draw.drawcodeicon(v, (k - 1)*36 + 8, 64 + 8)\n end\n -- Draw Cubot 2's commands\n if cubot2y then\n for k, v in ipairs(cubot2) do\n draw.block((k - 1)*36, 100, 36, 4, yellow1, yellow2, draw.white)\n draw.fillbox((k - 1)*36 + 8, 100 + 8, 24, 24, draw.codeiconcolor(v))\n draw.drawcodeicon(v, (k - 1)*36 + 8, 100 + 8)\n if curcubot2 == k then\n -- indicate that it is running this command\n draw.rect((k - 1)*36 + 8, 100 + 8, k*36 - 4, 100 + 32, draw.white)\n end\n end\n end\n -- Draw Function 1 commands\n if availcommands[8] then\n for k, v in ipairs(funct1) do\n draw.block((k - 1)*36, 136, 36, 4, draw.yellow, blue2, draw.white)\n draw.fillbox((k - 1)*36 + 8, 136 + 8, 24, 24, draw.codeiconcolor(v))\n draw.drawcodeicon(v, (k - 1)*36 + 8, 136 + 8)\n if curfunct1c1 == k then\n -- indicate that it is running this command\n draw.rect((k - 1)*36 + 8, 136 + 8, k*36 - 4, 136 + 32, draw.white)\n end\n end\n end\n -- Draw Function 2 commands\n if availcommands[9] then\n for k, v in ipairs(funct2) do\n draw.block((k - 1)*36, 172, 36, 4, draw.magenta, yellow2, draw.white)\n draw.fillbox((k - 1)*36 + 8, 172 + 8, 24, 24, draw.codeiconcolor(v))\n draw.drawcodeicon(v, (k - 1)*36 + 8, 172 + 8)\n if curfunct2c1 == k then\n -- indicate that it is running this command\n draw.rect((k - 1)*36 + 8, 172 + 8, k*36 - 4, 172 + 32, draw.white)\n end\n end\n end\n if dragx then -- Draw command cursor\n draw.fillbox(dragx, dragy, 24, 24, draw.codeiconcolor(selectedcommand))\n draw.drawcodeicon(selectedcommand, dragx, dragy)\n end\n end\nend\n\n-- Draw Memory Bonus\nfunction draw.memoryBonus()\n local string1 = \"Memory Bonus: \"..bonus\n draw.string(string1, draw.stringsize(string1), 0, draw.blue)\nend\n\n-- Draws the menu where you chose a level.\nfunction draw.levelsMenu(Set)\n local color1, color2, color3 = blue1, blue2, draw.white\n local title = \"Training\"\n if Set == 1 then\n\n elseif Set == 2 then\n title = \"Push and Pull\"\n color1, color2 = pink1, pink2\n elseif Set == 3 then\n title = \"Functional\"\n color1, color2 = red1, red2\n elseif Set == 4 then\n title = \"Hello Orange\"\n color1, color2 = green3, green4\n elseif Set == 5 then\n title = \"Multifunctional\"\n color1, color2 = purple1, purple2\n end\n local oldcolor1 = color1\n for i=1, 5 do\n -- Set Color\n if save.data == 2 then\n color1 = draw.green\n elseif save.data == 1 then\n color1 = color2\n else\n color1 = oldcolor1\n end\n draw.block(i*64 + 4, 64, 56, 4, color1, color2, color3)\n -- Set Color\n if save.data == 2 then\n color1 = draw.green\n elseif save.data == 1 then\n color1 = color2\n else\n color1 = oldcolor1\n end\n draw.block(i*64 + 4, 160, 56, 4, color1, color2, color3)\n end\n draw.setfont(\"Arial\", 24)\n draw.stringinrect(title, 48, 0, ScreenX - 48, 48, draw.white)\n draw.setfont(\"Arial\", 16)\n if Set < 5 then\n draw.filltriangle(ScreenX - 48, 0, ScreenX - 48, 48, ScreenX, 24, draw.green)\n end\n if Set > 1 then\n draw.filltriangle(48, 0, 48, 48, 0, 24, draw.green)\n end\n draw.string(\"Score: \"..score, 0, ScreenY - 20, draw.white)\nend\n\n-- Draws the main menu.\nfunction draw.mainMenu()\n -- Draw Play Button\n draw.block(ScreenX*.5 - 128, ScreenY - 128, 72, 12, blue1, blue2, draw.white)\n draw.filltriangle(ScreenX*.5 - 116, ScreenY - 116, ScreenX*.5 - 56, ScreenY - 86, ScreenX*.5 - 116, ScreenY - 56, draw.green)\n -- Draw Help Button\n draw.block(ScreenX*.5 - (72*.5), ScreenY - 128, 72, 12, green1, green2, draw.white)\n -- Draw Reset Button\n draw.block(ScreenX*.5 + (128 - 72), ScreenY - 128, 72, 12, yellow1, yellow2, draw.white)\n draw.image(approot..\"resources\/BlueBlock.png\", 0, 0)\nend\n\nfunction draw.helpTouchIcon(x, y)\n draw.filltriangle(x, y, x + 24, y, x, y + 24, draw.white)\n draw.triangle(x, y, x + 24, y, x, y + 24, draw.gray)\nend\n\n-- Help Main Page\nfunction draw.helpMain(time)\n draw.clear(draw.black)\n draw.stage()\n draw.memoryBonus()\n draw.code()\n if time > 1 then\n if time < 2 then\n selectedcommand = 2\n dragx, dragy = 96 - ((time - 1)*80), 32 + ((time - 1)*48)\n draw.helpTouchIcon(dragx, dragy)\n elseif time < 2.5 then\n dragx, dragy = nil, nil\n cubot1[1] = selectedcommand\n elseif time < 3.5 then\n draw.helpTouchIcon(ScreenX - 24, 24)\n elseif time > 5 and time < 5.5 then\n draw.helpTouchIcon(ScreenX - 24, 24)\n elseif time > 6.5 and time < 7 then\n cubot1 = {2, 2, 2, 2, 2, 2, 0, 0}\n elseif time > 7 and time < 7.5 then\n draw.helpTouchIcon(ScreenX - 24, 24)\n end\n end\nend\n\n-- Draw Help Objects Page\nfunction draw.helpMain2()\n local swidth = 480\n local l = (ScreenX - swidth)\n local m = ScreenX*.5 - (ScreenX - swidth)\n local r = ScreenX - (ScreenX - swidth)\n draw.setfont(\"Arial\", 36)\n draw.stringinrect(\"Objects\", 0, 0, ScreenX, 48, draw.white)\n draw.setfont(\"Arial\", 16)\n -- Draw Cubot Section\n draw.rect(l + 24, 48, m, 160, draw.white)\n draw.cubot1(l + 24, 48, \"default\")\n --draw.cubot2(l + 24, 96, \"default\")\n draw.stringinrect(\"These are the cubots. To complete a level move all of the cubots to their respectively colored doors.\", l + 64, 48, m, 160, draw.white)\n -- Draw Door Section\n draw.rect(l + 24, 160, m, 256, draw.white)\n draw.image(approot..\"resources\/Door.png\", l + 24, 160)\n draw.stringinrect(\"This is a door. Some stages have locked doors which must be unlocked by a key.\", l + 64, 160, m, 256, draw.white)\n -- Draw Block Section\n draw.rect(m, 48, r - 24, 160, draw.white)\n draw.block(m, 48, 56, 56 - blocksize, blue1, blue2, draw.white)\n draw.stringinrect(\"These are blocks. Only dynamic blocks can be pushed or pulled.\", m + 48, 64, r - 24, 160, draw.white)\nend\n\n-- Help Commands Page\nfunction draw.helpCommands()\n if not commandslist then\n commandslist = {\"Move Left\", \"Move Right\", \"Move Forward\", \"Turn Around\", \"Push Block\", \"Pull Block\", \"Jump Over Block\", \"Call Function 1\", \"Call Function 2\"}\n end\n draw.setfont(\"Arial\", 36)\n draw.stringinrect(\"Commands\", 0, 0, ScreenX, 48, draw.white)\n draw.setfont(\"Arial\", 20)\n for k, v in ipairs(commandslist) do\n draw.fillbox(40, k*32, 24, 24, draw.codeiconcolor(k))\n draw.drawcodeicon(k, 40, k*32)\n draw.string(v, 64, k*32, draw.white)\n end\n draw.setfont(\"Arial\", 16)\nend\n\ndraw.preloadResources() -- Preload Resources","Applications\/FileBrowser":"nil","Applications\/CubotsMarch!\/touchx.lua":"if not game then require \"main\" end\n---------------------\n-- Touch Functions --\n---------------------\n\n-- Checks if point is in rectangle\nfunction touch.rect(px, py, rx1, ry1, rx2, ry2)\n rx1, rx2 = math.min(rx1, rx2), math.max(rx1, rx2)\n ry1, ry2 = math.min(ry1, ry2), math.max(ry1, ry2)\n if px > rx1 and px < rx2 then\n if py > ry1 and py < ry2 then\n return true\n end\n end\n return false\nend\n\n-- This function exists because Touch Lua does not accept nil variables for draw.tracktouches\nfunction none() end\n\n-- Gameplay touch events\nfunction touch.beganGameplay(tx, ty)\n if not playing then -- Don't select command if running commands.\n if ty < 48 then -- If players tapped on a command or the play button,\n if math.floor(tx\/36) < 1 then\n selectedcommand = 0 -- Clear Cmd\n elseif math.floor(tx\/36) < 10 then\n if availcommands[math.floor(tx\/36)] then -- and the command is available then\n selectedcommand = math.floor(tx\/36) -- Select this command.\n print(\"selected command \"..selectedcommand)\n end\n end\n end\n end\n if tx > ScreenX - 48 and ty < 48 then\n playing = not playing\n game.resetStage()\n end\nend\n\nfunction touch.movedGameplay(tx, ty)\n if not playing then -- Only show selected command if the commands are not running.\n dragx, dragy = tx, ty -- Dragging icon.\n end\nend\n\nfunction touch.endedGameplay(tx, ty)\n if not playing and ty > 48 then -- Make sure that players can't cheat by changing commands while they are running.\n if math.floor(tx\/36) + 1 <= maxcommands then\n if ty < 96 then\n -- Add a command to Cubot 1\n cubot1[math.floor(tx\/36) + 1] = selectedcommand\n elseif ty < 128 and cubot2x then\n -- Add a command to Cubot 2\n cubot2[math.floor(tx\/36) + 1] = selectedcommand\n elseif ty < 160 and availcommands[8] then\n -- Add a command to Function 1\n funct1[math.floor(tx\/36) + 1] = selectedcommand\n elseif ty < 192 and availcommands[9] then\n -- Add a command to Function 2\n funct2[math.floor(tx\/36) + 1] = selectedcommand\n end\n end\n end\n if tx > ScreenX - 48 and ty > 48 and ty < 96 then\n hidecoding = not hidecoding\n end\n dragx, dragy = nil, nil\nend\n\n-- Levels Menu touch events\nfunction touch.beganLevels()\nend\n\nfunction touch.movedLevels()\nend\n\nfunction touch.endedLevels(tx, ty)\n if tx < 48 and ty < 48 then\n set = math.max(set - 1, 1)\n elseif tx > ScreenX - 48 and ty < 48 then\n set = math.min(set + 1, 5)\n end\n local levx, levy = math.floor(tx\/64), math.floor(ty\/64)\n if levy == 1 then\n selectedlevel = levx + (set - 1)*10\n elseif levy == 2 then\n selectedlevel = levx + 5 + (set - 1)*10\n end\n if not stages[selectedlevel] then\n selectedlevel = nil\n end\nend\n\n-- Help Menu touch events\nfunction touch.endedHelp(tx, ty)\n if ty > ScreenY - 48 then\n if tx > ScreenX - 48 then\n nextPage = true\n elseif tx > ScreenX - 96 then\n back = true\n end\n end\nend\n\n-- Main Menu touch events\nfunction touch.beganMenu()\nend\n\nfunction touch.movedMenu()\nend\n\nfunction touch.endedMenu(tx, ty)\n Play = touch.rect(tx, ty, ScreenX*.5 - 128, ScreenY - 96, (ScreenX*.5 - 128) + 72, ScreenY - 24)\n Help = touch.rect(tx, ty, ScreenX*.5 + 72, ScreenY - 96, (ScreenX*.5 - 128) + 72, ScreenY - 24)\nend","Applications\/CubotsMarch!\/save.data":"2\n2\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n","mods.lua":"--Version 2.0\n--External Modules\npcall(function()\n lfs = require \"lfs\"\nend)\n--Plugins\ninf = math.huge\nout = {}\noutput = {}\n\nfunction ischar(str, i, char)\n return string.sub(str, i, i) == char and true or false\nend\n\nfunction string.mult(str, times)\n str = tostring(str)\n local s = \"\"\n for i = 1, times do\n s = s..str\n end\n return s\nend\n\nfunction string.div(str, num)\n return string.sub(str, 1, #str\/num)\nend\n\nfunction string.remspace(str)\n for i = 1, #str do\n if string.sub(str, i, i) == \" \" then\n str = string.sub(str, 1, i-1)..string.sub(str, i+1, #str)\n end\n end\n return str\nend\n\nfunction find(chars, str)\n local sec\n for i = 1, #str do\n sec = string.sub(str, i, i+#chars-1)\n if sec == chars then\n return i, i+#chars-1\n end\n end\nend\n\nfunction round(num)\n num = tostring(num)\n for i = 1, #num do\n if string.sub(num, i, i) == \".\" then\n if tonumber(string.sub(num, i+1, #num)) < tonumber(string.mult(\"5\", #num - i)) then\n num = string.sub(num, 1, i-1)\n return tonumber(num)\n else\n num = string.sub(num, 1, i-1)\n return tonumber(num)+1\n end\n end\n end\n return tonumber(num)\nend\n\n--[\nfunction echo(str, tim)\n if not tim then\n tim = 1\n end\n sys.println(string.mult(str, tim))\nend\n--]]\n\nfunction os.execute(code)\n rewrite(\"Execution.lua\", code)\n require \"Execution\"\n --clearSave(\"Execution.lua\")\n remove(\"Execution.lua\")\nend\n\nfunction table.print(tab)\n for i, v in pairs(tab) do\n print(v)\n end\nend\n\nfunction wait(num)\n num = num*1000\n sys.sleep(num)\nend\n\nfunction getfps()\n\nend\n\nfunction output.reset()\n sys.sleep(100)\n clear(output)\n for i, v in pairs(out) do\n for c, e in pairs(v) do\n sys.print(e)\n end\n end\nend\n\nfunction print(...)\n local t = {...}\n table.insert(out, {})\n for i, v in pairs(t) do\n if i > 1 then\n v = \"\\t\"..v\n end\n sys.print(v)\n table.insert(out[#out], v)\n end\n sys.print(\"\\n\")\n table.insert(out[#out], \"\\n\")\nend\n\nfunction remline(ln)\n table.remove(out, ln)\n output.reset()\nend\n\nfunction getline(ln)\n local s = \"\"\n for i, v in pairs(out[ln]) do\n s = s..v\n end\n return s\nend\n\n\n-----------------------------\n\n\n--DrawMods\ndraw.pink = { red = 1, green = 0.7, blue = 0.9, alpha = 1 }\ndraw.babyblue = {red = 0, green = 0.7, blue = 1, alpha = 1}\ndraw.lightBlue = {red = 0, green = 0.9, blue = 1, alpha = 1}\ndraw.beige = {red = 1, green = 1, blue = 0.65, alpha = 1}\ndraw.lightGreen = {red = 0.5, green = 1, blue = 0.5, alpha = 1}\ndraw.lightred= { red = 1, green = 0, blue = 0, alpha = 0.7 }\n\n--Sets up the draw screen\nfunction draw.start(title)\n draw.clear()\n --draw.sleep(1)\n draw.setscreen(1)\n if title then\n draw.settitle(title)\n else\n draw.settitle(\"Title\")\n end\nend\n--Shuts down the draw screen\nfunction draw.stop(endtime)\n if endtime then\n draw.sleep(endtime)\n end\n draw.setscreen(0)\n draw.sleep(1)\n draw.clear()\nend\n--Draw a dot\nfunction draw.dot( x, y, size, color)\n draw.fillcircle( x, y, size, color )\nend\n--Color the background\nfunction draw.colorbackground(color)\n local x, y = draw.getport()\n draw.fillrect(0, 0, x, y, color)\nend\n--outline a rectangle\nfunction draw.outline(x1, y1, x2, y2, size, color)\n if not color then\n color = draw.black\n end\n a = 1\n offset = 1\n while a ~= size do\n draw.roundedrect(x1-offset, y1-offset, x2+offset, y2+offset, 5, color)\n a = a + 1\n offset = offset + 1\n end\nend\n--outline a circle\nfunction draw.coutline(x, y, csize, color, size)\n local offset = 0\n local offsetter = csize\n while offset ~= size do\n offsetter = csize + offset\n draw.circle(x, y, offsetter, color)\n offset = offset + 1\n end\nend\n--test if a rectangle is clicked\nfunction isClicked(sx, sy, ex, ey)\n local width = ex-sx\n local height = ey-sy\n if x > sx and x < sx+width and\n y > sy and y < sy+height then\n return true\n end\n return false\nend\n--draw a square\nfunction draw.square(x, y, size, color)\n local size = size\/2\n draw.rect(x-size, y-size, x+size, y+size, color)\nend\n--draw a filled square\nfunction draw.fillsquare(x, y, size, color)\n local size = size\/2\n draw.fillrect(x-size, y-size, x+size, y+size, color)\nend\n--update the screen width and height with the variables w and h\nfunction draw.update(w, h)\n if not w then\n w = \"width\"\n end\n if not h then\n h = \"height\"\n end\n _G[w], _G[h] = draw.getport()\nend\n\n\n-----------------------------\n\n\n--Save Module\nfunction getlines(tab)\n local lns = 0\n for line in io.lines(tab) do\n lns = lns + 1\n end\n return lns\nend\n\nfunction saveCode(file, code)\n local db = io.open(file, \"a\")\n db:write(code)\n db:flush()\n db:close()\nend\n\nfunction saveVar(file, nam, val)\n local db = io.open(file, \"a\")\n if type(val) ~= \"table\" then\n if type(val) ~= \"string\" then\n db:write(nam..\" = \"..val..\" \\n\")\n else\n db:write(nam..' = \"'..val..'\"'..\" \\n\")\n end\n else\n db:write(nam..\" = {} \\n\")\n for i, v in pairs(val) do\n if type(v) ~= \"string\" then\n db:write(nam..\"[\"..i..\"] = \"..v..\" \\n\")\n else\n db:write(nam..\"[\"..i..'] = \"'..v..'\"'..\" \\n\")\n end\n end\n end\n db:flush()\n db:close()\nend\n\nfunction rewrite(file, code)\n local db = io.open(file, \"w\")\n db:write(code)\n db:flush()\n db:close()\nend\n\nfunction remove(file)\n os.remove(file)\nend\n\nfunction clearSave(tab)\n local db = io.open(tab, \"w\")\n db:flush()\nend","LAMAPI\/filebrowser.lua":"local browser = {}\nbrowser.viewmode = \"thumbnails\"\nbrowser.imagesizes = {}\nbrowser.history = {}\nbrowser.curpoint = 0\nScreenX, ScreenY = draw.getport()\nlocal imagesperrow = math.floor((ScreenX - 48)\/96)\n\nlfs = require \"lfsplus\"\nif not Key then Key = require \"keyboard\" end\nindex = require \"index\"\n\n-- Cache Images\ndraw.cacheimage(\"@resources\/LAMUnknownFile.png\")\ndraw.cacheimage(\"@resources\/LAMSoundFile.png\")\ndraw.cacheimage(\"@resources\/LAMScriptFile.png\")\ndraw.cacheimage(\"@resources\/LAMFolder.png\")\ndraw.cacheimage(\"@resources\/LAMInstallFold.png\")\ndraw.cacheimage(\"@resources\/LAMInboxFold.png\")\ndraw.cacheimage(\"@resources\/LAMMail.png\")\n\nfunction draw.box(x, y, sx, sy, color)\n draw.rect(x, y, x + sx, y + sy, color)\nend\n\nfunction draw.fillbox(x, y, sx, sy, color)\n draw.fillrect(x, y, x + sx, y + sy, color)\nend\n\nfunction browser.ScrollBar(Scroll, Max)\n local ScreenY = ScreenY - 108\n local Size = math.max((ScreenY\/Max)*(ScreenY\/3.3333), 48)\n if Max <= 0 then\n Size = ScreenY\n end\n draw.fillrect(ScreenX - 48, (Scroll\/Max)*(ScreenY - Size) + 64, ScreenX, (((Scroll\/Max)*(ScreenY - Size)) + Size) + 64, Color or draw.blue)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY + 64, draw.black)\n draw.rect(ScreenX - 48, 0, ScreenX, ScreenY + 64, draw.black)\nend\n\nfunction browser.draw(title, files)\n local imagesizes = browser.imagesizes\n local Scroll = ScrollY - 16\n draw.beginframe()\n draw.clear()\n local loc -- Location\n if browser.viewmode == \"list\" then\n for k, v in ipairs(files) do\n if (k*48) - Scroll > -48 and ((k*48) - Scroll) + 48 < ScreenY + 48 then\n draw.line(0, (k*48) - Scroll, ScreenX - 48, (k*48) - Scroll, Color)\n if SelectedFile == k then\n draw.fillrect(0, (k*48) - Scroll, ScreenX - 48, ((k + 1)*48) - Scroll, Color)\n end\n draw.string(v, 0, ((k*48) - Scroll), draw.black)\n if v ~= \"..\" then\n if type(sizes[k]) == \"number\" then\n draw.string(tostring(sizes[k]).. \" bytes\", 0, ((k*48) - Scroll) + 24, draw.black)\n if updated[k] then\n if ScreenX > 360 then\n draw.string(\"Last Updated on \"..os.date(\"%B %d, %Y\", updated[k]), 128, ((k*48) - Scroll) + 24, draw.black)\n else\n draw.string(os.date(\"%B %d, %Y\", updated[k]), 128, ((k*48) - Scroll) + 24, draw.black)\n end\n end\n else\n draw.string(tostring(sizes[k]), 0, ((k*48) - Scroll) + 24, draw.black)\n end\n else\n if string.find(string.reverse(location), \"\/\") then\n draw.string(string.sub(location, 0, #location - string.find(string.reverse(location), \"\/\")), 0, ((k*48) - Scroll) + 24, draw.black)\n end\n end\n end\n end\n elseif browser.viewmode == \"thumbnails\" then\n for k, v in ipairs(files) do\n local column = ((k - 1)\/imagesperrow - math.floor((k - 1)\/imagesperrow))*imagesperrow\n local x = (column*96)\n local y = ((math.floor((k - 1)\/imagesperrow) + 1)*128) - 80\n if y - Scroll > -32 and y - Scroll < ScreenY + 128 then\n if not searchMode then\n loc = location..\"\/\"..v\n else\n loc = v\n end\n if SelectedFile == k then\n draw.fillbox(x, y - Scroll, 96, 128, draw.blue)\n end\n if imagesizes[loc] then\n draw.transformedimage(loc, x + 48, (y + 48) - Scroll, 96\/math.max(imagesizes[loc][1], imagesizes[loc][2]), 0)\n elseif type(sizes[k]) == \"number\" then\n if string.sub(loc, -4) == \".lua\" then\n draw.transformedimage(\"@resources\/LAMScriptFile.png\", x + 48, y + 48 - Scroll, 2, 0)\n elseif string.sub(loc, -4) == \".mp3\" then\n draw.transformedimage(\"@resources\/LAMSoundFile.png\", x + 48, y + 48 - Scroll, 2, 0)\n else\n draw.transformedimage(\"@resources\/LAMUnknownFile.png\", x + 48, y + 48 - Scroll, 2, 0)\n end\n else -- Draw Folder Icon\n draw.transformedimage(\"@resources\/LAMFolder.png\", x + 48, y + 48 - Scroll, 2, 0)\n end\n if v ~= \"..\" then\n draw.stringinrect(v, x, y + 96 - Scroll, x + 96, y + 128 - Scroll, draw.black)\n else\n draw.stringinrect(\"Back\", x, y + 96 - Scroll, x + 96, y + 128 - Scroll, draw.black)\n end\n end\n end\n end\n browser.ScrollBar(ScrollY, ScrollMax)\n draw.fillrect(0, 0, ScreenX, 64, draw.gray)\n draw.setfont(\"Arial\", 24)\n draw.fillroundedrect(98, 32, ScreenX - 98, 62, 4, draw.white)\n --draw.stringinrect(title, 0, 24, ScreenX, 48, draw.black)\n draw.string(location, 100, 32, draw.black)\n draw.fillrect(ScreenX - 128, ScreenY - 48, ScreenX, ScreenY, draw.gray)\n draw.stringinrect(\"Cancel\", ScreenX - 128, ScreenY - 36, ScreenX, ScreenY, draw.black)\n draw.fillrect(ScreenX - 256, ScreenY - 48, ScreenX - 128, ScreenY, draw.lightgray)\n draw.setfont(\"Arial\", 16)\n if browser.viewmode == \"list\" then\n draw.stringinrect(\"Show as Thumbnails\", ScreenX - 256, ScreenY - 42, ScreenX - 128, ScreenY, draw.black)\n else\n draw.stringinrect(\"Show as List\", ScreenX - 256, ScreenY - 32, ScreenX - 128, ScreenY, draw.black)\n end\n if savemode then\n draw.fillrect(ScreenX - 352, ScreenY - 48, ScreenX - 256, ScreenY, draw.blue)\n draw.stringinrect(\"Save New File\", ScreenX - 352, ScreenY - 32, ScreenX - 256, ScreenY, draw.black)\n end\n if browser.curpoint > 1 then\n draw.transformedimage(\"@resources\/LAMBack.png\", 24, 48, 1.75, 0)\n end\n if browser.curpoint < #browser.history then\n draw.transformedimage(\"@resources\/LAMForward.png\", 72, 48, 1.75, 0)\n end\n draw.transformedimage(\"@resources\/LAMInstallFold.png\", ScreenX - 72, 48, .75, 0)\n draw.transformedimage(\"@resources\/LAMMail.png\", ScreenX - 24, 48, .75, 0)\n draw.setfont(\"Arial\", 16)\n draw.endframe()\nend\n\nfunction browser.starttouch(x, y)\n if x > ScreenX - 48 then\n Scrolling = true\n else\n Scrolling = false\n end\nend\n\nfunction browser.touch(x, y)\n y = y - 48\n local ScreenY = ScreenY - 96\n if Scrolling and ScrollMax > 0 then\n local Size = math.max((ScreenY\/ScrollMax)*(ScreenY\/3.3333), 48)\n if ScrollMax <= 0 then\n Size = ScreenY\n end\n ScrollY = ((y - (Size*.5))*ScrollMax)\/(ScreenY - Size), 0\n if ScrollY < 0 then\n ScrollY = 0\n elseif ScrollY > ScrollMax + ScreenY then\n ScrollY = ScrollMax + ScreenY\n end\n end\nend\n\nfunction browser.endtouch(x, y)\n local Scroll = ScrollY - 64\n if y < 48 then ScrollY = 0 end\n if not Scrolling then\n if browser.viewmode == \"list\" then\n for k, v in ipairs(browser.files) do\n if (k*ButtonHeight) - Scroll >= y and ((k - 1)*ButtonHeight) - Scroll <= y then\n if SelectedFile == k then\n if v == \"..\" then\n if string.find(string.reverse(location), \"\/\") then\n location = string.sub(location, 0, #location - string.find(string.reverse(location), \"\/\"))\n browser.history[browser.curpoint + 1] = location\n browser.curpoint = browser.curpoint + 1\n browser.reloadlocation()\n else\n location = \"..\/..\/\"\n browser.reloadlocation()\n end\n elseif sizes[k] == \"Folder\" then\n location = location..\"\/\"..v\n browser.history[browser.curpoint + 1] = location\n browser.curpoint = browser.curpoint + 1\n browser.reloadlocation()\n else\n if searchMode then\n browser.running = v\n else\n browser.running = location..\"\/\"..v\n end\n end\n else\n SelectedFile = k\n end\n end\n end\n elseif browser.viewmode == \"thumbnails\" then\n for k, v in ipairs(browser.files) do\n local column = ((k - 1)\/imagesperrow - math.floor((k - 1)\/imagesperrow))*imagesperrow\n local x1 = (column*96)\n local y1 = ((math.floor((k - 1)\/imagesperrow))*128)\n if x > x1 and y > y1 - Scroll and x < x1 + 96 and y < (y1 + 128) - Scroll then\n if SelectedFile == k then\n if v == \"..\" then\n if string.find(string.reverse(location), \"\/\") then\n location = string.sub(location, 0, #location - string.find(string.reverse(location), \"\/\"))\n browser.history[browser.curpoint + 1] = location\n browser.curpoint = browser.curpoint + 1\n browser.reloadlocation()\n else\n location = \"..\/..\/\"\n browser.reloadlocation()\n end\n elseif sizes[k] == \"Folder\" then\n location = location..\"\/\"..v\n browser.history[browser.curpoint + 1] = location\n browser.curpoint = browser.curpoint + 1\n browser.reloadlocation()\n else\n if savemode then\n if overwriteprompt() then\n browser.running = location..\"\/\"..v\n end\n else\n if searchMode then\n browser.running = v\n else\n browser.running = location..\"\/\"..v\n end\n end\n end\n else\n SelectedFile = k\n end\n end\n end\n end\n if x > ScreenX - 128 and y > ScreenY - 48 then\n browser.running = false\n elseif x > ScreenX - 256 and y > ScreenY - 48 then\n if browser.viewmode == \"list\" then\n browser.viewmode = \"thumbnails\"\n else\n browser.viewmode = \"list\"\n end\n elseif x > ScreenX - 352 and y > ScreenY - 48 then\n if savemode then\n local SaveLocation = Key.Keyboard(\"Save As\", \"\")\n if SaveLocation then\n browser.running = SaveLocation\n end\n end\n end\n end\n if y < 48 and x < 48 then -- Go Back\n if browser.curpoint > 1 then\n location = browser.history[browser.curpoint - 1]\n browser.curpoint = browser.curpoint - 1\n browser.reloadlocation()\n end\n elseif y < 48 and x < 96 then -- Go Forward\n if browser.curpoint < #browser.history then\n location = browser.history[browser.curpoint + 1]\n browser.curpoint = browser.curpoint + 1\n browser.reloadlocation()\n end\n elseif y < 48 and x < ScreenX - 48 then\n location = \"@search \"..Key.Keyboard(\"search\")\n browser.reloadlocation()\n end\n if y < 48 and x > ScreenX - 48 then\n location = \"..\/..\/Documents\/Inbox\"\n browser.reloadlocation()\n elseif y < 48 and x > ScreenX - 96 then\n location = \"..\/..\/Documents\/AALuaAppManager\"\n browser.reloadlocation()\n end\nend\n\nfunction browser.reloadlocation(default)\n collectgarbage(\"stop\")\n if string.find(location, \"@search \") then\n files, sizes, updated = index.searchFiles(string.sub(location, 8, -1)), {}, {}\n searchMode = \"search\"\n elseif string.find(location, \"@find \") then\n files, sizes, updated = index.searchFileNames(string.sub(location, 6, -1)), {}, {}\n searchMode = \"find\"\n else\n files, sizes, updated = sys.dir(location), {}, {}\n searchMode = nil\n end\n browser.files = files\n if not files then\n if default then\n error(errlocation..\" is not a folder, and the default location was unable to be accessed.\", 2)\n else\n errlocation = location\n location = \"\"\n browser.reloadlocation(true)\n return\n end\n end\n if browser.viewmode == \"list\" then\n ScrollMax = math.max((#files*ButtonHeight) - (ScreenY - 96), 0)\n elseif browser.viewmode == \"thumbnails\" then\n ScrollMax = math.max((math.ceil(#files\/imagesperrow)*128) - (ScreenY - 96), 0)\n end\n table.remove(files, 1)\n local location = location\n if searchMode then\n for k, v in ipairs(files) do\n if v ~= \"..\" then\n if lfs.isDirectory(v) then\n sizes[k] = \"Folder\"\n else\n File = lfs.isFile(v)\n if File then\n sizes[k] = lfs.fileSize(v)\n updated[k] = lfs.lastUpdated(v)\n else\n sizes[k] = \"Folder\"\n end\n if string.sub(v, #v - 3, #v) == \".png\" then -- If an image file\n local sx, sy = draw.cacheimage(v)\n browser.imagesizes[v] = {sx, sy}\n end\n end\n end\n end\n else\n for k, v in ipairs(files) do\n if v ~= \"..\" then\n if lfs.isDirectory(location..\"\/\"..v) then\n sizes[k] = \"Folder\"\n else\n File = lfs.isFile(location..\"\/\"..v)\n if File then\n sizes[k] = lfs.fileSize(location..\"\/\"..v)\n updated[k] = lfs.lastUpdated(location..\"\/\"..v)\n else\n sizes[k] = \"Folder\"\n end\n if string.sub(v, #v - 3, #v) == \".png\" then -- If an image file\n local sx, sy = draw.cacheimage(location..\"\/\"..v)\n browser.imagesizes[location..\"\/\"..v] = {sx, sy}\n end\n end\n end\n end\n end\n collectgarbage()\nend\n\nfunction browser.loadfile(title, default, save)\n savemode = save\n if not title then title = \"\" end\n browser.running = true\n SelectedFile = 0\n draw.setscreen(1)\n location = default or \"\"\n browser.reloadlocation()\n ScrollY = 0\n while browser.running == true do\n draw.tracktouches(browser.starttouch, browser.touch, browser.endtouch)\n if browser.viewmode == \"list\" then\n ScrollMax = math.max((#browser.files*ButtonHeight) - (ScreenY - 96), 0)\n elseif browser.viewmode == \"thumbnails\" then\n ScrollMax = math.max((math.ceil(#browser.files\/imagesperrow)*128) - (ScreenY - 96), 0)\n end\n browser.draw(title, files, ScrollY)\n draw.doevents()\n end\n return browser.running\nend\n\nreturn browser","Applications\/Help\/Book":"nil","Applications\/SampleApp":"nil","LAMAPI\/keyboard.lua":"local ckey = {}\nKey = ckey\n\nfunction ckey.makeTappedSound()\n sys.alert(\"tock\")\nend\n\nfunction ckey.drawkey(str, x, y, xs, ys, color)\n draw.fillroundedrect(x, y, x + xs, y + ys, 6, color or draw.white)\n local stszx, stszy = draw.stringsize(str)\n draw.string(str, x + (xs - stszx)*.5, y + (ys - stszy)*.5, draw.black)\nend\n\nckey.x, ckey.y = 0, 0\nckey.xs, ckey.ys = 480, 160\nckey.slidetime = .4\nckey.curtext = \"\"\nckey.curpos = 0\nckey.mode = 0\nckey.row1 = {\"q\", \"w\", \"e\", \"r\", \"t\", \"y\", \"u\", \"i\", \"o\", \"p\"}\nckey.row2 = {\"a\", \"s\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\"}\nckey.row3 = {\"z\", \"x\", \"c\", \"v\", \"b\", \"n\", \"m\"}\nckey.nrow1 = {\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\"}\nckey.nrow2 = {\"-\", \"\/\", \":\", \";\", \"(\", \")\", \"$\", \"&\", \"@\", '\"'}\nckey.nrow3 = {\".\", \",\", \"?\", \"!\", \"'\"}\nckey.nrow4 = {\"[\", \"]\", \"{\", \"}\", \"#\", \"%\", \"^\", \"*\", \"+\", \"=\"}\nckey.nrow5 = {\"_\", \"\\\\ \", \"|\", \"~\", \"<\", \">\", \"€\", \"£\", \"¥\", \"•\"}\n\nfunction ckey.getRows()\n local row1, row2, row3 = ckey.row1, ckey.row2, ckey.row3\n if ckey.mode == 1 then\n row1 = ckey.nrow1\n row2 = ckey.nrow2\n row3 = ckey.nrow3\n elseif ckey.mode == 2 then\n row1 = ckey.nrow4\n row2 = ckey.nrow5\n row3 = ckey.nrow3\n elseif ckey.mode == 3 then\n row3 = ckey.nrow3\n end\n return row1, row2, row3\nend\n\nlocal ipairs = ipairs\n\nfunction ckey.drawKeyboard(x, y, xs, ys)\n x, y = x or ckey.x, y or ckey.y\n xs, ys = xs or ckey.xs, ys or ckey.ys\n draw.fillrect(x, y, x + xs, y + ys, draw.lightgray)\n local row1, row2, row3 = ckey.getRows()\n local r2s = ((#row1 - #row2)\/#row1)*(xs - 8)*.5\n local r3s = ((#row1 - #row3)\/#row1)*(xs - 8)*.5\n local wid = (1\/#row1)*xs - 6\n -- Draw Keys\n if ckey.mode < 3 then\n for k, v in ipairs(row1) do\n ckey.drawkey(v, 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4, wid, ys*.25 - 8)\n end\n for k, v in ipairs(row2) do\n ckey.drawkey(v, r2s + 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4 + (ys*.25), wid, ys*.25 - 8)\n end\n for k, v in ipairs(row3) do\n ckey.drawkey(v, r3s + 6 + x + ((k - 1)\/#row1)*(xs - 6), y + 4 + (ys*.5), wid, ys*.25 - 8)\n end\n ckey.drawkey(\"Shift\", 6 + x, y + 4 + (ys*.5), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n -- Draw Command Keys\n ckey.drawkey(\"Backs\", 6 + x + (xs - 6 - r3s), y + 4 + (ys*.5), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n ckey.drawkey(\"123\", 6 + x, y + 4 + (ys*.75), r3s - 6, ys*.25 - 8, draw.gray, draw.white)\n ckey.drawkey(\"•\", r3s + 6 + x + ((0)\/#ckey.row1)*(xs - 6), y + 4 + (ys*.75), (1\/#ckey.row1)*xs - 6, ys*.25 - 8)\n else\n\n end\n -- Draw global keys\n ckey.drawkey(\"Go\", 6 + x + (xs - 6 - r3s), y + 4 + (ys*.75), r3s - 6, ys*.25 - 8, draw.blue, draw.white)\n if ckey.mode == 0 then\n ckey.drawkey(\"space\", r3s + 6 + x + ((1)\/#ckey.row1)*(xs - 6), y + 4 + (ys*.75), (5\/#ckey.row1)*xs - 6, ys*.25 - 8)\n else\n ckey.drawkey(\"space\", r3s + 6 + x + ((1)\/#ckey.row1)*(xs - 6), y + 4 + (ys*.75), (4\/#ckey.row1)*xs - 6, ys*.25 - 8)\n end\nend\n\nfunction ckey.tappedKey(tx, ty)\n local xs, ys = ckey.xs, ckey.ys\n local row1, row2, row3 = ckey.getRows()\n local r2s = ((#row1 - #row2)\/#row1)*(xs - 8)*.5\n local r3s = ((#row1 - #row3)\/#row1)*(xs - 8)*.5\n local keytapped, keytappedvalue, rowtapped\n if ty > ckey.y and ty < ckey.y + ys*.25 then\n keytapped = math.floor(tx\/((1\/#row1)*(xs + 6))) + 1\n keytappedvalue = row1[keytapped]\n rowtapped = 1\n elseif ty > ckey.y + ys*.25 and ty < ckey.y + ys*.5 then\n if ckey.mode == 0 then\n keytapped = math.floor(((tx - r2s + 6)\/((1\/#row2)*xs)) + .5) + 1\n else\n keytapped = math.floor(((tx - r2s + 6)\/((1\/#row2)*xs))) + 1\n end\n keytappedvalue = row2[keytapped]\n rowtapped = 2\n elseif ty > ckey.y + ys*.5 and ty < ckey.y + ys*.75 then\n keytapped = math.floor(tx\/((1\/#row1)*(xs + 6)))\n if ckey.mode > 0 then\n keytapped = keytapped - 1\n end\n keytappedvalue = row3[keytapped]\n rowtapped = 3\n elseif ty > ckey.y + ys*.75 and ty < ckey.y + ys then\n keytapped = math.floor((tx - r3s)\/((1\/#row3)*(xs - 6))) + 1\n rowtapped = 4\n end\n ckey.keytapped, ckey.keytappedvalue, ckey.rowtapped = keytapped, keytappedvalue, rowtapped\nend\n\nfunction ckey.begintouch(x, y)\n ckey.tappedKey(x, y)\nend\n\nfunction ckey.touch(x, y)\n ckey.tappedKey(x, y)\nend\n\nfunction ckey.endtouch(x, y)\n ckey.tappedKey(x, y)\n local row1, row2, row3 = ckey.getRows()\n if ckey.keytapped then\n if ckey.rowtapped == 3 then\n if ckey.mode == 0 and ckey.keytapped <= 0 then\n ckey.shift = not shift\n elseif ckey.keytapped > #row3 then\n ckey.curtext = string.sub(ckey.curtext, 0, #ckey.curtext - 1)\n elseif ckey.keytappedvalue then\n ckey.curtext = ckey.curtext .. ckey.keytappedvalue\n ckey.makeTappedSound()\n end\n elseif ckey.rowtapped == 4 then\n if ckey.keytapped <= 0 then\n if ckey.mode >= 2 then\n ckey.mode = 0\n else\n ckey.mode = ckey.mode + 1\n end\n elseif ckey.keytapped == 1 then\n ckey.curtext = ckey.curtext .. \"•\"\n ckey.makeTappedSound()\n elseif ckey.keytapped < 6 then\n ckey.curtext = ckey.curtext .. \" \"\n ckey.makeTappedSound()\n else\n ckey.returnNow = ckey.curtext\n end\n elseif ckey.keytappedvalue then\n ckey.curtext = ckey.curtext .. ckey.keytappedvalue\n ckey.makeTappedSound()\n end\n\n end\nend\n\nfunction ckey.keyboard(title, defaulttext)\n draw.tracktouches(ckey.begintouch, ckey.touch, ckey.endtouch)\n local scwidth, scheight = draw.getport()\n local begintime = sys.gettime()\n ckey.returnNow = nil\n draw.setfont(\"Arial\", 20)\n draw.settitle(title)\n ckey.curtext = defaulttext or \"\"\n while not ckey.returnNow do\n if sys.gettime() < begintime + ckey.slidetime then\n ckey.y = scheight - (ckey.ys* ((sys.gettime() - begintime)\/ckey.slidetime))\n else\n ckey.y = scheight - ckey.ys\n end\n draw.doevents()\n draw.beginframe()\n draw.clear()\n ckey.drawKeyboard()\n draw.string(ckey.curtext, 0, 24, draw.black)\n draw.endframe()\n end\n draw.setfont(\"Arial\", 16)\n return ckey.returnNow\nend\n\nckey.Keyboard = ckey.keyboard\n\nreturn ckey","Applications\/BlockGame\/ExportApp.lua":"print('Generating Installer Stubs!')\nlocal FileTable = {}\n\nfunction requireFromRoot(File)\n local Handle, err = io.open(\"..\/\"..File..\".lua\")\n local String, Funct = \"\", nil\n if Handle then\n String = \"require = requireFromRoot\\n\"..Handle:read(\"*a\")\n Handle:close()\n Funct = load(String)\n end\n --local Funct, err = loadfile(\"..\"..File..\".lua\")\n if Funct then\n local var1 = Funct()\n require = Require\n return var1 or true\n else\n print(err)\n end\nend\n\nlfs = require \"lfs\"\n\nJSON = require(\"JSON\")\nlocal files = sys.dir()\n\nfunction lfs.isDirectory(Path)\n return lfs.attributes(Path, \"mode\") == \"directory\"\nend\n\nfor k, v in ipairs(files) do\n if v ~= \".\" and v ~= \"..\" and v ~= \"InstallStub\" and v~= \"SavedData\" and v~= \"Resources\" then\n if lfs.isDirectory(v) then\n local sub = sys.dir(v)\n for k2, v2 in ipairs(sub) do\n if v2 ~= \".\" and v2 ~= \"..\" and string.sub(v, -8)~=\"stub.lua\" then\n files[#files + 1] = v..\"\/\"..v2\n end\n end\n end\n end\nend\n\nfor k, v in ipairs(files) do\n if v ~= \".\" and v ~= \"..\" and string.sub(v, -8)~=\"stub.lua\" then\n local file = io.open(v)\n if file then\n FileTable[v] = file:read(\"*a\")\n file:close()\n end\n end\nend\n\n\nlocal String = JSON.EncodeJSON(FileTable)\nprint(#String..\" bytes\")\n\nif not lfs.isDirectory(\"InstallStub\") then\n lfs.mkdir(\"InstallStub\")\nend\n\nprint(\"Saving...\")\nlocal Chunk = 8192*16\nfor i=1, math.ceil(#String\/Chunk) do\n file = io.open(\"InstallStub\/TouchLuaBuilder\".. i..\"stub.lua\", \"w\")\n file:write(string.sub(String, ((i - 1)*Chunk) + 1, math.min(i*Chunk, #String)))\n file:close()\nend\nprint(\"Done!\")","LAMAPI\/Mods.lua":"--Version 2.0\n--External Modules\npcall(function()\n lfs = require \"lfs\"\nend)\n--Plugins\ninf = math.huge\nout = {}\noutput = {}\n\nfunction ischar(str, i, char)\n return string.sub(str, i, i) == char and true or false\nend\n\nfunction string.mult(str, times)\n str = tostring(str)\n local s = \"\"\n for i = 1, times do\n s = s..str\n end\n return s\nend\n\nfunction string.div(str, num)\n return string.sub(str, 1, #str\/num)\nend\n\nfunction string.remspace(str)\n for i = 1, #str do\n if string.sub(str, i, i) == \" \" then\n str = string.sub(str, 1, i-1)..string.sub(str, i+1, #str)\n end\n end\n return str\nend\n\nfunction find(chars, str)\n local sec\n for i = 1, #str do\n sec = string.sub(str, i, i+#chars-1)\n if sec == chars then\n return i, i+#chars-1\n end\n end\nend\n\nfunction round(num)\n num = tostring(num)\n for i = 1, #num do\n if string.sub(num, i, i) == \".\" then\n if tonumber(string.sub(num, i+1, #num)) < tonumber(string.mult(\"5\", #num - i)) then\n num = string.sub(num, 1, i-1)\n return tonumber(num)\n else\n num = string.sub(num, 1, i-1)\n return tonumber(num)+1\n end\n end\n end\n return tonumber(num)\nend\n\n--[\nfunction echo(str, tim)\n if not tim then\n tim = 1\n end\n sys.println(string.mult(str, tim))\nend\n--]]\n\nfunction os.execute(code)\n rewrite(\"Execution.lua\", code)\n require \"Execution\"\n --clearSave(\"Execution.lua\")\n remove(\"Execution.lua\")\nend\n\nfunction table.print(tab)\n for i, v in pairs(tab) do\n print(v)\n end\nend\n\nfunction wait(num)\n num = num*1000\n sys.sleep(num)\nend\n\nfunction getfps()\n\nend\n\nfunction output.reset()\n sys.sleep(100)\n clear(output)\n for i, v in pairs(out) do\n for c, e in pairs(v) do\n sys.print(e)\n end\n end\nend\n\nfunction print(...)\n local t = {...}\n table.insert(out, {})\n for i, v in pairs(t) do\n if i > 1 then\n v = \"\\t\"..v\n end\n sys.print(v)\n table.insert(out[#out], v)\n end\n sys.print(\"\\n\")\n table.insert(out[#out], \"\\n\")\nend\n\nfunction remline(ln)\n table.remove(out, ln)\n output.reset()\nend\n\nfunction getline(ln)\n local s = \"\"\n for i, v in pairs(out[ln]) do\n s = s..v\n end\n return s\nend\n\n\n-----------------------------\n\n\n--DrawMods\ndraw.pink = { red = 1, green = 0.7, blue = 0.9, alpha = 1 }\ndraw.babyblue = {red = 0, green = 0.7, blue = 1, alpha = 1}\ndraw.lightBlue = {red = 0, green = 0.9, blue = 1, alpha = 1}\ndraw.beige = {red = 1, green = 1, blue = 0.65, alpha = 1}\ndraw.lightGreen = {red = 0.5, green = 1, blue = 0.5, alpha = 1}\ndraw.lightred= { red = 1, green = 0, blue = 0, alpha = 0.7 }\n\n--Sets up the draw screen\nfunction draw.start(title)\n draw.clear()\n --draw.sleep(1)\n draw.setscreen(1)\n if title then\n draw.settitle(title)\n else\n draw.settitle(\"Title\")\n end\nend\n--Shuts down the draw screen\nfunction draw.stop(endtime)\n if endtime then\n draw.sleep(endtime)\n end\n draw.setscreen(0)\n draw.sleep(1)\n draw.clear()\nend\n--Draw a dot\nfunction draw.dot( x, y, size, color)\n draw.fillcircle( x, y, size, color )\nend\n--Color the background\nfunction draw.colorbackground(color)\n local x, y = draw.getport()\n draw.fillrect(0, 0, x, y, color)\nend\n--outline a rectangle\nfunction draw.outline(x1, y1, x2, y2, size, color)\n if not color then\n color = draw.black\n end\n a = 1\n offset = 1\n while a ~= size do\n draw.roundedrect(x1-offset, y1-offset, x2+offset, y2+offset, 5, color)\n a = a + 1\n offset = offset + 1\n end\nend\n--outline a circle\nfunction draw.coutline(x, y, csize, color, size)\n local offset = 0\n local offsetter = csize\n while offset ~= size do\n offsetter = csize + offset\n draw.circle(x, y, offsetter, color)\n offset = offset + 1\n end\nend\n--test if a rectangle is clicked\nfunction isClicked(sx, sy, ex, ey)\n local width = ex-sx\n local height = ey-sy\n if x > sx and x < sx+width and\n y > sy and y < sy+height then\n return true\n end\n return false\nend\n--draw a square\nfunction draw.square(x, y, size, color)\n local size = size\/2\n draw.rect(x-size, y-size, x+size, y+size, color)\nend\n--draw a filled square\nfunction draw.fillsquare(x, y, size, color)\n local size = size\/2\n draw.fillrect(x-size, y-size, x+size, y+size, color)\nend\n--update the screen width and height with the variables w and h\nfunction draw.update(w, h)\n if not w then\n w = \"width\"\n end\n if not h then\n h = \"height\"\n end\n _G[w], _G[h] = draw.getport()\nend\n\n\n-----------------------------\n\n\n--Save Module\nfunction getlines(tab)\n local lns = 0\n for line in io.lines(tab) do\n lns = lns + 1\n end\n return lns\nend\n\nfunction saveCode(file, code)\n local db = io.open(file, \"a\")\n db:write(code)\n db:flush()\n db:close()\nend\n\nfunction saveVar(file, nam, val)\n local db = io.open(file, \"a\")\n if type(val) ~= \"table\" then\n if type(val) ~= \"string\" then\n db:write(nam..\" = \"..val..\" \\n\")\n else\n db:write(nam..' = \"'..val..'\"'..\" \\n\")\n end\n else\n db:write(nam..\" = {} \\n\")\n for i, v in pairs(val) do\n if type(v) ~= \"string\" then\n db:write(nam..\"[\"..i..\"] = \"..v..\" \\n\")\n else\n db:write(nam..\"[\"..i..'] = \"'..v..'\"'..\" \\n\")\n end\n end\n end\n db:flush()\n db:close()\nend\n\nfunction rewrite(file, code)\n local db = io.open(file, \"w\")\n db:write(code)\n db:flush()\n db:close()\nend\n\nfunction remove(file)\n os.remove(file)\nend\n\nfunction clearSave(tab)\n local db = io.open(tab, \"w\")\n db:flush()\nend","Applications\/RegistryEditor":"nil"}
|
|