Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- [ "apis/novaio/" ] = {
- content = "local str = \"\"\
- local active = true\
- local inputindex = #str\
- local function setStartStr(nstr)\
- \009str = nstr\
- end\
- function read(e,maxlen,mslen,x,y)\
- \009term.setCursorBlink(active)\
- \009local function drawstr()\
- \009\009term.setCursorPos(x,y)\
- \009\009write(string.rep(\" \",mslen+1))\
- \009\009term.setCursorPos(x,y)\
- \009\009if(#str > mslen)then\
- \009\009\009local dif = #str - mslen\
- \009\009\009if(inputindex <= dif)then\
- \009\009\009\009write(str:sub(inputindex,mslen+inputindex))\
- \009\009\009else\
- \009\009\009\009write(str:sub(dif,mslen+dif))\
- \009\009\009end\
- \009\009else\
- \009\009\009write(str)\
- \009\009end\
- \009\009if(inputindex > mslen)then\
- \009\009\009term.setCursorPos(x+inputindex-(#str-mslen),y)\
- \009\009else\
- \009\009\009term.setCursorPos(x+inputindex,y)\
- \009\009end\
- \009end\
- \009local function undrawstr()\
- \009\009term.setCursorPos(x,y)\
- \009\009write(string.rep(\" \",mslen))\
- \009end\
- \009local function updatestr()\
- \009\009inputindex = inputindex + 1\
- \009\009drawstr()\
- \009end\
- \009if(active)then\
- \009\009if(e[1] == \"char\" and #str < maxlen)then\
- \009 str = str:sub(1,inputindex) .. tostring(e[2]) .. str:sub(inputindex+1,#str)\
- \009updatestr()\
- \009\009end\
- \009\009if(e[1] == \"key\")then\
- \009\009\009local key = e[2]\
- \009\009\009 if(key == keys.enter)then\
- \009\009\009 \009term.setCursorBlink(false)\
- \009\009\009 \009active = false\
- \009\009\009 \009return true\
- \009\009\009 end\
- \009\009\009 if(key == keys.backspace and inputindex > 0)then\
- \009\009\009 \009 undrawstr()\
- \009\009\009 \009 str = string.sub( str, 1, inputindex - 1 ) .. string.sub( str, inputindex + 1 )\
- \009\009\009 \009 inputindex = inputindex - 1\
- \009\009\009 \009 drawstr()\
- \009\009\009 end\
- \009\009\009 if(key == keys.left and inputindex > 0)then\
- \009\009\009 \009 inputindex = inputindex - 1\
- \009\009\009 \009 drawstr()\
- \009\009\009 end\
- \009\009\009 if(key == keys.right and inputindex < #str)then\
- \009\009\009 \009 inputindex = inputindex + 1\
- \009\009\009 \009 drawstr()\
- \009\009\009 end\
- \009\009\009 if(key == keys.delete and inputindex < #str)then\
- \009\009\009 \009 undrawstr()\
- \009\009\009 \009 str = string.sub( str, 1, inputindex ) .. string.sub( str, inputindex + 2 )\
- \009\009\009 \009 drawstr()\
- \009\009\009 end\
- \009\009end\
- \009end\
- \009if(e[1] == \"mouse_click\" and (e[4] ~= y or e[3] < x or e[3] > x+maxlen) )then\
- \009\009active = false\
- \009\009term.setCursorBlink(active)\
- \009elseif(e[1] == \"mouse_click\" and e[4] == y)then\
- \009\009if(not active)then\
- \009\009\009active = true\
- \009\009\009term.setCursorPos(x+inputindex,y)\
- \009\009\009term.setCursorBlink(active)\
- \009\009end\
- \009\009if(e[3]-x >= 0 and e[3]-x <= #str)then\
- \009\009\009inputindex = e[3]-x\
- \009\009\009drawstr()\
- \009\009end\
- \009end\
- end\
- function getInput()\
- \009return str\
- end\
- function resetInput()\
- \009str = \"\"\
- \009inputindex = #str\
- end\
- function setInput(nstr)\
- \009str = nstr\
- \009inputindex = #str\
- end\
- function setActive(act)\
- \009active = act\
- end\
- function getActive()\
- \009return active\
- end",
- },
- [ "users/Test/JDJJD/" ] = {
- content = "",
- },
- [ "programs/novaexplore/" ] = {
- content = "--====================================================\
- --]] Nova Explore and all file apis created by\
- --]] Lewisk3 CEO of Nova, all rights reservered \
- --]] DO NOT REDISTRIBUTE without the permission \
- --]] of Nova, Editing and/or \"rebranding\" is prohibited.\
- --]] Any copys found outside the permission of Nova\
- --]] will be taken and money will be due to the rights\
- --]] of Nova Technologys\
- -------------------------------------------------------\
- --=] We have the rights to all the above [=- \
- --=====================================================\
- --]] Determine OS and load apis accordingly \
- local w, h = term.getSize()\
- local sbc = term.setBackgroundColor\
- local stc = term.setTextColor\
- local scp = term.setCursorPos\
- local clr = term.clear\
- local clrln = term.clearLine\
- local actionkeydown = false\
- local actionkey = keys.leftCtrl\
- local multiselecting = false\
- local diskside = \"right\"\
- files_selected = {}\
- local archiver = \"\"\
- local pa = paintutils\
- local apis = {'ugapi','fpath','futils','novaio'}\
- local pinnednames = {}\
- local innova = true\
- local iscrossbow = false\
- --]] Load apis\
- \009if( fs.isDir(\"CrossBow/apis\") )then\
- \009\009os.loadAPI(\"CrossBow/apis/novautils\")\
- \009else\
- \009\009os.loadAPI(shell.resolveProgram(\"novautils\"))\
- \009end\
- \009novautils.init(shell)\
- \009iscrossbow = novautils.getApisFrom(\"CrossBow/apis\",apis)\
- \009if(iscrossbow)then\
- \009\009archiver = \"CrossBow/programs/novazip\"\
- \009else\
- \009\009if(not shell.resolveProgram(\"novazip\"))then\
- \009\009\009print(\"NovaZIP not found, novaexplore will run with no ZIP viewer. \")\
- \009\009else\
- \009\009\009archiver = shell.resolveProgram(\"novazip\")\
- \009\009end\
- \009end\
- --]] Define variables \
- local file_selected = 0\
- local files = {}\
- -- Path isnt locked\
- local path = fpath.newpath(\"/\")\
- novaio.setActive(false)\
- novaio.setInput(path:getraw())\
- local fileoffs = 0\
- local sideoffs = 0\
- local sidemax = h-1\
- local filemax = h\
- local searching = false\
- local selectedside = 0\
- local search = \"\"\
- local clipboard = {}\
- local inmenu = false\
- local inmenutype = {}\
- local drawingmenu = {}\
- local inmenux, inmenuy = 1, 4\
- local sideitems = {}\
- local pinslocation = \".novapins\"\
- local icons = {\
- \009folder = \"&e[=]\",\
- \009file = \"&7-~-\",\
- \009executable = \"&8:&7=&8:\",\
- \009game = \"&4-&7=&8]\",\
- \009zip = \"&5[&1=&2]\",\
- \009paint = \"&2~&4* \",\
- \009pin = \"&7<&8 \",\
- \009disk= \"&8:&4^&8:\"\
- }\
- --]] Menus \
- filemenu = {\
- \009 {n=\"Open \",func=function(file) openHref(path:getraw() .. file.n) end},\
- \009 {n=\"Edit \",func=function(file) \
- \009 \009editfile(path:getraw() .. file.n)\
- \009 end},\
- \009 {n=\"Open as \",func=function(file) \
- \009 \009local ans = novautils.openYesNo(\"Open File As. \",\"Select open option.*\",novaex_redraw,\"With\", \"Args\")\
- \009 \009if(ans == 1)then -- open with file\
- \009 \009\009local openfile = novautils.openReadDialog(\"Open with another file. \",novaex_redraw)\
- \009 \009\009if(file ~= \"\")then\
- \009 \009\009\009runFile(openfile,path:getraw() .. file.n,true)\
- \009 \009\009end\
- \009 \009elseif(ans == 2)then -- open with arguments\
- \009 \009\009local args = novautils.openReadDialog(\"Open with arguments. \",novaex_redraw)\
- \009 \009\009runFile(path:getraw() .. file.n,args,true)\
- \009 \009end\
- \009 end},\
- \009 {n=\"Rename \",relies=function(file) \
- \009 \009return file.t ~= \"disk\"\
- \009 end,\
- \009 func=function(file)\
- \009 \009\009local sid = getSelectedFile()\
- \009 \009\009sbc(colors.lightGray)\
- \009 \009\009scp(23,(sid-fileoffs)+4)\
- \009 \009\009write(string.rep(\" \",17))\
- \009 \009\009scp(23,(sid-fileoffs)+4)\
- \009 \009\009local newname = novautils.readEx(17,false,file.n)\
- \009 \009\009renameFile(path:getraw(),file.n,newname)\
- \009 end},\
- \009 {n=\"Extract \",relies=function(file) return file.t == \"zip\" end,\
- \009 func=function(file) \
- \009 \009 local eto = novautils.openReadDialog(\"Extract to: \",novaex_redraw)\
- \009 \009 local ans = novautils.openYesNo(\"Extract \", \"Extract contents of * \" .. file.n .. \" to: \" .. eto .. \"? \",novaex_redraw)\
- \009 \009 if(ans == 1)then\
- \009 \009 \009 futils.extract(path:getraw() .. file.n,eto)\
- \009 \009 \009 ans = novautils.openYesNo(\"Extract \", \"Extracted to: \" .. eto .. \"* Open location?\",novaex_redraw)\
- \009 \009 \009 if(ans == 1)then\
- \009 \009 \009 \009 path:set(eto)\
- \009 \009 \009 \009 getfiles()\
- \009 \009 \009 \009 undrawFiles()\
- \009 \009 \009 \009 drawFiles()\
- \009 \009 \009 end\
- \009 \009 end\
- \009 end},\
- \009 {n=\"Archive \",relies=function(file) return file.t ~= \"zip\" end,\
- \009 func=function(file) \
- \009 \009 local eto = novautils.openReadDialog(\"Export archive to: \",novaex_redraw)\
- \009 \009 if(futils.archive(path:getraw() .. file.n,eto))then\
- \009 \009\009 novautils.notify(\"Archive\",\"Folder/file successfully * archived. \",novaex_redraw)\
- \009 else\
- \009 \009 novautils.notify(\"Archive\",\"Failed to archive folder/file. \",novaex_redraw)\
- \009 \009 end\
- \009 end},\
- \009 {n=\"Cut \",relies=function(file) \
- \009\009return not fs.isReadOnly(path:getraw() .. file.n)\
- \009 end,func=function(file) \
- \009 \009setClipboard(path:getraw() .. file.n, file.n, \"cut\")\
- \009 end},\
- \009 {n=\"Copy \",func=function(file) \
- \009 \009setClipboard(path:getraw() .. file.n, file.n, \"copy\")\
- \009 end},\
- \009 {n=\"Paste \",relies=function(file) \
- \009 \009return clipboard.name ~= nil and \
- \009 \009\009not fs.isReadOnly(path:getraw() .. file.n)\
- \009 end,\
- \009 func=function(file) \
- \009 \009pasteFile(path:getraw()) \
- \009 end},\
- \009 {n=\"Pin item\",relies=function(file) \
- \009 \009return not isPinnedItem(path:getraw() .. file.n) end,\
- \009 func=function(file)\
- \009 \009 addPinnedFile(\
- \009 \009 \009icons[file.t] .. \" &r\" .. file.n,file.t,path:getraw() .. file.n\
- \009 \009 )\
- \009 end},\
- \009 {n=\"Unpin \",relies=function(file) \
- \009 \009return isPinnedItem(path:getraw() .. file.n) end,\
- \009 func=function(file) \
- \009 \009 removePinnedFile(path:getraw() .. file.n)\
- \009 end},\
- \009 {n=\"Delete \",relies=function(file) \
- \009 \009 return not fs.isReadOnly(path:getraw() .. file.n) and \
- \009 \009 \009not (file.t == \"disk\" and peripheral.find(\"drive\"))\
- \009 end,func=function(file) \
- \009 \009\009local ans = novautils.openYesNo(\"File deletion. \",\"Confirm &4deletion&r of *\" .. file.n,novaex_redraw)\
- \009 \009\009if(ans == 1)then\
- \009 \009\009\009deleteFile(path:getraw() .. file.n)\
- \009 \009\009end\
- \009 end},\
- }\
- sidemenu = {\
- \009 {n=\"Open \",func=function() openHref(getSelectedSideItem().href) end},\
- \009 {n=\"Rename \",\
- \009 func=function(file)\
- \009 \009\009local sid = getSelectedSide()\
- \009 \009\009scp(5,(sid-sideoffs)+4)\
- \009 \009\009sbc(colors.lightGray)\
- \009 \009\009write(string.rep(\" \",11))\
- \009 \009\009scp(5,(sid-sideoffs)+4)\
- \009 \009\009local newname = novautils.readEx(9,false)\
- \009 \009\009renameSideItem(getSelectedSide(),newname)\
- \009 end},\
- \009 {n=\"Unpin \",relies=function() return getSelectedSide() >= 8 end,\
- \009 func=function(file) \
- \009 \009removePinnedFile(getSelectedSideItem().href)\
- \009 end},\
- \009 {n=\"Up \",relies=function() \
- \009 \009\009return getSideItem(getSelectedSide()-1).t ~= nil and \
- \009 \009\009\009 getSideItem(getSelectedSide()-1).t ~= \"text\" \
- \009 \009\009end,\
- \009 func=function(file) \
- \009 \009\009moveSideItem(getSelectedSide(),-1)\
- \009 end},\
- \009 {n=\"Down \",relies=function() \
- \009 \009return (getSelectedSide() < getSideAmmount()) and \
- \009 \009\009 (getSideItem(getSelectedSide()+1).n ~= nil) and\
- \009 \009\009 (getSideItem(getSelectedSide()+1).n ~= \"text\")\
- \009 end,\
- \009 func=function(file) \
- \009 \009moveSideItem(getSelectedSide(),1)\
- \009 end},\
- }\
- emptymenu = {\
- \009{n=\"New Folder \",func=function() \
- \009\009local file = novautils.openReadDialog(\"New Folder\",novaex_redraw)\
- \009\009newFileFolder(\"folder\",path:getraw(),file) \
- \009end},\
- \009{n=\"New File \",func=function() \
- \009\009local file = novautils.openReadDialog(\"New File\",novaex_redraw)\
- \009\009newFileFolder(\"file\",path:getraw(),file) \
- \009end},\
- \009 {n=\"Paste \",relies=function() \
- \009 \009return clipboard.name ~= nil and \
- \009 \009\009not fs.isReadOnly(path:getraw())\
- \009 end,\
- \009 func=function() \
- \009 \009pasteFile(path:getraw()) \
- \009 end},\
- \009 {n=\"Test Crash \",func=function() error(\"Lol get rekt!\") end},\
- }\
- foldermenu = {\
- \009 filemenu[1],\
- \009 filemenu[4],\
- \009 filemenu[6],\
- \009 filemenu[7],\
- \009 filemenu[8],\
- \009 filemenu[9],\
- \009 {n=\"Pin item\",relies=function(file) \
- \009 \009return not isPinnedItem(path:getraw() .. file.n) end,\
- \009 func=function(file) \
- \009 \009 addPinnedFile(\
- \009 \009 \009icons[file.t] .. \" &r\" .. file.n,file.t,path:getraw() .. file.n\
- \009 \009 )\
- \009 end},\
- \009 filemenu[11],\
- \009 {n=\"Eject \",relies=function(file) \
- \009 \009 return (file.t == \"disk\" and peripheral.find(\"drive\"))\
- \009 end,func=function(file) \
- \009 \009\009disk.eject(getDiskside())\
- \009 end},\
- \009 filemenu[12],\
- }\
- if(iscrossbow)then\
- \009sideitems = {\
- \009\009{n='&5* &rQuick Access',t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.folder..' &rPrograms',t='folder',href=\"CrossBow/programs\"},\
- \009\009{n=icons.folder..' &rGames',t='folder',href=\"CrossBow/games\"},\
- \009\009{n=' ',t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.pin .. \"&rPinned Items\",t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.game..' &rGameOfLife',t='game',href=\"CrossBow/games/GameOfLife\"},\
- \009\009{n=icons.game..' &r2048',t='game',href=\"CrossBow/games/2048\"},\
- \009\009{n=icons.folder..' &5Apis',t='folder',href=\"CrossBow/apis\"},\
- \009}\
- else\
- \009sideitems = {\
- \009\009{n='&5* &rQuick Access',t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.folder..' &rPrograms',t='folder',href=\"rom/programs\"},\
- \009\009{n=icons.folder..' &rGames',t='folder',href=\"rom/programs/fun\"},\
- \009\009{n=' ',t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.pin .. \"&rPinned Items\",t='text'},\
- \009\009{n=' ',t='text'},\
- \009\009{n=icons.game..' &2Worm',t='game',href=\"rom/programs/fun/worm\"},\
- \009\009{n=icons.game..' &8Redirection',t='game',href=\"rom/programs/fun/advanced/redirection\"},\
- \009}\
- end\
- --]] Get functions and file definitions\
- local pinnednames = {}\
- if(iscrossbow)then\
- \009pinslocation = \"configs/novapins\"\
- end\
- function getDiskside() return diskside end\
- function getWorkingDir()\
- \009return fs.getDir(shell.getRunningProgram()) .. \"/\"\
- end\
- function getConfigPinnedItems()\
- \009if(fs.exists(getWorkingDir() .. pinslocation))then\
- \009\009local pfile = (getWorkingDir() .. pinslocation)\
- \009\009local itemspinned = textutils.unserialize(futils.file_readAll(pfile))\
- \009\009for i = 1, #itemspinned do\
- \009\009\009sideitems[8+(i-1)] = itemspinned[i]\
- \009\009end\
- \009\009getPinnedNames()\
- \009else\
- \009\009local writeitems = {}\
- \009\009for i = 8, #sideitems do\
- \009\009\009writeitems[#writeitems+1] = sideitems[i]\
- \009\009end\
- \009\009futils.file_write(getWorkingDir() .. pinslocation,textutils.serialize(writeitems))\
- \009\009getConfigPinnedItems()\
- \009end\
- end\
- function saveConfigPinnedItems()\
- \009local writeitems = {}\
- \009for i = 8, #sideitems do\
- \009\009writeitems[#writeitems+1] = sideitems[i]\
- \009end\
- \009if(fs.exists(getWorkingDir() .. pinslocation))then\
- \009\009futils.file_write(getWorkingDir() .. pinslocation,textutils.serialize(writeitems))\
- \009end\
- end\
- \
- function isPinnedItem(path)\
- \009return pinnednames[formatPinPath(path)]\
- end\
- \
- -- Icon drawing\
- \
- \
- function formatPinPath(path)\
- \009local npath = fpath.newpath(path)\
- local pathtbl={}\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- fname = pathtbl[#pathtbl]\
- npath:goback(1)\
- \
- \009if(path:sub(1,1) == \"/\" and #npath:getraw() > 1)then path = path:sub(2,#path) end \
- \009if(#npath:getraw() <= 1)then path = \"/\" .. fname end\
- \009return path\
- end\
- \
- function novaex_redraw()\
- \009undrawFiles()\
- \009getfiles()\
- \009drawMain()\
- \009drawFiles()\
- end\
- \
- function moveSideItem(id,to)\
- \009local moveitem = sideitems[id]\
- \009local toitem = sideitems[id+to]\
- \
- \009sideitems[id+to] = moveitem\
- \009sideitems[id] = toitem\
- \009selectedside = selectedside + to\
- \009drawSideBar()\
- end\
- function deleteFile(file)\
- \009file_selected = 0\
- \009fs.delete(file)\
- \009undrawFiles()\
- \009getfiles()\
- \009drawFiles()\
- end\
- function newFileFolder(forf,path,file)\
- \009if(file == \"\" or file:find(\" \"))then return false end\
- \009if(not fs.exists(path .. file))then\
- \009\009if(forf == \"folder\")then\
- \009\009\009if(file:sub(1,4) == \"disk\")then\
- \009\009\009\009novautils.notify(\"Creation Error.\",\"Cannot create disk directory!\",novaex_redraw)\
- \009\009\009\009return false\
- \009\009\009end\
- \009\009\009fs.makeDir(path .. file)\
- \009\009elseif(forf == \"file\")then\
- \009\009\009local f = fs.open(path .. file,\"w\")\
- \009\009\009f.write(\"\")\
- \009\009\009f.close()\
- \009\009end\
- \009\009getfiles()\
- \009\009drawFiles()\
- \009else\
- \009\009novautils.notify(\"Creation Error.\",\"File or folder already exists.\",novaex_redraw)\
- \009end\
- end\
- function renameSideItem(id,nname)\
- if(nname ~= \"\")then\
- \009 nname = icons[sideitems[id].t] .. \"&r \" .. nname\
- \009 sideitems[id].n = nname\
- \009 saveConfigPinnedItems()\
- end\
- drawSideBar()\
- end\
- function getSideItemType(id)\
- \009return sideitems[id].t\
- end\
- function getSideItem(id)\
- \009return sideitems[id]\
- end\
- function addPinnedFile(name,type,link)\
- \009sideitems[#sideitems+1] = {n=name,t=type,href=formatPinPath(link)}\
- \009pinnednames[formatPinPath(link)] = true\
- \009saveConfigPinnedItems()\
- \009drawFiles()\
- \009drawSideBar()\
- end\
- function setClipboard(p,n,t)\
- \009clipboard = {path=p,name=n,type=t}\
- \009if(t == \"cut\")then\
- \009\009drawFiles()\
- \009end\
- end\
- function getSelectedSideItem()\
- \009return sideitems[selectedside]\
- end\
- function getSelectedSide()\
- \009return selectedside\
- end\
- function getSideAmmount()\
- \009return #sideitems\
- end\
- function getSelectedFile()\
- \009return file_selected\
- end\
- function getnamedpins()\
- \009return pinnednames\
- end\
- function getClipboard()\
- \009return clipboard\
- end\
- function removePinnedFile(link)\
- \009for i = 8, #sideitems do\
- \009\009if(sideitems[i].href == formatPinPath(link))then\
- \009\009\009table.remove(sideitems,i)\
- \009\009\009getPinnedNames()\
- \009\009\009saveConfigPinnedItems()\
- \009\009\009break\
- \009\009end\
- \009end\
- \009selectedside = 0\
- \009drawFiles()\
- \009drawSideBar()\
- end\
- function getPinnedNames()\
- \009pinnednames = {}\
- \009for i = 1, #sideitems do\
- \009\009if(sideitems[i].t ~= \"text\")then\
- \009\009\009pinnednames[sideitems[i].href] = true\
- \009\009end\
- \009end\
- end\
- \
- --]] Get files in directory\
- \
- function getfiles()\
- \009files = {}\
- \009local folders = {}\
- \009for k , v in pairs(fs.list(path:getraw())) do\
- \009\009if(fs.isDir(path:getraw() .. v))then\
- \009\009\009local spt = 'folder'\
- \009\009\009if(v:sub(1,4) == \"disk\")then \
- \009\009\009\009if(#v > 4)then\
- \009\009\009\009\009if(tonumber(v:sub(5,#v)) ~= nil)then\
- \009\009\009\009\009\009spt = \"disk\"\
- \009\009\009\009\009end\
- \009\009\009\009else\
- \009\009\009\009\009spt = \"disk\" \
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009folders[#folders+1] = {n=v,t=spt}\
- \009\009else\
- \009\009\009local nt = 'file'\
- \009\009\009if(v:sub(#v-3,#v) == '.zip')then nt = 'zip' end\
- \009\009\009if(v:sub(#v-3,#v) == '.exe')then nt = 'exe' end\
- \009\009\009if(path:getraw():find(\"CrossBow/games\") or \
- \009\009\009\009path:getraw():find(\"rom/programs/fun\"))then nt = \"game\" end\
- \009\009\009if(path:getraw():find(\"CrossBow/programs\"))then nt = \"executable\" end\
- \009\009\009if(novautils.isFileImage(path:getraw() .. v))then nt = \"paint\" end\
- \009\009\009files[#files+1] = {n=v,t=nt}\
- \009\009end\
- \009end\
- \009-- Sort folders before files\
- \009for k,v in pairs(files) do \
- \009\009table.insert(folders, v) \
- \009end\
- \009files = folders\
- end\
- \
- --]] Draw program layout\
- function drawSideBar()\
- \009term.current().setVisible(false)\
- \009sbc(colors.white)\
- \009pa.drawFilledBox(0,4,17,h,colors.white)\
- \009sbc(1,1)\
- \009local loopam = #sideitems\
- \009if(#sideitems > h-5)then\
- \009\009loopam = (h-5)+sideoffs\
- \009end\
- \009for i = 1+sideoffs, loopam do\
- \009\009if(i-sideoffs < sidemax)then\
- \009\009\009if(sideitems[i] ~= nil)then\
- \009\009\009\009scp(1,(i-sideoffs)+4)\
- \009\009\009\009write(string.rep(\" \",16))\
- \009\009\009\009if(selectedside == i)then\
- \009\009\009\009\009sbc(colors.lightGray)\
- \009\009\009\009else\
- \009\009\009\009\009sbc(colors.white)\
- \009\009\009\009end\
- \009\009\009\009novautils.colorwrite(sideitems[i].n,12,1,(i-sideoffs)+4)\
- \009\009\009end\
- \009\009end\
- \009end\
- \009pa.drawBox(17,4,17,h,colors.gray)\
- \009pa.drawBox(1,h,17,h,colors.gray)\
- \009pa.drawBox(16,4,16,h-1,colors.lightGray)\
- \009stc(colors.gray)\
- \009ugapi.writexy(\"^\",16,4)\
- \009ugapi.writexy(\"v\",16,h-1)\
- \009term.current().setVisible(true)\
- end\
- -- Deprecidated\
- function drawFile(ind)\
- \009 -- Draw selected files\
- \009term.current().setVisible(false)\
- \009sbc(colors.white)\
- \009stc(colors.black)\
- \009drawFilePath()\
- \009 if(ind <= filemax)then\
- \009 \009 scp(19,ind+fileoffs)\
- \009\009\009write(string.rep(\" \",30))\
- \009\009\009novautils.colorwrite(icons[files[ind].t] .. \" &r\" .. files[ind].n ,12,19,ind,file_selected == ind)\
- \009\009\009scp(40,ind+fileoffs)\
- \009\009 if(not fs.isDir(path:getraw() .. files[ind].n))then\
- \009\009 \009write(tostring(fs.getSize(path:getraw() .. files[ind].n) / 1000):sub(1,4) .. \"KB\")\
- \009\009 end\
- \009 end\
- \009 term.current().setVisible(true)\
- end\
- function undrawFiles()\
- \009pa.drawFilledBox(18,4,w-1,h,colors.white)\
- end\
- function drawFilePath()\
- \009sbc(colors.white)\
- \009ugapi.writexy(string.rep(\" \",w-24),12,2)\
- \009sbc(colors.white)\
- \009stc(colors.black)\
- \009scp(13,2)\
- \009if(#path:getraw() > 25)then\
- \009\009local dif = #path:getraw() - 25\
- \009\009write(path:getraw():sub(dif,#path:getraw()))\
- \009else\
- \009\009write(path:getraw())\
- \009end\
- end\
- function drawFiles()\
- \009term.current().setVisible(false)\
- \009sbc(colors.white)\
- \009stc(colors.black)\
- \009drawFilePath()\
- \009 scp(23,4)\
- \009 stc(colors.lightGray)\
- \009 write(\"Name\")\
- \009 scp(40,4)\
- \009 write(\"Size\")\
- \009if(#files == 0)then\
- \009\009scp(25,5)\
- \009\009stc(colors.lightGray)\
- \009\009if(search ~= \"\")then\
- \009\009\009scp(20,5)\
- \009\009\009write(\"No items matched your search. \")\
- \009\009else\
- \009\009\009write(\"This folder is empty. \")\
- \009\009end\
- \009end\
- \009local loopam = #files\
- \009if(#files > h-4)then\
- \009\009loopam = (h-4)+fileoffs\
- \009end\
- \009 for i = 1+fileoffs, loopam do\
- \009 \009 if(i-fileoffs <= filemax)then\
- \009 \009 \009if(files[i].n ~= nil)then\
- \009 \009 \009 scp(19,(i-fileoffs)+4)\
- \009\009\009 write(string.rep(\" \",30))\
- \009\009\009 local namecolor = \" &r\"\
- \009\009\009 local drawname = files[i].n\
- \009\009\009 if(path:getraw() .. files[i].n == clipboard.path and clipboard.type == \"cut\")then\
- \009\009\009 \009namecolor = \" &7\"\
- \009\009\009end\
- \009\009\009 if(isPinnedItem(path:getraw() .. files[i].n))then \
- \009\009\009 \009 namecolor = \" &b\"\
- \009\009\009 \009if(path:getraw() .. files[i].n == clipboard.path and clipboard.type == \"cut\")then\
- \009\009\009 \009 \009namecolor = \" &e\"\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009\009 local selected = (file_selected == i)\
- \009\009\009 if(multiselecting)then\
- \009\009\009 \009for s = 1, #files_selected do\
- \009\009\009 \009\009if(files_selected[s].n == files[i].n and \
- \009\009\009 \009\009\009path:getraw() == files_selected[s].p)then\
- \009\009\009 \009\009\009if(clipboard.type == \"cut\")then\
- \009\009\009 \009\009\009\009namecolor = \" &7\"\
- \009\009\009 \009\009\009\009if(isPinnedItem(path:getraw() .. files[i].n))then \
- \009\009\009 \009\009\009\009\009namecolor = \" &e\"\
- \009\009\009 \009\009\009\009end\
- \009\009\009 \009\009\009end\
- \009\009\009 \009\009\009selected = true\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009\009 local bcol = colors.white\
- \009\009\009 if(selected)then bcol = colors.lightBlue end\
- \009\009\009 novautils.colorwrite(icons[files[i].t] .. namecolor .. drawname ..\"&r\",12,19,(i-fileoffs)+4,bcol)\
- \009\009\009 scp(40,(i-fileoffs)+4)\
- \009\009\009 if(not fs.isDir(path:getraw() .. files[i].n))then\
- \009\009\009 \009write(tostring(fs.getSize(path:getraw() .. files[i].n) / 1000):sub(1,4) .. \"KB\")\
- \009\009\009 end\
- \009 \009 end\
- \009 \009 end\
- \009 end \
- \009 term.current().setVisible(true)\
- end\
- function renameFile(path,name,nname)\
- \009local odir = shell.dir()\
- \009shell.setDir(\"\")\
- \009if(not fs.exists(path .. nname) and nname ~= \"\" and not nname:find(\" \"))then\
- \009\009if(nname:sub(1,4) == \"disk\" and fs.isDir(path .. name))then\
- \009\009\009shell.setDir(odir)\
- \009\009\009novautils.notify(\"Rename Error.\",\"Cannot rename directory to * disk!\",novaex_redraw)\
- \009\009\009return false\
- \009\009end\
- \009\009fs.move(path .. name, path .. nname)\
- \009\009getfiles()\
- \009elseif(nname ~= \"\" and not nname:find(\" \"))then\
- \009\009novautils.notify(\"Couldn't rename file.\",\"File with name: * \".. nname .. \", already exists.\",novaex_redraw)\
- \009end\
- \009drawFiles()\
- \009shell.setDir(odir)\
- end\
- function runFile(fpath,args,noclick)\
- \009local odir = shell.dir()\
- \009sbc(colors.black)\
- \009stc(colors.white)\
- \009clr()\
- \009scp(1,1)\
- \009shell.setDir(\"\")\
- \009if(novautils.isFileImage(fpath))then \
- \009\009args = fpath\
- \009\009fpath = \"paint\"\
- \009\009noclick = true\
- \009end\
- \009if(shell.resolveProgram(fpath))then\
- \009\009if(fs.exists(shell.resolveProgram(fpath)))then \
- \009\009\009shell.run(fpath,args)\
- \009\009\009if(not noclick)then\
- \009\009\009\009ugapi.writecy(\"Click any where to return to NovaBrowse. \",9)\
- \009\009\009\009os.pullEvent(\"mouse_click\")\
- \009\009\009end\
- \009\009else\
- \009\009\009novautils.notify(\"Open file.\", \"&4File not found. \",novaex_redraw)\
- \009\009end\
- \009end\
- \009shell.setDir(odir)\
- \009drawMain()\
- \009getfiles()\
- \009drawFiles()\
- end\
- function setDir(name)\
- \009if(fs.isDir(name))then\
- \009\009clearSearch()\
- \009\009file_selected = 0\
- \009\009if(name:sub(#name,#name) ~= \"/\")then name = name .. \"/\" end\
- \009\009fileoffs = 0\
- \009\009path:set(name)\
- \009\009getfiles()\
- \009\009undrawFiles()\
- \009\009drawFiles()\
- \009\009return true\
- \009else\
- \009\009drawFilePath()\
- \009\009return false\
- \009end\
- end\
- function addDir(name)\
- \009selectedside = 0\
- \009drawSideBar() \
- \009clearSearch()\
- \009file_selected = 0\
- \009fileoffs = 0\
- \009path:add(name)\
- \009getfiles()\
- \009undrawFiles()\
- \009drawFiles()\
- end\
- function clearSearch()\
- \009search = \"\"\
- \009scp(40,2)\
- \009sbc(colors.lightGray)\
- \009write(string.rep(\" \",11))\
- end\
- function searchDir(val)\
- \009file_selected = 0\
- \009fileoffs = 0\
- \009local nfiles = {}\
- \009undrawFiles()\
- \009if(val == \"\" or val == \" \")then\
- \009\009getfiles()\
- \009else\
- \009\009for i = 1, #files do\
- \009\009\009if(files[i].n:find(val))then\
- \009\009\009\009nfiles[#nfiles+1] = files[i]\
- \009\009\009end\
- \009\009end\
- \009\009files = nfiles\
- \009end\
- \009drawFiles()\
- end\
- function openHref(href)\
- if(fs.isDir(href))then\
- \009setDir(href)\
- elseif(fs.exists(href))then\
- \009return runFile(href)\
- end\
- end\
- function editfile(filepath)\
- \009runFile(\"edit\",filepath,true)\
- end\
- function pasteMultiFile(to)\
- \009if(multiselecting)then\
- \009\009for i = 1, #files_selected do\
- \009\009\009clipboard.path = files_selected[i].p .. files_selected[i].n\
- \009\009\009clipboard.name = files_selected[i].n\
- \009\009\009pasteFile(to)\
- \009\009end\
- \009end\
- end\
- function pasteFile(to)\
- \009local odir = shell.dir()\
- \009if(fs.isReadOnly(to))then\
- \009\009novautils.notify(\"Paste file \", \"Access Denied. \",novaex_redraw)\
- \009\009return\
- \009end\
- \009if(not fs.exists(to .. clipboard.name))then\
- \009\009fs.copy(clipboard.path,path:getraw() .. clipboard.name)\
- \009\009if(clipboard.type == \"cut\")then fs.delete(clipboard.path) clipboard = {} end\
- \009\009getfiles()\
- \009\009drawFiles()\
- \009else\
- \009\009if(to .. clipboard.name == clipboard.path)then\
- \009\009\009clipboard = {}\
- \009\009\009drawFiles()\
- \009\009\009return\
- \009\009end\
- \009\009local ans = novautils.openYesNo(\"File transfer\",\"File exists, Rename file? \",novaex_redraw)\
- \009\009if(ans == 1)then\
- \009\009\009local newname = novautils.openReadDialog(\"Rename paste file. \",novaex_redraw,clipboard.name)\
- \009\009\009if(newname:find(\" \"))then\
- \009\009\009\009novautils.notify(\"File rename \", \"Invalid file name. \",novaex_redraw)\
- \009\009\009else\
- \009\009\009\009clipboard.name = newname\
- \009\009\009end\
- \009\009\009return pasteFile(to)\
- \009\009end\
- \009end\
- \
- \009shell.setDir(odir)\
- end\
- function prevDir(ind) \
- \009selectedside = 0 \
- \009drawSideBar()\
- \009scp(2,2)\
- \009sbc(colors.gray)\
- \009stc(colors.black)\
- \009write(\"<-\")\
- \009sleep(0.1)\
- \009scp(2,2)\
- \009sbc(colors.lightGray)\
- \009stc(colors.gray)\
- \009write(\"<-\")\
- \009clearSearch()\
- \009file_selected = 0\
- \009fileoffs = 0\
- \009path:goback(ind)\
- \009getfiles()\
- \009undrawFiles()\
- \009drawFiles()\009\
- end\
- function refreshDir()\
- \009scp(6,2)\
- \009sbc(colors.gray)\
- \009stc(colors.black)\
- \009write(\"<>\")\
- \009sleep(0.1)\
- \009scp(6,2)\
- \009sbc(colors.lightGray)\
- \009stc(colors.gray)\
- \009write(\"<>\")\
- \009clearSearch()\
- \009file_selected = 0\
- \009fileoffs = 0\
- \009drawMain()\
- \009getConfigPinnedItems()\
- \009getPinnedNames()\
- \009drawSideBar()\
- \009getfiles()\
- \009drawFiles()\
- \009checkUpdate()\
- end\
- function drawfilemenu(menu,sx,sy)\
- \009local finalmenu = {}\
- \009for i = 1, #menu do\
- \009\009if(menu[i].relies == nil)then\
- \009\009\009finalmenu[#finalmenu+1] = menu[i]\
- \009\009elseif(menu[i].relies(files[file_selected],pinnednames))then\
- \009\009\009finalmenu[#finalmenu+1] = menu[i]\
- \009\009end\
- \009end\
- \009if(sy+#finalmenu > h)then\
- \009\009sy = sy - ((sy+#finalmenu)-h)\
- \009end\
- \009if(sx+#finalmenu[1].n >= w-1)then\
- \009\009sx = sx - ((sx+#finalmenu[1].n)-(w-1))\
- \009end\
- \009pa.drawBox(sx,sy+2,sx+#finalmenu[1].n,sy+#finalmenu+1,colors.black)\
- \009for i = 1, #finalmenu do\
- \009\009if(sy+i <= h)then\
- \009\009\009scp(sx-1,sy+i)\
- \009\009\009sbc(colors.lightGray)\
- \009\009\009stc(colors.white)\
- \009\009\009write(string.rep(\" \",#finalmenu[i].n+1))\
- \009\009\009scp(sx,sy+i)\
- \009\009\009write(finalmenu[i].n)\
- \009\009end\
- \009end\
- \009return finalmenu, sx, sy\
- end\
- function drawMenuClick(mop)\
- \009local _, dny = term.getCursorPos()\
- \009local dnx = inmenux+1\
- \009sbc(colors.gray)\
- \009stc(colors.black)\
- \009write(mop.n)\
- \009sleep(0.2)\
- \009scp(dnx,dny)\
- \009sbc(colors.lightGray)\
- \009stc(colors.white)\
- \009write(mop.n)\
- end\
- function updatemenu(e,menu,sx,sy,clrfunc)\
- \009if(e[1] == \"mouse_click\")then\
- \009\009local x, y = e[3], e[4]\
- \009\009local mlen = #menu[1].n-1\
- \009\009if(x >= sx and x <= sx+mlen and y >= sy+1 and y <= sy+#menu)then\
- \009\009\009 local clicked = menu[(y-sy)]\
- \009\009\009 scp(sx,y)\
- \009\009\009 drawMenuClick(clicked)\
- \009\009\009 clrfunc()\
- \009\009\009 e[1] = nil\
- \009\009\009 inmenu = false\
- \009\009\009 return clicked.func(files[file_selected])\
- \009\009else\
- \009\009\009clrfunc()\
- \009\009\009inmenu = false\
- \009\009end\
- \009end\
- end\
- function opencloseMenu(type,x,y,yind)\
- \009if(inmenu)then\
- \009\009undrawFiles()\
- \009\009drawFiles()\
- \009\009drawSideBar()\
- \009\009inmenu = false\
- \009elseif(type==\"reg\")then\
- \009\009local mtodraw = filemenu\
- \009\009if(fs.isDir(path:getraw() .. files[file_selected].n))then\
- \009\009\009mtodraw = foldermenu\
- \009\009end\
- \009\009drawingmenu = mtodraw\
- \009\009inmenutype, inmenux, inmenuy = drawfilemenu(mtodraw,x,y)\
- \009\009inmenu = true\
- \009elseif(type==\"sidebar\")then\
- \009\009drawingmenu = sidemenu\
- \009\009inmenutype, _, inmenuy = drawfilemenu(sidemenu,5,y)\
- \009\009inmenux = 5\
- \009\009inmenu = true\
- \009elseif(type==\"new\" and not fs.isReadOnly(path:getraw()) )then\
- \009\009drawingmenu = emptymenu\
- \009\009inmenutype,inmenux,inmenuy = drawfilemenu(emptymenu,x,y)\
- \009\009inmenu = true\
- \009end\
- end\
- local function update(e)\
- \009if(inmenu)then\
- \009\009updatemenu(e,inmenutype,inmenux,inmenuy,novaex_redraw)\
- \009end\
- \009if(e[1] == \"disk\")then\
- \009\009getfiles()\
- \009\009drawFiles()\
- \009\009diskside = e[2]\
- \009\009if(fs.exists(\"disk/autorun\"))then\
- \009\009\009local ans = novautils.openYesNo(\"Disk detected \",\"A software disk has been * detected. \",novaex_redraw,\"Run\",\"Cancel\")\
- \009\009\009if(ans == 1)then\
- \009\009\009\009runFile(\"disk/autorun\")\
- \009\009\009end\
- \009\009elseif(disk.hasAudio(e[2]))then\
- \009\009\009local ans = novautils.openYesNo(\"Music detected \",\"A music disk has been * inserted. \",novaex_redraw,\"Play\",\"Cancel\")\
- \009\009\009if(ans == 1)then\
- \009\009\009\009disk.playAudio(e[2])\
- \009\009\009end\
- \009\009else\
- \009\009\009local ans = novautils.openYesNo(\"Disk detected \",\"A floppy disk has been * inserted. \",novaex_redraw,\"Open\",\"Cancel\")\
- \009\009\009if(ans == 1)then\
- \009\009\009\009setDir(\"disk/\")\
- \009\009\009end\
- \009\009end\
- \009elseif(e[1] == \"disk_eject\")then\
- \009\009if(path:getraw():find(\"disk/\"))then\
- \009\009\009path:set(\"/\")\
- \009\009end\
- \009\009undrawFiles()\
- \009\009getfiles()\
- \009\009drawFiles()\
- \009end\
- \009if(e[1] == \"paste\")then\
- \009\009if(clipboard.name ~= nil)then\
- \009\009\009if(multiselecting)then\
- \009\009\009\009pasteMultiFile(path:getraw())\
- \009\009\009else\
- \009\009\009\009pasteFile(path:getraw())\
- \009\009\009end\
- \009\009end\
- \009end\
- \009if(e[1] == \"key\")then\
- \009\009local key = e[2] \
- \009\009if(key == actionkey and not actionkeydown)then\
- \009\009\009actionkeydown = true\
- \009\009elseif(actionkeydown)then\
- \009\009\009local opper = \"copy\"\
- \009\009\009if(key == keys.c or key == keys.x)then\
- \009\009\009\009if(key == keys.x)then opper = \"cut\" end\
- \009\009\009\009if(file_selected ~= 0)then\
- \009\009\009\009\009setClipboard(path:getraw() .. files[file_selected].n, \
- \009\009\009\009\009files[file_selected].n, opper)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009\009if(file_selected > 0)then\
- \009\009\009if(key == keys.delete)then\
- \009\009 \009\009local ans = novautils.openYesNo(\"File deletion. \",\"Confirm &4deletion&r of *\" .. files[file_selected].n,novaex_redraw)\
- \009\009 \009\009if(ans == 1)then\
- \009\009 \009\009\009deleteFile(path:getraw() .. files[file_selected].n)\
- \009\009 \009\009end\
- \009\009\009end\
- \009\009end\
- \009\009if(selectedside > 0)then\
- \009\009\009if(key == keys.up and sideitems[selectedside-1].t ~= nil and \
- \009 \009\009 sideitems[selectedside-1].t ~= \"text\" )then\
- \009\009\009\009moveSideItem(selectedside,-1)\
- \009\009\009elseif(key == keys.down and (selectedside < #sideitems) and \
- \009 \009\009 (sideitems[selectedside+1].n ~= nil) and \
- \009 \009\009 sideitems[selectedside+1].t ~= \"text\" )then\
- \009\009\009\009moveSideItem(selectedside,1)\
- \009\009\009end\
- \009\009end\
- \009elseif(e[1] == \"key_up\")then\
- \009\009\009local key = e[2] \
- \009\009if(key == actionkey and actionkeydown )then\
- \009\009\009actionkeydown = false\
- \009\009end\
- \009end\
- \009if(e[1] == \"mouse_click\")then\
- \009\009 local x,y = e[3], e[4] \
- \009\009 -- Left clicked\
- \009\009if(e[2] == 1)then\
- \009\009\009if(x == w and y == 1)then\
- \009\009\009\009clickExit()\
- \009\009\009\009innova = false\
- \009\009\009\009sbc(colors.white)\
- \009\009\009\009clr()\
- \009\009\009\009stc(colors.gray)\
- \009\009\009\009ugapi.writecy(\"Thank you for using Nova Explore. \",9)\
- \009\009\009\009ugapi.writecy(\"Click the screen to exit. \",10)\
- \009\009\009\009os.pullEvent(\"mouse_click\")\
- \009\009\009\009sbc(colors.black)\
- \009\009\009\009clr()\
- \009\009\009\009stc(colors.white)\
- \009\009\009\009scp(1,1)\
- \009\009\009\009return \
- \009\009\009end\
- \009\009 \009if(x >= 38 and x <= 51 and y == 2)then\
- \009\009 \009\009novaio.setInput(search)\
- \009\009 \009\009searching = true\
- \009\009 \009elseif(searching)then\
- \009\009 \009\009search = novaio.getInput()\
- \009\009 \009\009searching = false\
- \009\009 \009end\
- \009\009 \009if(x >= 2 and x <= 4 and y == 2)then\
- \009\009 \009\009if(inmenu)then inmenu = false end\
- \009\009 \009\009prevDir(1)\
- \009\009 \009end\
- \009\009 \009if(x >= 6 and x <= 8 and y == 2)then\
- \009\009 \009\009refreshDir()\
- \009\009 \009end\
- \009\009end \
- \009\009-- Left or right clicked\
- \009\009 \009local yind = (y+fileoffs)-4\
- \009\009 \009local syind = (y+sideoffs)-4\
- \009\009 \009if(x < 18 and syind <= #sideitems and syind > 0)then\
- \009\009\009 \009 if(y > 4 and x >= 1 and x <= #(sideitems[syind].n:sub(1,14)) )then\
- \009\009\009 \009 if(e[2] == 1 and not inmenu)then\
- \009\009\009\009 \009 \009if(fs.isDir(sideitems[syind].href) and sideitems[syind].t ~= \"text\")then\
- \009\009\009\009 \009 \009 selectedside = syind\
- \009\009\009\009 \009 \009 \009openHref(sideitems[syind].href)\
- \009\009\009\009 \009 \009 \009drawSideBar()\
- \009\009\009\009 \009 \009elseif(sideitems[syind].t ~= \"text\")then\
- \009\009\009\009 \009 \009 \009if(selectedside == syind)then\
- \009\009\009\009 \009 \009 \009 \009openHref(sideitems[syind].href)\
- \009\009\009\009 \009 \009 \009else\
- \009\009\009\009 \009 \009 \009 selectedside = syind\
- \009\009\009\009 \009 \009 \009 \009drawSideBar()\
- \009\009\009\009 \009 \009 \009end\
- \009\009\009\009 \009 \009end\
- \009\009\009\009 elseif(e[2] == 2)then\
- \009\009\009\009 \009\009if(selectedside ~= 0)then\
- \009\009\009\009 \009 \009\009opencloseMenu(\"sidebar\",x,y)\009\
- \009\009\009\009 \009 \009end\
- \009\009\009 \009 end\
- \009\009\009 \009 end\
- \009\009\009 elseif(yind <= #files and yind > 0)then\
- \009\009 \009 \009if(y > 4 and x >= 18 and x <= 22+#files[yind].n)then\
- \009\009 \009 \009 if(e[2] == 1 and not inmenu)then\
- \009\009\009 \009 \009 if(file_selected == yind)then\
- \009\009\009\009 \009 \009 \009if(fs.isDir(path:getraw() .. files[file_selected].n))then\
- \009\009\009\009 \009 \009 \009\009if(inmenu)then inmenu = false end\
- \009\009\009\009 \009 \009 \009 \009addDir(files[yind].n)\
- \009\009\009\009 \009 \009 \009 else\
- \009\009\009\009 \009 \009 \009 \009runFile(path:getraw() .. files[file_selected].n)\
- \009\009\009\009 \009 \009 \009end\
- \009\009\009\009 \009 \009 else\
- \009\009\009\009 \009 \009 \009 file_selected = yind\
- \009\009\009\009 \009 \009 \009 drawFiles()\
- \009\009\009\009 \009 \009 end\
- \009\009\009 \009 elseif(e[2] == 2 )then\
- \009\009\009 \009 \009 if(file_selected == yind)then\
- \009\009\009 \009 \009 \009\009opencloseMenu(\"reg\",x,y,yind)\
- \009\009\009 \009 \009 else\
- \009\009\009 \009 \009 \009\009opencloseMenu(\"new\",x,y,yind)\
- \009\009\009\009\009 end\
- \009\009\009\009end\
- \009\009 end\
- \009\009end\
- \009\009if(e[2] == 2 and not inmenu and x > 18)then\
- \009\009 \009opencloseMenu(\"new\",x,y,1)\
- \009\009end\
- \009end\
- \009if(e[1] == \"mouse_scroll\")then\
- \009\009local dir = e[2]\
- \009\009local x,y = e[3], e[4]\
- \009\009if(dir == -1)then\
- \009\009\009if(x > 16 and fileoffs > 0 )then\
- \009\009\009\009fileoffs = fileoffs - 1\
- \009\009\009\009drawFiles()\
- \009\009\009elseif(x <= 16 and sideoffs > 0)then\
- \009\009\009\009sideoffs = sideoffs - 1\
- \009\009\009\009drawSideBar()\
- \009\009\009end\
- \009\009elseif(dir == 1)then\
- \009\009\009if(x > 16 and fileoffs < #files-(filemax-4))then\
- \009\009\009\009fileoffs = fileoffs + 1\
- \009\009\009\009drawFiles()\
- \009\009\009elseif(x <= 16 and sideoffs < #sideitems-(sidemax-4))then\
- \009\009\009\009sideoffs = sideoffs + 1\
- \009\009\009\009drawSideBar()\
- \009\009\009end\
- \009\009end\
- \009end\
- \009if(novaio.getActive() == false and not searching)then\
- \009\009if(novaio.getInput() ~= path:getraw())then\
- \009\009\009novaio.setInput(path:getraw())\
- \009\009end\
- \009end\
- \
- \009if(not searching)then\
- \009\009stc(colors.black)\
- \009\009sbc(colors.white)\
- \009\009local doneinp = novaio.read(e,1000,25,13,2)\
- \009\009if(doneinp)then\
- \009 \009novaio.setActive(false)\
- \009\009\009if( setDir(novaio.getInput()) )then\
- \009\009\009\009selectedside = 0\
- \009\009\009\009drawSideBar()\
- \009\009\009end\
- \009\009\009novaio.setInput(\"\")\
- \009\009end\
- \009else\
- \009\009stc(colors.black)\
- \009\009sbc(colors.lightGray)\
- \009\009local doneinp = novaio.read(e,1000,10,40,2)\
- \009\009if(doneinp)then\
- \009\009\009searching = false\
- \009 \009novaio.setActive(false)\
- \009 \009search = novaio.getInput()\
- \009\009\009searchDir(novaio.getInput()) \
- \009\009\009novaio.setInput(\"\")\
- \009\009end\
- \009end\
- end\
- function displayError(err)\
- \009sbc(colors.white)\
- \009clr()\
- \009stc(colors.gray)\
- \009ugapi.writecy(\" Well, thats not supposed to happen. \",1)\
- \009scp(2,3)\
- \009stc(colors.lightGray)\
- \009write(err)\
- \009ugapi.writecy(\" Why you do dis to me :(. \",16)\
- \009stc(colors.black)\
- \009ugapi.writecy(\" Press any key to end NovaExplore. \",17)\
- \009ugapi.writecy(\" Click to restart NovaExplore. \",18)\
- \009local e = {os.pullEvent()}\
- \009if(e[1] == \"key\")then \
- \009\009sbc(colors.black)\
- \009\009clr()\
- \009\009stc(colors.white)\
- \009\009scp(1,1)\
- \009elseif(e[1] == \"mouse_click\")then\
- \009\009local odir = shell.dir()\
- \009\009shell.setDir(\"\")\
- \009\009shell.run(shell.getRunningProgram())\
- \009\009shell.setDir(odir)\
- \009end\
- end\
- function clickExit()\
- \009scp(w,1)\
- \009stc(colors.black)\
- \009sbc(colors.pink)\
- \009write(\"X\")\
- \009sleep(0.2)\
- \009scp(w,1)\
- \009stc(colors.white)\
- \009sbc(colors.red)\
- \009write(\"X\")\
- end\
- function checkUpdate()\
- \009if(http)then\
- \009\009local upd = http.get(\"http://pastebin.com/raw/rpipr5pT\")\
- \009\009if(upd ~= nil)then\
- \009\009\009local cont = upd.readAll()\
- \009\009\009local f = fs.open(shell.getRunningProgram(),\"r\")\
- \009\009\009local pcont = f.readAll()\
- \009\009\009f.close()\
- \009\009\009if(cont ~= pcont)then\
- \009\009\009\009local ans = novautils.openYesNo(\"Auto update\", \"Update detected, would you * like to update?.\",novaex_redraw)\
- \009\009\009\009if(ans == 1)then\
- \009\009\009\009\009local f = fs.open(shell.getRunningProgram(),\"w\")\
- \009\009\009\009\009f.write(cont)\
- \009\009\009\009\009f.close()\
- \009\009\009\009\009novautils.notify(\"Auto update\", \"Updated, restart required.\",novaex_redraw)\
- \009\009\009\009\009innova = false\
- \009\009\009\009\009return shell.run(shell.resolveProgram(shell.getRunningProgram()))\
- \009\009\009\009end\
- \009\009\009end\
- \009\009else\
- \009\009\009novautils.notify(\"Auto update\", \"Failed to connect to pastebin.\",novaex_redraw)\
- \009\009end\
- \009else\
- \009\009novautils.notify(\"Auto update\", \"Http is disabled, Failed to * check for updates.\",novaex_redraw)\
- \009\009return\
- \009end\
- end\
- function drawMain()\
- \009sbc(colors.white)\
- \009clr()\
- \009scp(1,2)\
- \009sbc(colors.lightGray)\
- \009clrln()\
- \009pa.drawBox(w-12,1,w,3,colors.gray)\
- \009sbc(colors.white)\
- \009ugapi.writexy(string.rep(\" \",w-12),1,2)\
- \009pa.drawBox(10,1,w-12,3,colors.gray)\
- \009drawSideBar()\
- \009pa.drawFilledBox(1,1,9,3,colors.lightGray)\
- \009scp(2,2)\
- \009stc(colors.gray)\
- \009write(\"<- <>\")\
- \009--pa.drawBox(15,h,w,h,colors.lightGray)\
- \009pa.drawBox(w,4,w,h,colors.lightGray)\
- \009stc(colors.gray)\
- \009ugapi.writexy(\"^\",w,4)\
- \009ugapi.writexy(\"v\",w,h)\
- \009scp(w,1)\
- \009stc(colors.white)\
- \009sbc(colors.red)\
- \009write(\"X\")\
- \009sbc(colors.black)\
- end\
- drawMain()\
- getConfigPinnedItems()\
- getPinnedNames()\
- drawSideBar()\
- getfiles()\
- drawFiles()\
- checkUpdate()\
- \
- local function loop()\
- \009while innova do \
- \009\009local e = {os.pullEvent()}\
- \009\009update(e)\
- \009end\
- end\
- local ok, err = pcall(loop)\
- if(not ok)then\
- \009if(term.current().setVisible)then\
- \009\009term.current().setVisible(true)\
- \009end\
- \009displayError(err)\
- end",
- },
- [ "apis/fpath/" ] = {
- content = "local function path_goback(path,amm)\
- pathtbl={}\
- s=\"\"\
- pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- for k, v in pairs(pathtbl) do\
- pathsize=k\
- end\
- pathsize = pathsize - amm\
- -- Based on how large the user wants the string to be \
- -- add only the string bits that led up to the user defined\
- -- size.\
- for k, v in pairs(pathtbl) do\
- if(k <= pathsize)then s = s..pathtbl[k]..\"/\" end\
- end\
- return s\
- end\
- local function path_getsize(path)\
- pathtbl={}\
- pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- for k, v in pairs(pathtbl) do\
- pathsize=k\
- end\
- return pathsize\
- end\
- \
- function newpath(name,stuckindex)\
- if(name == nil or type(name) ~= \"string\")then error(\"PathAPI: Name must be provided for new paths. \") end\
- if(string.sub(name,#name,#name) ~= \"/\")then\
- name = name .. \"/\"\
- end\
- if(type(stuckindex) ~= \"number\")then stuckindex = 0 end\
- local pathobj = {\
- path = name,\
- stuckind = stuckindex,\
- getsize = function(self)\
- return path_getsize(self.path)\
- end,\
- goback = function(self,amm)\
- if(self:getsize() - amm >= self.stuckind)then\
- self.path = path_goback(self.path,amm)\
- return self.path\
- else\
- return false\
- end\
- end,\
- getraw = function(self)\
- return self.path\
- end,\
- add = function(self,new)\
- self.path = self.path .. new .. \"/\"\
- return self.path\
- end,\
- set = function(self,npath)\
- self.path = npath\
- return self.path\
- end,\
- lockpath = function(self)\
- self.stuckind = self:getsize()\
- end,\
- unlockpath = function(self)\
- self.stuckind = 0\
- end,\
- }\
- return pathobj\
- end",
- },
- [ "programs/novazip/" ] = {
- content = "--====================================================\
- --]] Nova Zip and all file apis created by\
- --]] Lewisk3 CEO of Nova, all rights reservered \
- --]] DO NOT REDISTRIBUTE without the permission \
- --]] of Nova, Editing and/or \"rebranding\" is prohibited.\
- --]] Any copys found outside the permission of Nova\
- --]] will be taken and money will be due to the rights\
- --]] of Nova Technologys\
- -------------------------------------------------------\
- --=] We have the rights to all the above [=- \
- --=====================================================\
- --]] Determine OS and load apis accordingly \
- local args = { ... }\
- if(#args < 1)then error(\"Ussage: novazip <zipfile>\") end\
- local w, h = term.getSize()\
- local sbc = term.setBackgroundColor\
- local stc = term.setTextColor\
- local scp = term.setCursorPos\
- local clr = term.clear\
- local clrln = term.clearLine\
- local pa = paintutils\
- local offs = 0\
- local zip = args[1]\
- local files = {}\
- local selected = 0\
- local inmenu = false\
- local inmenutype = {}\
- local drawingmenu = {}\
- local inmenux, inmenuy = 1, 4\
- local apis = {'ugapi','fpath','futils','novaio','ziputils','novautils'}\
- local innovazip = true\
- \
- local function init()\
- \009if(fs.isDir(\"CrossBow/apis\"))then\
- \009\009iscrossbow = true\
- \009\009for i = 1, #apis do\
- \009\009\009\009if(fs.exists(\"CrossBow/apis/\"..apis[i]))then\
- \009\009\009\009\009apis[i] = \"CrossBow/apis/\" ..apis[i]\
- \
- \009\009\009\009else\
- \009\009\009\009\009error(\"Program had to Quit: CrossBow install outdated or malformed. \")\
- \009\009\009\009end\
- \009\009end \
- \009end\
- \009for i = 1, #apis do\
- \009\009if(iscrossbow)then\
- \009\009\009os.loadAPI((apis[i]))\
- \009\009else\
- \009\009\009os.loadAPI(shell.resolveProgram((apis[i])))\
- \009\009end\
- \009end\
- end\
- init()\
- \
- nz_menu = {\
- \009{n=\"Open \",func=function(file) end},\
- \009{n=\"Edit \",relies=function(file) return file.type ~= \"folder\" end,func=function(file) end},\
- \009{n=\"Rename \",func=function(file) end},\
- \009{n=\"Delete \",func=function(file) end},\
- }\
- \
- nz_newmenu = {\
- \009{n=\"New File \",func=function() end},\
- \009{n=\"Add File \",func=function() end},\
- \009{n=\"Extract \",func=function() end},\
- \009{n=\"Close \",func=function() end},\009\
- }\
- \
- function nz_opencloseMenu(type,x,y)\
- \009if(inmenu)then\
- \009\009nz_drawfiles(1)\
- \009\009inmenu = false\
- \009elseif(type==\"reg\")then\
- \009\009local mtodraw = nz_menu\
- \009\009drawingmenu = mtodraw\
- \009\009inmenutype, inmenux, inmenuy = nz_drawmenu(drawingmenu,x,y)\
- \009\009inmenu = true\
- \009elseif(type==\"new\")then\
- \009\009drawingmenu = nz_newmenu\
- \009\009inmenutype,inmenux,inmenuy = nz_drawmenu(drawingmenu,x,y)\
- \009\009inmenu = true\
- \009end\
- end\
- function drawMenuClick(mop)\
- \009local _, dny = term.getCursorPos()\
- \009local dnx = inmenux+1\
- \009sbc(colors.gray)\
- \009stc(colors.black)\
- \009write(mop.n)\
- \009sleep(0.2)\
- \009scp(dnx,dny)\
- \009sbc(colors.lightGray)\
- \009stc(colors.white)\
- \009write(mop.n)\
- end\
- \
- function nz_updatemenu(e,menu,sx,sy)\
- \009if(e[1] == \"mouse_click\")then\
- \009\009local x, y = e[3], e[4]\
- \009\009local mlen = #menu[1].n-1\
- \009\009if(x >= sx and x <= sx+mlen and y >= sy+1 and y <= sy+#menu and e[2] == 1)then\
- \009\009\009 local clicked = menu[(y-sy)]\
- \009\009\009 scp(sx,y)\
- \009\009\009 novautils.drawMenuClick(clicked)\
- \009\009\009 nz_drawfiles(1)\
- \009\009\009 e[1] = nil\
- \009\009\009 inmenu = false\
- \009\009\009 return clicked.func(files[file_selected])\
- \009\009else\
- \009\009\009nz_drawfiles(1)\
- \009\009\009inmenu = false\
- \009\009end\
- \009end\
- end\
- \
- function nz_drawmenu(menu,sx,sy)\
- \009local finalmenu = {}\
- \009for i = 1, #menu do\
- \009\009if(menu[i].relies == nil)then\
- \009\009\009finalmenu[#finalmenu+1] = menu[i]\
- \009\009elseif(menu[i].relies(files[selected],pinnednames))then\
- \009\009\009finalmenu[#finalmenu+1] = menu[i]\
- \009\009end\
- \009end\
- \009if(sy+#finalmenu > h-2)then\
- \009\009sy = sy - ((sy+#finalmenu)-(h-2))\
- \009end\
- \009if(sx+#finalmenu[1].n >= w-1)then\
- \009\009sx = sx - ((sx+#finalmenu[1].n)-(w-1))\
- \009end\
- \009pa.drawBox(sx,sy+2,sx+#finalmenu[1].n,sy+#finalmenu+1,colors.black)\
- \009for i = 1, #finalmenu do\
- \009\009if(sy+i <= h)then\
- \009\009\009scp(sx-1,sy+i)\
- \009\009\009sbc(colors.lightGray)\
- \009\009\009stc(colors.white)\
- \009\009\009write(string.rep(\" \",#finalmenu[i].n+1))\
- \009\009\009scp(sx,sy+i)\
- \009\009\009write(finalmenu[i].n)\
- \009\009end\
- \009end\
- \009return finalmenu, sx, sy\
- end\
- \
- function nz_openYesNo()\
- \009local r = novautils.openYesNo()\
- \009nz_getfiles()\
- \009nz_drawmain()\
- \009nz_drawfiles()\
- \009return r\
- end\
- --- NovaZIP start --\
- local path = fpath.newpath(\"\")\
- function nz_formatzippath(path)\
- \009if(path:sub(1,1) == \"/\")then\
- \009\009return path:sub(2,#path)\
- \009else\
- \009\009return path\
- \009end\
- end\
- function nz_getfiles()\
- \009offs = 0\
- \009files = {}\
- \009files = ziputils.ziplist(shell.resolveProgram(zip),nz_formatzippath(path:getraw()))\
- \009pa.drawFilledBox(2,8,w-1,h-1,colors.white)\
- end\
- function nz_addDir(dir)\
- \009path:add(dir:sub(1,#dir-1))\
- \009nz_getfiles()\
- \009nz_drawfiles()\
- end\
- function nz_drawfiles(c)\
- \009if(c)then pa.drawFilledBox(2,8,w-1,h-1,colors.white) end\
- \009scp(7,6)\
- \009stc(colors.white)\
- \009sbc(colors.lightGray)\
- \009write(string.rep(\" \",w-5))\
- \009scp(7,6)\
- \009write( nz_formatzippath(path:getraw()) )\
- \009scp(2,8)\
- \009sbc(colors.white)\
- \009stc(colors.lightGray)\
- \009write(\" Name Type Size \")\
- \009local lamm = #files-offs\
- \009if(#files-offs > 10)then\
- \009\009lamm = 10 \
- \009end\
- \009for i = 1+offs, lamm+offs do\
- \009\009sbc(colors.white)\
- \009\009scp(2,(i+8)-offs)\
- \009\009write(string.rep(\" \",w-2))\
- \009\009if(files[i].type == \"folder\")then\
- \009\009\009sbc(colors.yellow)\
- \009\009\009stc(colors.brown)\
- \009\009\009scp(2,(i+8)-offs)\
- \009\009\009write(\"[=]\")\
- \009\009\009sbc(colors.white)\
- \009\009\009if(selected == i)then sbc(colors.lightBlue) end\
- \009\009\009stc(colors.black)\
- \009\009\009scp(5,i+8-offs)\
- \009\009\009write(' ' .. files[i].n:sub(1,#files[i].n-1))\
- \009\009\009files[i].t = \"Folder\"\
- \009\009else\
- \009\009\009sbc(colors.gray)\
- \009\009\009stc(colors.lightGray)\
- \009\009\009scp(2,i+8-offs)\
- \009\009\009write(\"-~-\")\
- \009\009\009sbc(colors.white)\
- \009\009\009if(selected == i)then sbc(colors.lightBlue) end\
- \009\009\009stc(colors.black)\
- \009\009\009scp(5,i+8-offs)\
- \009\009\009write(' ' .. files[i].n)\
- \009\009\009files[i].t = \"File\"\
- \009\009end\
- \009end\
- end\
- function nz_drawmain()\
- \009sbc(colors.white)\
- \009clr()\
- \009pa.drawBox(1,7,w,h,colors.gray)\
- \009pa.drawBox(1,1,w,7,colors.gray)\
- \009pa.drawFilledBox(2,2,w-1,5,colors.lightGray)\
- \009scp(2,5)\
- \009sbc(colors.gray)\
- \009stc(colors.white)\
- \009write(string.rep(\"_\",w-2))\
- \009scp(2,6)\
- \009sbc(colors.black)\
- \009stc(colors.lightGray)\
- \009write(\"^-\")\
- \009sbc(colors.lightGray)\
- \009stc(colors.black)\
- \009write(\":/\")\
- \009write(string.rep(\" \",w-6))\
- \009scp(2,7)\
- \009sbc(colors.gray)\
- \009stc(colors.white)\
- \009write(string.rep(\"-\",w-2))\
- end\
- function nz_goback()\
- \009scp(2,6)\
- \009sbc(colors.gray)\
- \009stc(colors.white)\
- \009write(\"^-\")\
- \009sleep(0.2)\
- \009sbc(colors.black)\
- \009stc(colors.lightGray)\
- \009scp(2,6)\
- \009write(\"^-\")\
- \009path:goback(1)\
- \009nz_getfiles()\
- \009nz_drawfiles()\
- end\
- \
- local function update()\
- \009local e = {os.pullEvent()}\
- \009if(inmenu)then\
- \009\009nz_updatemenu(e,inmenutype,inmenux,inmenuy)\
- \009end\
- \009if(e[1] == \"mouse_scroll\" and #files > 1)then\
- \009\009if(e[2] == -1 and offs > 0)then\
- \009\009\009offs = offs - 1\
- \009\009\009nz_drawfiles()\
- \009\009end\
- \009\009if(e[2] == 1 and offs < #files-(10))then\
- \009\009\009offs = offs + 1\
- \009\009\009nz_drawfiles()\
- \009\009end\
- \009end\
- \009if(e[1] == \"mouse_click\")then\
- \009\009local x, y = e[3], e[4]\
- \009\009local yind = (y-8)+offs\
- \009\009if(e[2] == 1)then\
- \009\009\009if(x >= 2 and x <= 4 and y == 6)then\
- \009\009\009\009nz_goback()\
- \009\009\009end\
- \
- \009\009\009if(yind > 0 and yind <= #files and x >= 4 and x <= 5+#files[yind].n)then\
- \009\009\009\009if(selected == yind)then\
- \009\009\009\009\009if(files[yind].type == \"folder\")then\
- \009\009\009\009\009\009nz_addDir(files[selected].n)\
- \009\009\009\009\009\009selected = 0\
- \009\009\009\009\009end\
- \009\009\009\009else\
- \009\009\009\009\009selected = yind\
- \009\009\009\009end\
- \009\009\009elseif(inmenu)then\
- \009\009\009\009inmenu = false\
- \009\009\009end\
- \009\009\009\009nz_drawfiles()\
- \009\009\009elseif(e[2] == 2)then\
- \009\009\009\009if(not inmenu and x > 1 and y > 8)then\
- \009\009\009\009\009if(yind == selected and x >= 4 and x <= 5+#files[yind].n)then\
- \009\009\009\009\009\009nz_opencloseMenu(\"reg\",x,y)\
- \009\009\009\009\009else\
- \009\009\009\009\009\009nz_opencloseMenu(\"new\",x,y)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- end\
- nz_getfiles()\
- nz_drawmain()\
- nz_drawfiles()\
- \
- local function loop()\
- \009while innovazip do\
- \009\009update()\
- \009end\
- end\
- loop()",
- },
- [ "users/tes/" ] = {
- content = "",
- },
- [ "apis/grid/" ] = {
- content = "\
- -- ] Created by: Redxone(Lewisk3) [ -- \
- -- ] \009(c)Lewisk3 Corpz 2016\009 [ -- \
- \
- -- DOCUMENTATION (Sorta...) -- \
- --] grid.create(width,height)\
- --] grid:set(x,y,thing)\
- --] grid:find(obj) - returns the found objects x and y location\
- --] grid:findByAttrib(attrib,compare)\
- --] grid:get(x,y) - returns the object in the x any y of the grid\
- --] grid:getByAttrib(attrib,compare)\
- --] grid:getWidth() - returns width of grid\
- --] grid:getHeight() - returns grid height\
- --] grid:unset(x,y) - set grid spot to {}\
- --] grid:getRaw() - returns entire grid unserialized\
- --] grid:getSerial() - returns entire grid serialized\
- --] grid:replace(newgrid) - replaces grid with another grid\
- --] grid:draw()\
- --] grid:drawAttrib(attrib)\
- --] grid:fill(with) - fills grid with something\
- --] grid:setRegion(startx,starty,endx,endy,with) - fills grid from start x and start y to ends with something\
- --] grid:drawRegion(startx,starty,endx,endy)\
- \
- function create(w, h)\
- \009local gridtable = {\
- \009\009maxw = w,\
- \009\009maxh = h,\
- \009\009grid = {},\
- \
- \009\009set = function(self,x,y,obj)\
- \009\009\009if(x <= self.maxw and y <= self.maxh)then\
- \009\009\009\009self.grid[y][x] = obj\
- \009\009\009else\
- \009\009\009\009error(\"grid:set -> Invaild X and/or Y param(s).\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009find = function(self,obj)\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009if(textutils.serialize(self.grid[y][x]) == textutils.serialize(obj))then\
- \009\009\009 \009\009\009return x, y\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009get = function(self,x,y)\
- \009\009\009local tbl = {}\
- \009\009\009if(x <= self.maxw and y <= self.maxh )then\
- \009\009\009\009return self.grid[y][x]\
- \009\009\009else\
- \009\009\009\009return tbl\
- \009\009\009end\
- \009\009end,\
- \
- \009\009getByAttribEqual = function(self,a,c)\
- \009\009\009local gx, gy = 0, 0\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009if(self.grid[y][x][a] == c)then\
- \009\009\009 \009\009\009gx = x\
- \009\009\009 \009\009\009gy = y\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009\009return self:get(gx,gy)\
- \009\009end,\
- \
- \009\009checkAttribEqual = function(self,x,y,a,e)\
- \009\009\009 if(self.grid[y][x][a] == c)then\
- \009\009\009 \009return true\
- \009\009\009 else\
- \009\009\009 \009return false\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009getByAttrib = function(self,a)\
- \009\009\009local xx, yy = 0, 0\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009if(self.grid[y][x][a] ~= nil)then\
- \009\009\009 \009\009\009 xx = x\
- \009\009\009 \009\009\009 yy = y\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \
- \009\009\009 if(xx ~= 0 and yy ~= 0)then\
- \009\009\009\009return self:get(xx,yy)[a]\
- \009\009\009 else\
- \009\009\009\009return {}\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009setByAttrib = function(self,a,n)\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009if(self.grid[y][x][a] ~= nil)then\
- \009\009\009 \009\009\009 local bset = self.grid[y][x]\
- \009\009\009 \009\009\009 bset[a] = n\
- \009\009\009 \009\009\009 self:set(x,y,bset)\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009getWidth = function(self)\
- \009\009\009return self.maxw\
- \009\009end,\
- \
- \009\009getHeight = function(self)\
- \009\009\009return self.maxh\
- \009\009end,\
- \
- \009\009unset = function(self,x,y)\
- \009\009\009if(x <= self.maxw and y <= self.maxh)then\
- \009\009\009\009self.grid[y][x] = {}\
- \009\009\009else\
- \009\009\009\009error(\"grid:unset -> Invaild X and/or Y param(s).\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009getRaw = function(self)\
- \009\009\009return self.grid\
- \009\009end,\
- \
- \009\009getSerial = function(self)\
- \009\009\009return textutils.serialize(self.grid):gsub(\"\\n%s*\",\"\")\
- \009\009end,\
- \
- \009\009replace = function(self,grid)\
- \009\009\009if(type(grid) ~= \"table\")then error(\"grid:replace -> Invalid grid type. \") end\
- \009\009\009 -- calculating grid size... --\
- \009\009\009 self.maxh = 0\
- \009\009\009 self.maxw = 0\
- \
- \009\009\009 for iy = 1, #grid do\
- \009\009\009 \009self.maxh = self.maxh + 1\
- \009\009\009 end\
- \
- \009\009\009 for ix = 1, #grid[0] do\
- \009\009\009\009self.maxw = self.maxw + 1\
- \009\009 end\
- \
- \009\009 self.grid = grid\
- \
- \009\009\009 if(self.maxh <= 0 or self.maxw <= 0)then error(\"grid:replace -> Grid is malformed.\") end\
- \
- \009\009end,\
- \
- \009\009draw = function(self)\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009term.setCursorPos(x,y)\
- \009\009\009 \009\009if(self.grid[y][x] ~= {})then\
- \009\009\009\009\009\009term.write(self.grid[y][x])\
- \009\009\009\009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009swap = function(self,fromx,fromy,tox,toy)\
- \009\009\009local prevo = self.grid[fromy][fromx] \
- \009\009\009local too = self.grid[toy][tox]\
- \009\009\009self.grid[fromy][fromx] = too\
- \009\009\009self.grid[toy][tox] = prevo\
- \009\009end,\
- \
- \009\009moveInto = function(self,obj,x,y,uap,flags)\
- \009\009\009local prloc = self:get(x,y)\
- \009\009\009local ox, oy = self:find(obj)\
- \009\009\009-- only take place if flags on other block are met --\
- \009\009\009if(type(flags) == \"table\")then\
- \009\009\009\009for k, v in pairs(flags) do\
- \009\009\009\009\009if(not self:checkAttribEqual(x,y,k,v))then\
- \009\009\009\009\009\009return false\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009-- if passes flags -- \
- \009\009\009if(type(uap) == \"table\")then\
- \009\009\009\009for k, v in pairs(uap) do\
- \009\009\009\009\009obj[k] = v\
- \009\009\009\009end\009\009\009\009\
- \009\009\009end\
- \009\009\009self:set(ox,oy,prloc)\
- \009\009\009self:set(x,y,obj)\
- \009\009end,\
- \
- \009\009renderSwap = function(self, charattrib, tcolattrib, bcolattrib, fromx,fromy,tox,toy)\
- \009\009\009self:swap(fromx,fromy,tox,toy)\009\009\
- \009\009\009self:renderRegion(charattrib, tcolattrib, bcolattrib,tox,toy,tox,toy)\
- \009\009\009self:renderRegion(charattrib, tcolattrib, bcolattrib,fromx,fromy,fromx,fromy)\
- \009\009end,\
- \
- \009\009render = function(self,charattrib,tcolattrib,bcolattrib)\
- \009\009\009local ta = colors.white\
- \009\009\009local ba = colors.black\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009term.setCursorPos(x,y)\
- \009\009\009 \009\009term.setTextColor(self.grid[y][x][tcolattrib])\
- \009\009\009 \009\009term.setBackgroundColor(self.grid[y][x][bcolattrib])\
- \009\009\009\009\009 \009ta = colors.white\
- \009\009\009\009\009 \009ba = colors.black\
- \009\009\009\009\009 \009if(type(tcolattrib) == \"number\")then ta = tcolattrib end\
- \009\009\009\009\009 \009if(type(bcolattrib) == \"number\")then ba = bcolattrib end\
- \009\009\009\009\009 \009if(self.grid[y][x][charattrib] ~= nil)then\
- \009\009\009\009\009 \009\009if(self.grid[y][x][tcolattrib] ~= nil)then\
- \009\009\009\009\009 \009\009\009ta = self.grid[y][x][tcolattrib]\
- \009\009\009\009\009 \009\009end\
- \009\009\009\009\009 \009\009if(self.grid[y][x][bcolattrib] ~= nil)then\
- \009\009\009\009\009 \009\009\009ba = self.grid[y][x][bcolattrib]\
- \009\009\009\009\009 \009\009end\
- \009\009\009\009\009\009 \009term.setTextColor(ta)\
- \009\009\009\009 \009\009\009term.setBackgroundColor(ba)\
- \009\009\009\009\009 \009\009term.write(self.grid[y][x][charattrib])\
- \009\009\009\009\009 \009end\
- \009\009\009\009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009drawAttrib = function(self,a)\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009term.setCursorPos(x,y)\
- \009\009\009 \009\009if(self.grid[y][x][a] ~= nil)then\
- \009\009\009 \009\009\009term.write(self.grid[y][x][a])\
- \009\009\009 \009\009end\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009fill = function(self,obj)\
- \009\009\009for y = 0, self.maxh do\
- \009\009\009 \009for x = 0, self.maxw do\
- \009\009\009 \009\009self.grid[y][x] = obj\
- \009\009\009 \009end\
- \009\009\009 end\
- \009\009end,\
- \
- \009\009setCursorPos = function(self,x,y)\
- \009\009\009term.setCursorPos(y,x)\
- \009\009end,\
- \
- \009\009loop = function(self,f,startx,starty,endx,endy)\
- \009\009\009if(startx == nil)then startx = 0 end\
- \009\009\009if(starty == nil)then starty = 0 end\
- \009\009\009if(endx == nil and startx ~= nil)then endx = startx end\
- \009\009\009if(endy == nil and starty ~= nil)then endy = starty end\
- \009\009\009if(endx == nil)then endx = self.maxw end\
- \009\009\009if(endy == nil)then endy = self.maxh end\
- \009\009\009for y = tonumber(starty), tonumber(endy) do\
- \009\009\009\009for x = tonumber(startx), tonumber(endx) do\
- \009\009\009\009\009f(x,y)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009setRegion = function(self, sx, sy, ex, ey, obj)\
- \009\009\009if(sx <= self.maxw and sy <= self.maxh and ex <= self.maxw and ey <= self.maxh)then\
- \009\009\009\009for y = tonumber(sy), tonumber(ey) do\
- \009\009\009\009 \009for x = tonumber(sx), tonumber(ex) do\
- \009\009\009\009 \009\009self.grid[y][x] = obj\
- \009\009\009\009 \009end\
- \009\009\009\009 end\
- \009\009\009else\
- \009\009\009\009error(\"grid:setRegion -> Invaild X and/or Y param(s).\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009drawRegion = function(self, sx, sy, ex, ey)\
- \009\009\009if(sx <= self.maxw and sy <= self.maxh and ex <= self.maxw and ey <= self.maxh)then\
- \009\009\009\009for y = tonumber(sy), tonumber(ey) do\
- \009\009\009\009 \009for x = tonumber(sx), tonumber(ex) do\
- \009\009\009\009\009 \009term.setCursorPos(x,y)\
- \009\009\009\009 \009\009if(self.grid[y][x] ~= {})then\
- \009\009\009\009\009\009\009term.write(self.grid[y][x])\
- \009\009\009\009\009\009end\
- \009\009\009\009 \009end\
- \009\009\009\009 end\
- \009\009\009else\
- \009\009\009\009error(\"grid:drawRegion -> Invaild X and/or Y param(s).\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009renderRegion = function(self, charattrib, tcolattrib, bcolattrib, sx, sy, ex, ey)\
- \009\009\009if(sx <= self.maxw and sy <= self.maxh and ex <= self.maxw and ey <= self.maxh)then\
- \009\009\009\009local ta = colors.white\
- \009\009\009 \009local ba = colors.black\
- \009\009\009\009for y = tonumber(sy), tonumber(ey) do\
- \009\009\009\009 \009for x = tonumber(sx), tonumber(ex) do\
- \009\009\009\009\009 \009term.setCursorPos(x,y)\
- \009\009\009\009\009 \009ta = colors.white\
- \009\009\009\009\009 \009ba = colors.black\
- \009\009\009\009\009 \009if(self.grid[y][x][charattrib] ~= nil)then\
- \009\009\009\009\009 \009\009if(self.grid[y][x][tcolattrib] ~= nil)then\
- \009\009\009\009\009 \009\009\009ta = self.grid[y][x][tcolattrib]\
- \009\009\009\009\009 \009\009end\
- \009\009\009\009\009 \009\009if(self.grid[y][x][bcolattrib] ~= nil)then\
- \009\009\009\009\009 \009\009\009ba = self.grid[y][x][bcolattrib]\
- \009\009\009\009\009 \009\009end\
- \009\009\009\009\009\009 \009term.setTextColor(ta)\
- \009\009\009\009 \009\009\009term.setBackgroundColor(ba)\
- \009\009\009\009\009 \009\009term.write(self.grid[y][x][charattrib])\
- \009\009\009\009\009 \009end\
- \009\009\009\009 \009end\
- \009\009\009\009 end\
- \009\009\009else\
- \009\009\009\009error(\"grid:renderRegion -> Invaild X and/or Y param(s).\")\
- \009\009\009end\
- \009\009end,\
- \
- \009}\
- \
- \
- \009-- generate grid locally --\
- \009for y = 0, h do\
- \009\009gridtable.grid[y] = {}\
- \009\009for x = 0, w do\
- \009\009\009gridtable.grid[y][x] = {}\
- \009\009end\
- \009end\
- \
- \009-- return grid to user --\
- \009return gridtable\
- end",
- },
- [ "games/2048/" ] = {
- content = "local running = true\
- local cx,cy = 0, 0\
- local drawx = 11\
- local drawy = -2\
- local xscale = 5\
- local yscale = 4\
- local cubexsize = 6\
- local cubeysize = 4\
- local score = 2\
- local function calcdragpos(sx,sy,ex,ey,dx,dy)\
- \009if(ex < sx-dx)then return -1,0\
- \009elseif(ex > sx+dx)then return 1,0\
- \009elseif(ey < sy-dy)then return 0,-1\
- \009elseif(ey > sy+dy)then return 0,1 end\
- end\
- \
- local map = {\
- \009{2,0,0,0},\
- \009{0,0,0,0},\
- \009{0,0,0,0},\
- \009{0,0,0,0},\
- }\
- local numcols = {\
- \009['2'] = \"white\",\
- \009['4'] = \"lightGray\",\
- \009['8'] = \"brown\",\
- \009['16'] = \"orange\",\
- \009['32'] = \"pink\",\
- \009['64'] = \"red\",\
- \009['128'] = \"yellow\",\
- \009['256'] = \"yellow\",\
- \009['512'] = \"yellow\",\
- \009['1024'] = \"yellow\",\
- \009['2048'] = \"yellow\",\
- \009['4096'] = \"magenta\",\
- \009['8192'] = \"purple\",\
- }\
- local function drawtile(x,y)\
- \009 \009local sx = (drawx)+(x)*xscale\
- \009 \009local sy = (drawy)+(y)*yscale\
- \009 \009local ex = (drawx+x*xscale)+cubexsize\
- \009 \009local ey = (drawy+y*yscale)+cubeysize\
- \009 \009if(map[y][x] ~= 0)then\
- \009 \009\009-- drawing code form empty\
- \009 \009\009bcol = numcols[tostring(map[y][x])]\
- \009 \009\009if(bcol == nil)then col = colors.lightBlue end\
- \009 \009\009paintutils.drawFilledBox(sx+1,sy+1,ex-(cubexsize/2)+1,ey-(cubeysize/2)+1,colors[bcol])\
- \009 \009\009term.setTextColor(colors.black)\
- \009 \009\009term.setCursorPos((sx+3) - #tostring(map[y][x])/2 ,sy+2)\
- \009 \009\009write(map[y][x])\
- \009 else\
- \009 \009\009paintutils.drawFilledBox(sx+1,sy+1,ex-(cubexsize/2)+1,ey-(cubeysize/2)+1,colors.black)\
- \009 \009end\
- end\
- local function drawtiles()\
- \009term.current().setVisible(false)\
- \009--paintutils.drawBox(drawx,drawy,drawx+(#map[1]*xscale),drawy+(#map*yscale),colors.gray)\
- \009for y = 1, #map do\
- \009 for x = 1, #map[y] do \
- \009 \009\009local tile = map[y][x]\
- \009 \009\009 \009local sx = (drawx)+(x)*xscale\
- \009 \009\009\009local sy = (drawy)+(y)*yscale\
- \009 \009\009\009local ex = (drawx+x*xscale)+cubexsize\
- \009 \009\009\009local ey = (drawy+y*yscale)+cubeysize\
- \009 \009\009\009paintutils.drawBox(sx,sy,ex-1,ey,colors.gray)\
- \009 \009\009\009drawtile(x,y)\
- \009 end\
- \009end\
- \009term.current().setVisible(true)\
- end\
- local function setTile(x,y,n)\
- \009if(map[y][x] ~= 0 and n ~= 0)then \
- \009\009score = score + (n-map[y][x]) \
- \009elseif(map[y][x] ~= 0 and n == 0)then\
- \009\009score = score - map[y][x]\
- \009else\
- \009\009score = score + n\
- \009end\
- \009map[y][x] = n\
- \009drawtile(x,y)\
- end\
- \
- local function getRandTile()\
- \009local rx = math.ceil(math.random(1,#map[1]))\
- \009local ry = math.ceil(math.random(1,#map))\
- \009local rn = math.ceil(math.random(1,10))\
- \009if(rn == 10)then\
- \009\009rn = 4\
- \009else \
- \009\009rn = 2\
- \009end\
- \009return rx,ry,rn\
- end\
- \
- local function slidetiles(xd,yd)\
- \009-- 1, UP: 2, DOWN, 3: LEFT, 4: RIGHT\
- \009local rna = math.ceil(math.random(1,2))\
- \009local moved=false\
- \009local cancombine = true\
- \009for li = 1, #map[1] do\
- \009 for y = 1, #map do\
- \009 \009 for x = 1, #map[y] do\
- \009 \009 \009local to = nil\
- \009 \009 \009if(y+yd < 0 or x+xd < 0)then break end\
- \009 \009\009 if(map[y+yd] ~= nil)then\
- \009 \009\009 \009if(map[y+yd][x+xd] ~= nil)then\
- \009 \009\009\009\009\009to = map[y+yd][x+xd]\
- \009 \009\009\009\009end\
- \009 \009\009\009end\
- \
- \009 \009\009 if(to == 0)then\
- \009\009\009\009\009setTile(x+xd,y+yd,map[y][x])\
- \009 \009\009\009\009setTile(x,y,0)\
- \009 \009\009\009\009moved = true\
- \009 \009\009\009elseif(to == map[y][x] and cancombine and to ~= 8192)then\
- \009\009\009\009\009setTile(x+xd,y+yd,map[y+yd][x+xd]+map[y][x])\
- \009 \009\009\009\009setTile(x,y,0)\
- \009 \009\009\009\009cancombine = false\
- \009 \009\009\009end\
- \009 \009 end\
- \009 end\
- \009end\
- \009local rx,ry,rn = getRandTile()\
- \009if(map[ry][rx] == 0 and moved)then\
- \009\009setTile(rx,ry,rn)\
- \009end\
- \009term.setCursorPos(1,1)\
- \009term.setBackgroundColor(colors.white)\
- \009term.setTextColor(colors.black)\
- \009term.clearLine()\
- \009print(score)\
- end\
- term.clear()\
- drawtiles()\
- while running do\
- \
- \009local e = {os.pullEvent()}\009\
- \009if(e[1] == \"mouse_click\")then \
- \009\009cx = e[3]\
- \009\009cy = e[4]\
- \009end\
- \009if(e[1] == \"mouse_drag\" and cx ~= 0 and cy ~= 0)then\
- \009\009local xdir,ydir = calcdragpos(cx,cy,e[3],e[4],2,1)\
- if(type(xdir) == \"number\" and type(ydir) == \"number\")then\
- \009 slidetiles(tonumber(xdir),tonumber(ydir))\
- \009 cx = 0\
- \009 cy = 0\
- end\
- \009end\
- end",
- },
- [ "apis/novautils/" ] = {
- content = "local w, h = term.getSize()\
- local sbc = term.setBackgroundColor\
- local stc = term.setTextColor\
- local scp = term.setCursorPos\
- local clr = term.clear\
- local clrln = term.clearLine\
- local shell = {}\
- function init(nshell)\
- \009shell = nshell\
- end\
- \
- function openReadDialog(title,clrfunc,startread)\
- \009local bw, bh = 30,0\
- \009local sx, sy = w/2-math.ceil(bw/2), (h/2)-math.ceil(bh/2)-1\
- \009local ex, ey = w/2+math.ceil(bw/2), (h/2)+math.floor(bh/2)-1\
- \009paintutils.drawFilledBox(sx+1,sy,ex+2,ey+2,colors.black)\
- \009paintutils.drawFilledBox(sx,sy,ex,ey,colors.lightGray)\
- \009paintutils.drawBox(sx-1,sy-1,ex+1,ey+1,colors.gray)\
- \009scp(sx,sy-1)\
- \009stc(colors.white)\
- \009write(title)\
- \009scp(sx,sy)\
- \009sbc(colors.lightGray)\
- \009local inp = readEx(30,true,startread)\
- \009clrfunc()\
- \009return inp\
- end\
- \
- function notify(title,txt,clrfunc)\
- \009local bw, bh = 30,5\
- \009local sx, sy = w/2-math.ceil(bw/2), (h/2)-math.ceil(bh/2)+2\
- \009local ex, ey = w/2+math.ceil(bw/2), (h/2)+math.floor(bh/2)+1\
- \009paintutils.drawLine(sx,sy-1,ex,sy-1,colors.gray)\
- \009paintutils.drawFilledBox(sx+1,sy+1,ex+1,ey+1,colors.black)\
- \009paintutils.drawFilledBox(sx,sy,ex,ey,colors.lightGray)\
- \009scp(sx,sy-1)\
- \009stc(colors.white)\
- \009sbc(colors.gray)\
- \009write(title)\
- \009sbc(colors.lightGray)\
- \009local msg = {}\
- for str in string.gmatch(txt, \"([^*]+)\") do\
- msg[#msg+1] = str \
- end\
- for i = 1, #msg do\
- \009sbc(colors.lightGray)\
- \009fullwrite(\" \" .. msg[i],45,sx,sy+i)\
- end\
- fullwrite(\"&4Click&r to close. \",45,sx+8,sy+#msg+2)\
- \009os.pullEvent(\"mouse_click\")\
- \009clrfunc()\
- end\
- function openYesNo(title,txt,clrfunc,y,n)\
- \009if(y == nil or n == nil)then \
- \009\009 y = \"Yes\"\
- \009\009 n = \"No\"\
- \009end\
- \009local ynm = {y, n}\
- \009local inynm = true\
- \009local bw, bh = 30,5\
- \009local opinc = 9\
- \009local sx, sy = w/2-math.ceil(bw/2), (h/2)-math.ceil(bh/2)+2\
- \009local ex, ey = w/2+math.ceil(bw/2), (h/2)+math.floor(bh/2)+1\
- \009paintutils.drawLine(sx,sy-1,ex,sy-1,colors.gray)\
- \009paintutils.drawFilledBox(sx+1,sy+1,ex+1,ey+1,colors.black)\
- \009paintutils.drawFilledBox(sx,sy,ex,ey,colors.lightGray)\
- \009scp(sx,sy-1)\
- \009stc(colors.white)\
- \009sbc(colors.gray)\
- \009write(title)\
- \009sbc(colors.lightGray)\
- \009 local msg = {}\
- for str in string.gmatch(txt, \"([^*]+)\") do\
- msg[#msg+1] = str \
- end\
- for i = 1, #msg do\
- \009sbc(colors.lightGray)\
- \009colorwrite(\" \" .. msg[i],45,sx,sy+i)\
- end\
- \009stc(colors.white)\
- \009local function drawm()\
- \009\009 for i = 1, #ynm do\
- \009\009 \009\009sbc(colors.red)\
- \009\009 \009\009if(i==1)then\
- \009\009 \009\009\009sbc(colors.green)\
- \009\009 \009\009end\
- \009\009 \009\009scp(sx+(i*opinc),ey-1)\
- \009\009 \009\009write(ynm[i])\
- \009\009 end\
- \009end\
- \009local function drawmopt(id,clk)\
- \009\009 sbc(colors.red)\
- \009\009 if(i==1)then\
- \009\009 sbc(colors.green)\
- \009\009 end\
- \009\009 if(clk)then sbc(colors.gray) end\
- \009\009 scp(sx+(id*opinc),ey-1)\
- \009\009 write(ynm[id])\
- \009\009 sleep(0.2)\
- \009end\
- \009local function mupdate()\
- \009\009while inynm do\
- \009\009\009local ev = {os.pullEvent()}\
- \009\009\009if(ev[1] == \"mouse_click\")then\
- \009\009\009\009local x, y = ev[3], ev[4]\
- \009\009\009\009for i = 1, #ynm do\
- \009\009\009\009\009if( x >= sx+(i*opinc)-1 and x <= sx+(i*opinc)+#ynm[i] and y == math.floor(ey-1) )then\
- \009\009\009\009\009\009inynm = false\
- \009\009\009\009\009\009drawmopt(i,true)\
- \009\009\009\009\009\009return i\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009end\
- \009drawm()\
- \009local res = mupdate()\
- \009clrfunc()\
- \009return res\
- end\
- function readEx(mlen,scroll,startw)\
- \009novaio.setActive(false)\
- \009if(startw == nil)then startw = \"\" end\
- \009novaio.setInput(startw)\
- \009local x, y = term.getCursorPos()\
- \009local readxoff = x\
- \009if(startw ~= \"\")then\
- \009\009scp(readxoff,y)\
- \009\009write(novaio.getInput())\
- \009end\
- \009local oinp = novaio.getInput()\
- \009local ininp = true\
- \009if(scroll)then\
- \009\009mslen = 1000\
- \009else\
- \009\009mslen = mlen+1\
- \009end\
- \009term.setCursorBlink(true)\
- \009while ininp do\
- \009\009local e = {os.pullEvent()}\
- \009\009local inp = novaio.read(e,mslen,mlen-1,readxoff,y)\
- \009\009novaio.setActive(true)\
- \009\009if(inp)then \
- \009\009\009ininp = false\
- \009\009\009novaio.setActive(false)\
- \009\009\009local inp = novaio.getInput()\
- \009\009\009novaio.setInput(oinp)\
- \009\009\009if(inp == startw)then\
- \009\009\009\009inp = \"\"\
- \009\009\009end\
- \009\009\009return inp\
- \009\009end\
- \009\009-- Dont let the user out of the read!\
- \009\009if(novaio.getActive() == \"false\")then novaio.setActive(true) end\
- \009end\
- end\
- \
- \
- function isFileImage(file)\
- \009local isImg = false\
- \009local f = fs.open(file,\"r\")\
- \009if(f)then\
- \009\009if(tonumber(f.readAll():gsub(\"%s+\",\"\"),16) ~= nil) then\
- \009\009\009 isImg = true\
- \009\009end\
- \009\009f.close()\
- \009end\
- \009return isImg\
- end\
- \
- function getApisFrom(loc,apis)\
- \009local inloc = false\
- \009if(fs.isDir(loc))then\
- \009\009inloc = true\
- \009\009for i = 1, #apis do\
- \009\009\009\009if(fs.exists(\"CrossBow/apis/\"..apis[i]))then\
- \009\009\009\009\009apis[i] = \"CrossBow/apis/\" ..apis[i]\
- \
- \009\009\009\009else\
- \009\009\009\009\009error(\"Program had to Quit: CrossBow install outdated or malformed. \")\
- \009\009\009\009end\
- \009\009end \
- \009end\
- \
- \009for i = 1, #apis do\
- \009\009if(inloc)then\
- \009\009\009os.loadAPI((apis[i]))\
- \009\009else\
- \009\009\009os.loadAPI(shell.resolveProgram((apis[i])))\
- \009\009end\
- \009end\
- \
- \009return inloc\
- end\
- \
- function colorwrite(str,smax,x,y,special)\
- \009scp(x,y)\
- \009\009local colorencode = {\
- \009 ['&r'] = \"black\",\
- \009 ['&1'] = \"blue\",\
- \009 ['&2'] = \"green\",\
- \009 ['&3'] = \"cyan\",\
- \009 ['&4'] = \"red\",\
- \009 ['&5'] = \"purple\",\
- \009 ['&6'] = \"brown\",\
- \009 ['&7'] = \"lightGray\",\
- \009 ['&8'] = \"gray\",\
- \009 ['&9'] = \"lightBlue\",\
- \009 ['&a'] = \"lime\",\
- \009 ['&b'] = \"orange\",\
- \009 ['&c'] = \"pink\",\
- \009 ['&d'] = \"magenta\",\
- \009 ['&e'] = \"yellow\",\
- \009 ['&f'] = \"white\",\
- \009}\
- \009if(special)then sbc(special) end\
- for a = 1, #str do\
- if(string.sub(str,a,a) == \"&\")then\
- if(colorencode[string.sub(str,a,a+1)] ~= nil)then\
- stc(colors[colorencode[string.sub(str,a,a+1)]])\
- end\
- str = string.sub(str,1,a-1) .. string.sub(str,a+1,#str)\
- else\
- write(string.sub(str,a,a))\
- end\
- end \
- sbc(colors.white)\
- end",
- },
- [ "apis/ugapi/" ] = {
- content = "--]] Language assigning [[--\
- \
- pos = term.setCursorPos\
- bcolor = term.setBackgroundColor\
- tcolor = term.setTextColor\
- blink = term.setCursorBlink\
- buffer = term.current().setVisible\
- getpos = term.getCursorPos\
- getbcolor = term.getBackgroundColor\
- gettcolor = term.getTextColor\
- printslow = textutils.slowPrint\
- clr = term.clear\
- clrln = term.clearLine\
- clrlny = function(y)\
- local x,_ = getpos()\
- pos(x,y)\
- clrln()\
- end\
- clrlnycolor = function(col,y) bcolor(col) clrlny(y) end\
- box = paintutils.drawFilledBox\
- hbox = paintutils.drawBox\
- drawimage = function(img,x,y) paintutils.drawImage(paintutils.loadImage(img),x,y) end\
- \
- \
- -- ]] Write functions [[--\
- function writexy(text,x,y)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- function writec(text)\
- local w, h = term.getSize()\
- term.setCursorPos(w/2 - #text/2, (h/2)- 1)\
- term.write(text)\
- end\
- \
- function writecy(text,y)\
- local w,_ = term.getSize()\
- term.setCursorPos(w/2 - #text/2, y)\
- term.write(text)\
- end\
- \
- \
- \
- -- ]] Print functions [[--\
- function printc(text)\
- local w,h = term.getSize()\
- term.setCursorPos( (w/2) - #text/2,(h/2) - 1)\
- print(text)\
- end\
- \
- function printcy(text,y)\
- local w,_ = term.getSize()\
- term.setCursorPos(w/2 - #text/2, y)\
- print(text)\
- end\
- \
- function println(text)\
- local xx, yy = term.getCursorPos()\
- term.setCursorPos(xx,yy+1)\
- print(text)\
- end\
- \
- function printxy(text,x,y)\
- term.setCursorPos(x,y)\
- print(text)\
- end\
- \
- --]] Transitions [[--\
- function fadeIn(time)\
- \
- local ctbl = {\
- 'black',\
- 'gray',\
- 'lightGray',\
- 'white',\
- }\
- \
- for i = 1, #ctbl do\
- term.setBackgroundColor(colors[ ctbl[i] ])\
- term.clear()\
- sleep(time) \
- end\
- end\
- \
- function fadeOut(time)\
- \
- local ctbl = {\
- 'white',\
- 'lightGray',\
- 'gray',\
- 'black',\
- }\
- \
- for i = 1, #ctbl do\
- term.setBackgroundColor(colors[ ctbl[i] ])\
- term.clear()\
- sleep(time) \
- end\
- end\
- \
- \
- function fadecolors(time,ctbl)\
- for i = 1, #ctbl do\
- term.setBackgroundColor(colors[ctbl[i]])\
- term.clear()\
- sleep(time)\
- end\
- end\
- \
- function transitionIn(pixeltime, linetime,smoothness)\
- \009local w, h = term.getSize()\
- \009local left = true\
- \009for hh = 1, h/2+1 do\
- \009\009for ww = 1, w do\
- \009\009\009bcolor(colors.white)\
- \009\009\009if(left)then writexy(string.rep(\" \",smoothness),w-(ww-1),hh) else writexy(\" \",ww,hh) end\
- \009\009\009bcolor(colors.white)\
- \009\009\009if(left)then writexy(string.rep(\" \",smoothness),ww,h-(hh-1) ) else writexy(\" \",w-(ww-1),h-(hh-1)) end\
- \009\009\009if(pixeltime > 0) then sleep(pixeltime) end\
- \009\009end\
- \009\009if(left)then left = false else left = true end\
- \009\009if(linetime > 0)then sleep(linetime) end\
- \009end\
- \
- end\
- \
- function transitionOut(pixeltime, linetime,smoothness)\
- \009local w, h = term.getSize()\
- \009local left = true\
- \009for hh = 1, h/2+1 do\
- \009\009for ww = 1, w do\
- \009\009\009bcolor(colors.black)\
- \009\009\009if(left)then writexy(string.rep(\" \",smoothness),w-(ww-1),hh) else writexy(\" \",ww,hh) end\
- \009\009\009bcolor(colors.black)\
- \009\009\009if(left)then writexy(string.rep(\" \",smoothness),ww,h-(hh-1) ) else writexy(\" \",w-(ww-1),h-(hh-1)) end\
- \009\009\009if(pixeltime > 0) then sleep(pixeltime) end\
- \009\009end\
- \009\009if(left)then left = false else left = true end\
- \009\009if(linetime > 0)then sleep(linetime) end\
- \009end\
- \
- end\
- \
- --]] Button API [[ -- \
- \
- function newButton(name,x,y,width,height,namecolor,color,activecolor)\
- \009local button = {\
- \009\009name = name,\
- \009\009x = x,\
- \009\009y = y,\
- \009\009w = width-1,\
- \009\009h = height-1,\
- \009\009tcol = namecolor,\
- \009\009col = color,\
- \009\009acol = activecolor,\
- \009\009active = false,\
- \009\009rfun = function() end,\
- \009\009fun = function() end,\
- \
- \009\009draw = function(self)\
- \009\009\009local dbcol\
- \009\009\009if(self.active)then dbcol = self.acol \
- \009\009\009else dbcol = self.col end\
- \009\009\009box(self.x,self.y,self.x+self.w,self.y+self.h,dbcol)\
- \009\009\009-- Center text on button --\
- \009\009\009tcolor(self.tcol)\
- \009\009\009writexy(self.name,\
- \009\009\009\009( (self.x+self.w/2) - (#self.name/2) ),\
- \009\009\009\009( (self.y+self.h) - (self.h/2) )\
- \009\009\009)\
- \009\009end,\
- \
- \009\009update = function(self,ev)\
- \009\009\009if(ev[1] == \"mouse_click\")then\
- \009\009\009\009-- Display active for a bit then switch off\
- \009\009\009\009if(ev[3] >= self.x and ev[3] <= self.x + self.w and ev[4] >= self.y and ev[4] <= self.y + self.h)then\
- \009\009\009\009\009self:setActive(true)\
- \009\009\009\009\009sleep(0.2)\
- \009\009\009\009\009self:setActive(false)\
- \
- \009\009\009\009\009if(ev[2] == 1)then self.fun() end\
- \009\009\009\009\009if(ev[2] == 2)then self.rfun() end\
- \
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009onPress = function(self,func)\
- \009\009\009self.fun = func\
- \009\009end,\
- \
- \009\009setName = function(self,nname)\
- \009\009\009self.name = nname\
- \009\009end,\
- \
- \009\009getName = function(self,nname)\
- \009\009\009return self.name\
- \009\009end,\
- \
- \009\009setPos = function(self,x,y)\
- \009\009\009self.x = x\
- \009\009\009self.y = y\
- \009\009\009self:draw()\
- \009\009end,\
- \
- \009\009getPos = function(self)\
- \009\009\009return self.x, self.y\
- \009\009end,\
- \
- \009\009onRightPress = function(self,func)\
- \009\009\009self.rfun = func\
- \009\009end,\
- \
- \009\009setActive = function(self,act)\
- \009\009\009self.active = act\
- \009\009\009self:draw()\
- \009\009end,\
- \
- \009\009getActive = function(self)\
- \009\009\009return self.active\
- \009\009end,\
- \
- \009}\
- \
- \009return button\
- end\
- \
- -- Menu API --\
- function newMenu(x,y,width,height,bcolor)\
- \
- \009local menu = {\
- \009\009x = x,\
- \009\009y = y,\
- \009\009w = width,\
- \009\009h = height,\
- \009\009bcol = bcolor,\
- \009\009options={},\
- \009\009presets={},\
- \
- \009\009draw = function(self)\
- \009\009\009box(self.x,self.y,self.x+self.w-1,self.y+self.h-1,self.bcol)\
- \009\009\009for i = 1, #self.options do\
- \009\009\009\009if(self.options[i].name ~= nil)then\
- \009\009\009\009\009local bcol = self.presets[self.options[i].pset].bc\
- \009\009\009\009\009local tcol = self.presets[self.options[i].pset].tc\
- \
- \009\009\009\009\009if(self.options[i].active)then\
- \009\009\009\009\009\009bcol = self.presets[self.options[i].pset].ab\
- \009\009\009\009\009\009tcol = self.presets[self.options[i].pset].at\
- \009\009\009\009\009end\
- \
- \009\009\009\009\009term.setBackgroundColor(bcol)\
- \009\009\009\009\009term.setTextColor(tcol)\
- \
- \009\009\009\009\009pos( self.x, self.y+(i-1) )\
- \
- \009\009\009\009\009write(self.options[i].name)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009update = function(self, ev)\
- \009\009\009if(ev[1] == \"mouse_click\")then\
- \
- \009\009\009\009for i = 1, #self.options do\
- \009\009\009\009\009if(self.options[i].name ~= nil)then\
- \009\009\009\009\009\009if(ev[3] >= self.x and ev[3] <= #self.options[i].name + self.x\
- \009\009\009\009\009\009 and ev[4] == self.y + (i-1))then\
- \009\009\009\009\009\009\009self:setActiveOption(self.options[i].name,true)\
- \009\009\009\009\009\009\009sleep(0.2)\
- \009\009\009\009\009\009\009self:setActiveOption(self.options[i].name,false)\
- \
- \009\009\009\009\009\009\009self.options[i].act()\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \
- \009\009\009end\
- \009\009end,\
- \
- \009\009addOption = function(self,name,preset,action)\
- \009\009\009if(self.presets[preset].tc ~= nil)then\
- \009\009\009\009self.options[#self.options+1] = {name=name,pset=preset,act=action,active=false}\
- \009\009\009else\
- \009\009\009\009error(\"UGAPI: ->menu->addOption: No such preset.\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009setPreset = function(self,name,tcolor,bcolor,atcolor,abcolor,action)\
- \009\009\009self.presets[name] = {tc=tcolor,bc=bcolor,at=atcolor,ab=abcolor}\
- \009\009end,\
- \
- \009\009addWhiteSpace = function(self)\
- \009\009\009self.options[#self.options+1] = {name=nil}\
- \009\009end,\
- \
- \009\009setActiveOption = function(self,nname,isact)\
- \009\009\009for i = 1, #self.options do\
- \009\009\009\009if(self.options[i].name == nname and nname ~= nil)then\
- \009\009\009\009\009self.options[i].active = isact\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009self:draw()\
- \009\009end,\
- \
- \009}\
- \
- \009return menu \
- end",
- },
- [ "apis/futils/" ] = {
- content = "function file_readAll(file,s)\
- local f = fs.open(file,\"r\")\
- local cont = f.readAll()\
- f.close()\
- if(s)then return textutils.unserialize(s) end\
- return cont\
- end\
- function file_readLine(file,s)\
- local f = fs.open(file,\"r\")\
- local cont = f.readLine()\
- f.close()\
- if(s)then return textutils.unserialize(s) end\
- return cont\
- end\
- function file_write(file,data,s)\
- local f = fs.open(file,\"w\")\
- if(s)then f.write(textutils.serialize(data)) else\
- f.write(data) end\
- f.close()\
- end\
- function file_writeline(file,data,s)\
- local f = fs.open(file,\"w\")\
- if(s)then f.writeLine(textutils.serialize(data)) else\
- f.writeLine(data) end\
- f.close()\
- end\
- local function formatpath(path)\
- \009local pathtbl={}\
- local s=\"\"\
- local pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- table.remove(pathtbl,1)\
- for i = 1, #pathtbl do\
- \009s = s .. pathtbl[i] .. \"/\"\
- end\
- return s\
- end\
- \
- local function getcontent(data,wdata,ctbl)\
- -- Returns a table --\
- for k, v in pairs(fs.list(data)) do\
- \
- if(fs.isDir(data..\"/\"..v) )then\
- getcontent(data..v..\"/\",v..\"/\",ctbl)\
- else\
- --print(data..v)\
- local f = fs.open(data..v,\"r\")\
- ctbl[formatpath(data..v)] = {content=f.readAll()}\
- f.close()\
- end\
- end\
- return textutils.serialize(ctbl)\
- end\
- function archive(data,export)\
- local content = {}\
- content = getcontent('/' .. data .. \"/\",\"/\",content)\
- file_write(export,content)\
- return true\
- end\
- \
- function extract(file,to)\
- local cont = textutils.unserialize(file_readAll(file))\
- for k,v in pairs(cont) do\
- file_write(to .. \"/\" .. k,v.content)\
- end\
- end",
- },
- [ "apis/ziputils/" ] = {
- content = "local function formatpath(path)\
- \009local pathtbl={}\
- local s=\"\"\
- local pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- for k, v in pairs(pathtbl) do\
- pathsize=k\
- end\
- pathsize = pathsize - 1\
- -- Based on how large the user wants the string to be \
- -- add only the string bits that led up to the user defined\
- -- size.\
- for k, v in pairs(pathtbl) do\
- if(k <= pathsize)then s = s..pathtbl[k]..\"/\" end\
- end\
- return s\
- end\
- local function pathlen(path)\
- \009local pathtbl={}\
- local s=\"\"\
- local pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- return #pathtbl\
- end\
- local function filterdirpath(dir,path)\
- \009local pathtbl={}\
- local s=\"\"\
- local pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- local la = 0\
- for str in string.gmatch(path, \"([^/]+)\") do\
- \009if(la >= pathlen(dir))then\
- \009pathtbl[#pathtbl+1] = str \
- end\
- la = la + 1\
- end\
- \009for i = 1, #pathtbl do\
- \009\009s = s .. pathtbl[i] .. \"/\"\
- \009end \
- return s\
- end\
- local function comparesubpath(flpath,subpath)\
- \009return (formatpath(subpath) == flpath) or (subpath:find(flpath) and pathlen(formatpath(subpath)) == pathlen(flpath)+1 )\
- end\
- local function comparefolderpath(flpath,subpath)\
- \009return \
- end\
- local function getend(path)\
- \009local pathtbl={}\
- local s=\"\"\
- local pathsize=0\
- -- Divide string and count the number of \
- -- divisions.\
- for str in string.gmatch(path, \"([^/]+)\") do\
- pathtbl[#pathtbl+1] = str \
- end\
- return pathtbl[#pathtbl]\
- end\
- function iszip(file)\
- \009local f = fs.open(file,\"r\")\
- \009local c = f.readAll()\
- \009f.close()\
- \009return type(c) == \"table\"\
- end\
- local function intable(tbl,am)\
- \009for i = 1, #tbl do\
- \009\009if(tbl[i].n == am)then\
- \009\009\009return true\
- \009\009end\
- \009end\
- \009return false \
- end\
- function ziplist(zip,dir)\
- \009local folders = {}\
- \009local files = {}\
- \009local list = {}\
- \009local startls = false\
- \009local f = fs.open(zip,\"r\")\
- \009local c = (f.readAll())\
- \009c = textutils.unserialize(c)\
- \009f.close()\
- \009for k, v in pairs(c) do\
- \009\009if(comparesubpath(dir,k))then\
- \009\009\009if(pathlen(formatpath(k)) == pathlen(dir))then\
- \009\009\009\009files[getend(k)] = {t=\"file\",c=v.content}\
- \009\009\009\009--print(\"File:\" .. getend(k))\
- \009\009\009\009--print(\"------------------\")\
- \009\009\009\009--os.pullEvent(\"key\")\
- \009\009\009elseif(pathlen(formatpath(k)) < 2+pathlen(dir) and \
- \009\009\009not intable(folders,filterdirpath(dir,formatpath(k))))then\
- \009\009\009\009folders[#folders+1] = {n=filterdirpath(dir,formatpath(k)),t=\"folder\",c=v.content}\
- \009\009\009\009--print(\"Folder: \" .. filterdirpath(dir,formatpath(k)))\
- \009\009\009\009--os.pullEvent(\"key\")\
- \009\009\009end\
- \009\009end\
- \009end\
- \009for k, v in pairs(files) do\
- \009\009folders[#folders+1] = {n=k,type=v.t,data=v.c}\
- \009end\
- \009for i = 1, #folders do\
- \009\009list[i] = {n=folders[i].n,type=folders[i].t,data=folders[i].c}\
- \009end\
- \009return list\
- end",
- },
- [ "programs/test/" ] = {
- content = "\
- print(getPinnedNames())\
- print(pinnednames)",
- },
- [ "programs/lightshot/" ] = {
- content = "\
- -- \
- -- Lighshot Screen Recorder\
- -- Made by GravityScore\
- -- \
- \
- \
- -- -------- Variables\
- \
- -- Lower the loop rate to decrease recording lag but to decrease compression\
- -- Do not set to below 50 else the file could become really big\
- local loopRate = 300\
- \
- -- Version\
- local version = \"1.5\"\
- \
- -- Terminal\
- local oldTerm = {}\
- local newTerm = {}\
- local w, h = term.getSize()\
- \
- -- Events\
- local event_exitRecording = \"lightshot_exitRecordingEvent\"\
- \
- -- Locations\
- local lightshotURL = \"https://raw.github.com/GravityScore/Lightshot/master/lightshot.lua\"\
- local lightshotLocation = \"/\" .. shell.getRunningProgram()\
- local recordLocation = \"/.lightshot_recording\"\
- \
- -- Variables\
- local clock = 0\
- local nfaRecording = false\
- local paused = false\
- local handle = nil\
- \
- local recordHeader = [[\
- -- \
- -- Recorded by Lightshot\
- -- \
- \
- local function sp(...) return sleep(...) end\
- local function c(...) return term.write(...) end\
- local function d(...) return term.setCursorPos(...) end\
- local function e(...) return term.setBackgroundColor(...) end\
- local function f(...) return term.setTextColor(...) end\
- local function g(...) return term.clear(...) end\
- local function h(...) return term.clearLine() end\
- local function i(...) return term.setCursorBlink(...) end\
- local function j(...) return term.scroll(...) end\
- \
- -- sD here...\
- \
- ]]\
- \
- \
- -- -------- Utilities\
- \
- local function modRead(properties)\
- \009local w, h = term.getSize()\
- \009local defaults = {replaceChar = nil, history = nil, visibleLength = nil, textLength = nil, \
- \009\009liveUpdates = nil, exitOnKey = nil}\
- \009if not properties then properties = {} end\
- \009for k, v in pairs(defaults) do if not properties[k] then properties[k] = v end end\
- \009if properties.replaceChar then properties.replaceChar = properties.replaceChar:sub(1, 1) end\
- \009if not properties.visibleLength then properties.visibleLength = w end\
- \
- \009local sx, sy = term.getCursorPos()\
- \009local line = \"\"\
- \009local pos = 0\
- \009local historyPos = nil\
- \
- \009local function redraw(repl)\
- \009\009local scroll = 0\
- \009\009if properties.visibleLength and sx + pos > properties.visibleLength + 1 then \
- \009\009\009scroll = (sx + pos) - (properties.visibleLength + 1)\
- \009\009end\
- \
- \009\009term.setCursorPos(sx, sy)\
- \009\009local a = repl or properties.replaceChar\
- \009\009if a then term.write(string.rep(a, line:len() - scroll))\
- \009\009else term.write(line:sub(scroll + 1, -1)) end\
- \009\009term.setCursorPos(sx + pos - scroll, sy)\
- \009end\
- \
- \009local function sendLiveUpdates(event, ...)\
- \009\009if type(properties.liveUpdates) == \"function\" then\
- \009\009\009local ox, oy = term.getCursorPos()\
- \009\009\009properties.liveUpdates(line, event, ...)\
- \009\009\009if a == true and data == nil then\
- \009\009\009\009term.setCursorBlink(false)\
- \009\009\009\009return line\
- \009\009\009elseif a == true and data ~= nil then\
- \009\009\009\009term.setCursorBlink(false)\
- \009\009\009\009return data\
- \009\009\009end\
- \009\009\009term.setCursorPos(ox, oy)\
- \009\009end\
- \009end\
- \
- \009term.setCursorBlink(true)\
- \009while true do\
- \009\009local e, but, x, y, p4, p5 = os.pullEvent()\
- \
- \009\009if e == \"char\" then\
- \009\009\009local s = false\
- \009\009\009if properties.textLength and line:len() < properties.textLength then s = true\
- \009\009\009elseif not properties.textLength then s = true end\
- \
- \009\009\009local canType = true\
- \009\009\009if not properties.grantPrint and properties.refusePrint then\
- \009\009\009\009local canTypeKeys = {}\
- \009\009\009\009if type(properties.refusePrint) == \"table\" then\
- \009\009\009\009\009for _, v in pairs(properties.refusePrint) do\
- \009\009\009\009\009\009table.insert(canTypeKeys, tostring(v):sub(1, 1))\
- \009\009\009\009\009end\
- \009\009\009\009elseif type(properties.refusePrint) == \"string\" then\
- \009\009\009\009\009for char in properties.refusePrint:gmatch(\".\") do\
- \009\009\009\009\009\009table.insert(canTypeKeys, char)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009\009for _, v in pairs(canTypeKeys) do if but == v then canType = false end end\
- \009\009\009elseif properties.grantPrint then\
- \009\009\009\009canType = false\
- \009\009\009\009local canTypeKeys = {}\
- \009\009\009\009if type(properties.grantPrint) == \"table\" then\
- \009\009\009\009\009for _, v in pairs(properties.grantPrint) do\
- \009\009\009\009\009\009table.insert(canTypeKeys, tostring(v):sub(1, 1))\
- \009\009\009\009\009end\
- \009\009\009\009elseif type(properties.grantPrint) == \"string\" then\
- \009\009\009\009\009for char in properties.grantPrint:gmatch(\".\") do\
- \009\009\009\009\009\009table.insert(canTypeKeys, char)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009\009for _, v in pairs(canTypeKeys) do if but == v then canType = true end end\
- \009\009\009end\
- \
- \009\009\009if s and canType then\
- \009\009\009\009line = line:sub(1, pos) .. but .. line:sub(pos + 1, -1)\
- \009\009\009\009pos = pos + 1\
- \009\009\009\009redraw()\
- \009\009\009end\
- \009\009elseif e == \"key\" then\
- \009\009\009if but == keys.enter then break\
- \009\009\009elseif but == keys.left then if pos > 0 then pos = pos - 1 redraw() end\
- \009\009\009elseif but == keys.right then if pos < line:len() then pos = pos + 1 redraw() end\
- \009\009\009elseif (but == keys.up or but == keys.down) and properties.history then\
- \009\009\009\009redraw(\" \")\
- \009\009\009\009if but == keys.up then\
- \009\009\009\009\009if historyPos == nil and #properties.history > 0 then \
- \009\009\009\009\009\009historyPos = #properties.history\
- \009\009\009\009\009elseif historyPos > 1 then \
- \009\009\009\009\009\009historyPos = historyPos - 1\
- \009\009\009\009\009end\
- \009\009\009\009elseif but == keys.down then\
- \009\009\009\009\009if historyPos == #properties.history then historyPos = nil\
- \009\009\009\009\009elseif historyPos ~= nil then historyPos = historyPos + 1 end\
- \009\009\009\009end\
- \
- \009\009\009\009if properties.history and historyPos then\
- \009\009\009\009\009line = properties.history[historyPos]\
- \009\009\009\009\009pos = line:len()\
- \009\009\009\009else\
- \009\009\009\009\009line = \"\"\
- \009\009\009\009\009pos = 0\
- \009\009\009\009end\
- \
- \009\009\009\009redraw()\
- \009\009\009\009sendLiveUpdates(\"history\")\
- \009\009\009elseif but == keys.backspace and pos > 0 then\
- \009\009\009\009redraw(\" \")\
- \009\009\009\009line = line:sub(1, pos - 1) .. line:sub(pos + 1, -1)\
- \009\009\009\009pos = pos - 1\
- \009\009\009\009redraw()\
- \009\009\009\009sendLiveUpdates(\"delete\")\
- \009\009\009elseif but == keys.home then\
- \009\009\009\009pos = 0\
- \009\009\009\009redraw()\
- \009\009\009elseif but == keys.delete and pos < line:len() then\
- \009\009\009\009redraw(\" \")\
- \009\009\009\009line = line:sub(1, pos) .. line:sub(pos + 2, -1)\
- \009\009\009\009redraw()\
- \009\009\009\009sendLiveUpdates(\"delete\")\
- \009\009\009elseif but == keys[\"end\"] then\
- \009\009\009\009pos = line:len()\
- \009\009\009\009redraw()\
- \009\009\009elseif properties.exitOnKey then \
- \009\009\009\009if but == properties.exitOnKey or (properties.exitOnKey == \"control\" and \
- \009\009\009\009\009\009(but == 29 or but == 157)) then \
- \009\009\009\009\009term.setCursorBlink(false)\
- \009\009\009\009\009return nil\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \
- \009\009sendLiveUpdates(e, but, x, y, p4, p5)\
- \009end\
- \
- \009term.setCursorBlink(false)\
- \009if line ~= nil then line = line:gsub(\"^%s*(.-)%s*$\", \"%1\") end\
- \009return line\
- end\
- \
- local function centerPrint(text, ny)\
- \009if type(text) == \"table\" then for _, v in pairs(text) do centerPrint(v) end\
- \009else\
- \009\009local x, y = term.getCursorPos()\
- \009\009local w, h = term.getSize()\
- \009\009term.setCursorPos(w/2 - text:len()/2 + (#text % 2 == 0 and 1 or 0), ny or y)\
- \009\009print(text)\
- \009end\
- end\
- \
- \
- -- -------- Updating\
- \
- local function download(url, path)\
- \009for i = 1, 3 do\
- \009\009local response = http.get(url)\
- \009\009if response then\
- \009\009\009local data = response.readAll()\
- \009\009\009response.close()\
- \009\009\009if path then\
- \009\009\009\009local f = io.open(path, \"w\")\
- \009\009\009\009f:write(data)\
- \009\009\009\009f:close()\
- \009\009\009end\
- \009\009\009return true\
- \009\009end\
- \009end\
- \
- \009return false\
- end\
- \
- local function updateClient()\
- \009local updateLocation = \"/.lightshot-update\"\
- \009fs.delete(updateLocation)\
- \
- \009download(lightshotURL, updateLocation)\
- \009local a = io.open(updateLocation, \"r\")\
- \009local b = io.open(lightshotLocation, \"r\")\
- \009local new = a:read(\"*a\")\
- \009local cur = b:read(\"*a\")\
- \009a:close()\
- \009b:close()\
- \
- \009if cur ~= new then\
- \009\009fs.delete(lightshotLocation)\
- \009\009fs.move(updateLocation, lightshotLocation)\
- \009\009return true\
- \009else\
- \009\009fs.delete(updateLocation)\
- \009\009return false\
- \009end\
- end\
- \
- \
- -- -------- Compression\
- \
- local sD = {{}}\
- local cD = {}\
- \
- local function proccessFunction(data)\
- \009if data:len() < 8 then\
- \009\009if data:sub(-1,-1) == \"]\" then return \"[[\" .. data .. \"] .. \\\"]\\\"\"\
- \009\009else return \"[[\" .. data .. \"]]\" end\
- \009end\
- \009if cD[v] then return cD[v] end\
- \009for k, v in pairs(sD[#sD]) do\
- \009\009if v == data then\
- \009\009\009cD[v] = (\"sD[\" .. #sD .. \"][\" .. k .. \"]\")\
- \009\009\009return(\"sD[\" .. #sD .. \"][\" .. k .. \"]\")\
- \009\009end\
- \009end\
- \009table.insert(sD[#sD], data)\
- \009local returnData = (\"sD[\".. #sD .. \"][\" .. #sD[#sD] .. \"]\")\
- \009if #sD[#sD] > loopRate then sD[#sD + 1] = {} end\
- \009return returnData\
- end\
- \
- \
- -- -------- Terminal Override\
- \
- local function add(...)\
- \009if not handle then\
- \009\009if fs.exists(recordLocation) then\
- \009\009\009handle = io.open(recordLocation, \"a\")\
- \009\009else\
- \009\009\009handle = io.open(recordLocation, \"w\")\
- \009\009end\
- \009end\
- \
- \009for _, v in pairs({...}) do\
- \009\009handle:write(v)\
- \009end\
- end\
- \
- local bg, tc, blnk = -1, -1, nil\
- for k, v in pairs(term.native()) do oldTerm[k] = v end\
- \
- newTerm.write = function(...)\
- \009local text = \"\"\
- \009for k, v in pairs({...}) do text = text .. tostring(v) end\
- \
- \009local a = \"\"\
- \009if not paused and os.clock() - clock > 0 then\
- \009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009end\
- \009text = proccessFunction(text)\
- \009local b = \"c(\" .. text .. \")\\n\"\
- \
- \009add(a .. b)\
- \009clock = os.clock()\
- \
- \009if not nfaRecording then return oldTerm.write(...) end\
- end\
- \
- newTerm.setCursorPos = function(x, y)\
- \009local a = \"\"\
- \009if not paused and os.clock() - clock > 0 then\
- \009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009end\
- \009add(a .. \"d(\" .. tostring(x) .. \", \" .. tostring(y) .. \")\\n\")\
- \009clock = os.clock()\
- \
- \009return oldTerm.setCursorPos(x, y)\
- end\
- \
- newTerm.getCursorPos = function(...) return oldTerm.getCursorPos(...) end\
- \
- newTerm.setBackgroundColor = function(col)\
- \009if bg ~= col then\
- \009\009local a = \"\"\
- \009\009if not paused and not nfaRecording and os.clock() - clock > 0 then\
- \009\009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009\009end\
- \
- \009\009add(a .. \"e(\" .. tostring(col) .. \")\\n\")\
- \009\009clock = os.clock()\
- \009\009bg = col\
- \009end\
- \
- \009return oldTerm.setBackgroundColor(col)\
- end\
- \
- newTerm.setTextColor = function(col)\
- \009if tc ~= col then\
- \009\009local a = \"\"\
- \009\009if not paused and not nfaRecording and os.clock() - clock > 0 then\
- \009\009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009\009end\
- \
- \009\009add(a .. \"f(\" .. tostring(col) .. \")\\n\")\
- \009\009clock = os.clock()\
- \009\009tc = col\
- \009end\
- \
- \009return oldTerm.setTextColor(col)\
- end\
- \
- newTerm.setBackgroundColour = function(col) return term.setBackgroundColor(col) end\
- newTerm.setTextColour = function(col) return term.setTextColor(col) end\
- \
- newTerm.clear = function(...)\
- \009local a = \"\"\
- \009if not paused and os.clock() - clock > 0 then\
- \009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009end\
- \009add(a .. \"g()\\n\")\
- \009clock = os.clock()\
- \
- \009return oldTerm.clear(...)\
- end\
- \
- newTerm.clearLine = function(...)\
- \009local a = \"\"\
- \009if not paused and os.clock() - clock > 0 then\
- \009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009end\
- \009add(a .. \"h()\\n\")\
- \009clock = os.clock()\
- \
- \009return oldTerm.clearLine(...)\
- end\
- \
- newTerm.setCursorBlink = function(flag)\
- \009if flag ~= blnk then\
- \009\009local a = \"\"\
- \009\009if not paused and os.clock() - clock > 0 then\
- \009\009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009\009end\
- \009\009add(a .. \"i(\" .. tostring(flag) .. \")\\n\")\
- \009\009clock = os.clock()\
- \009\009blnk = flag\
- \009end\
- \
- \009return oldTerm.setCursorBlink(flag)\
- end\
- \
- newTerm.scroll = function(n)\
- \009local a = \"\"\
- \009if not paused and os.clock() - clock > 0 then\
- \009\009a = \"sp(\" .. os.clock() - clock .. \") \"\
- \009end\
- \009add(a .. \"j(\" .. tostring(n) .. \")\\n\")\
- \009clock = os.clock()\
- \
- \009return oldTerm.scroll(n)\
- end\
- \
- newTerm.getSize = function(...) return oldTerm.getSize(...) end\
- newTerm.redirect = function(...) return oldTerm.redirect(...) end\
- newTerm.restore = function(...) return oldTerm.restore(...) end\
- newTerm.isColor = function(...) return oldTerm.isColor and oldTerm.isColor(...) end\
- newTerm.isColour = function(...) return term.isColor(...) end\
- \
- \
- -- -------- Recording\
- \
- local function record(location)\
- \009while true do\
- \009\009local e, key = os.pullEventRaw()\
- \009\009if (e == \"key\" and key == 59) or e == event_exitRecording or e == \"terminate\" then\
- \009\009\009local a = \"\"\
- \009\009\009if os.clock() - clock > 0 then a = \"sp(\" .. os.clock() - clock .. \") \" end\
- \009\009\009add(a)\
- \
- \009\009\009add(\"\\n\\nterm.setCursorBlink(false)\\n\")\
- \009\009\009add(\"if term.isColor() then term.setTextColor(colors.yellow)\\n\")\
- \009\009\009add(\"else term.setTextColor(colors.white) end\\n\")\
- \009\009\009add(\"term.setBackgroundColor(colors.black)\\n\")\
- \009\009\009add(\"term.clear()\\n\")\
- \009\009\009add(\"term.setCursorPos(1, 1)\\n\")\
- \009\009\009add(\"print(\\\"End of Recording!\\\")\\n\")\
- \
- \009\009\009local sd = \"local sD = \" .. textutils.serialize(sD) .. \"\\n\"\
- \
- \009\009\009term.redirect(term.native())\
- \009\009\009term.setCursorBlink(false)\
- \
- \009\009\009handle:close()\
- \009\009\009handle = nil\
- \009\009\009local f = io.open(recordLocation, \"r\")\
- \009\009\009local ncont = f:read(\"*a\")\
- \009\009\009f:close()\
- \
- \009\009\009ncont = ncont:gsub(\"%-%- sD here...\\n\", sd)\
- \009\009\009local f = io.open(location, \"w\")\
- \009\009\009f:write(ncont)\
- \009\009\009f:close()\
- \009\009\009fs.delete(recordLocation)\
- \
- \009\009\009break\
- \009\009elseif e == \"key\" and key == 61 then\
- \009\009\009paused = not paused\
- \009\009\009if paused then\
- \009\009\009\009add(\"sp(2)\\n\")\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- \
- \
- -- -------- Movie\
- \
- local function loadNfa(path)\
- \009local ret = {}\
- \009if fs.exists(path) and not fs.isDir(path) then\
- \009\009local f = io.open(path, \"r\")\
- \009\009local l = f:read(\"*l\")\
- \009\009local curFrame = \"\"\
- \009\009while l do\
- \009\009\009if l ~= \"\" and l ~= \"~\" then curFrame = curFrame .. l .. \"\\n\"\
- \009\009\009elseif l == \"~\" then\
- \009\009\009\009table.insert(ret, curFrame)\
- \009\009\009\009curFrame = \"\"\
- \009\009\009end\
- \009\009\009l = f:read(\"*l\")\
- \009\009end\
- \009\009f:close()\
- \009end\
- \
- \009return ret\
- end\
- \
- local function movie(location, duration)\
- \009nfaRecording = true\
- \009local frames = loadNfa(location)\
- \009if frames ~= {} then\
- \009\009for i, v in ipairs(frames) do\
- \009\009\009term.setTextColor(colors.white)\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clear()\
- \
- \009\009\009local tempImageLocation = \"/.lightshot-temp-image\"\
- \009\009\009local f = io.open(tempImageLocation, \"w\")\
- \009\009\009f:write(v)\
- \009\009\009f:close()\
- \009\009\009local a = paintutils.loadImage(tempImageLocation)\
- \009\009\009paintutils.drawImage(a, 1, 1)\
- \009\009\009fs.delete(tempImageLocation)\
- \009\009\009add(\"sp(\" .. duration .. \")\\n\")\
- \009\009end\
- \
- \009\009add(\"sp(\" .. duration .. \")\\n\")\
- \009end\
- \
- \009add(\"\\n\\nterm.setCursorBlink(false)\\n\")\
- \009add(\"if term.isColor() then term.setTextColor(colors.yellow)\\n\")\
- \009add(\"else term.setTextColor(colors.white) end\\n\")\
- \009add(\"term.setBackgroundColor(colors.black)\\n\")\
- \009add(\"term.clear()\\n\")\
- \009add(\"term.setCursorPos(1, 1)\\n\")\
- \009add(\"print(\\\"The End! :D\\\")\\n\")\
- \
- \009nfaRecording = false\
- \009term.restore()\
- \009term.setCursorBlink(false)\
- \009if term.isColor() then term.setTextColor(colors.yellow)\
- \009else term.setTextColor(colors.white) end\
- \009term.setBackgroundColor(colors.black)\
- \009term.clear()\
- \009term.setCursorPos(1, 1)\
- \009print(\"Movie Recorded Successfully!\")\
- \
- \009handle:close()\
- \009handle = nil\
- \009local f = io.open(recordLocation, \"r\")\
- \009local ncont = f:read(\"*a\")\
- \009f:close()\
- \
- \009local sd = \"local sD = \" .. textutils.serialize(sD) .. \"\\n\"\
- \009ncont = ncont:gsub(\"%-%- sD here...\\n\", sd)\
- \009local f = io.open(location, \"w\")\
- \009f:write(ncont)\
- \009f:close()\
- \009fs.delete(recordLocation)\
- end\
- \
- \
- -- -------- Main\
- \
- local theme = {}\
- if term.isColor and term.isColor() then\
- \009theme = {\
- \009\009[\"prompt\"] = \"cyan\",\
- \009\009[\"promptHighlight\"] = \"lightBlue\",\
- \009\009[\"textColor\"] = \"white\",\
- \009}\
- else\
- \009theme = {\
- \009\009[\"prompt\"] = \"black\",\
- \009\009[\"promptHighlight\"] = \"black\",\
- \009\009[\"textColor\"] = \"white\",\
- \009}\
- end\
- \
- local function drawButton(v, sel)\
- \009if sel then term.setBackgroundColor(v.highlight or colors[theme.promptHighlight])\
- \009else term.setBackgroundColor(v.bg or colors[theme.prompt]) end\
- \009term.setTextColor(v.tc or colors[theme.textColor])\
- \009for i = -1, 1 do\
- \009\009term.setCursorPos(v[2], v[3] + i)\
- \009\009term.write(string.rep(\" \", v[1]:len() + 4))\
- \009end\
- \
- \009term.setCursorPos(v[2], v[3])\
- \009if sel then\
- \009\009term.setBackgroundColor(v.highlight or colors[theme.promptHighlight])\
- \009\009term.write(\" > \")\
- \009else term.write(\" - \") end\
- \009term.write(v[1] .. \" \")\
- end\
- \
- local function prompt(list, dir)\
- \009local function draw(sel)\
- \009\009for i, v in ipairs(list) do\
- \009\009\009if i == sel then term.setBackgroundColor(v.highlight or colors[theme.promptHighlight])\
- \009\009\009else term.setBackgroundColor(v.bg or colors[theme.prompt]) end\
- \009\009\009term.setTextColor(v.tc or colors[theme.textColor])\
- \009\009\009for i = -1, 1 do\
- \009\009\009\009term.setCursorPos(v[2], v[3] + i)\
- \009\009\009\009term.write(string.rep(\" \", v[1]:len() + 4))\
- \009\009\009end\
- \
- \009\009\009term.setCursorPos(v[2], v[3])\
- \009\009\009if i == sel then\
- \009\009\009\009term.setBackgroundColor(v.highlight or colors[theme.promptHighlight])\
- \009\009\009\009term.write(\" > \")\
- \009\009\009else term.write(\" - \") end\
- \009\009\009term.write(v[1] .. \" \")\
- \009\009end\
- \009end\
- \
- \009local sel = 1\
- \009draw(sel)\
- \
- \009while true do\
- \009\009local e, but, x, y = os.pullEvent()\
- \009\009if e == \"key\" and but == 28 then return list[sel][1]\
- \009\009elseif e == \"key\" and but == 200 and sel > 1 then\
- \009\009\009sel = sel - 1\
- \009\009\009draw(sel)\
- \009\009elseif e == \"key\" and but == 208 and ((err == true and sel < #list - 1) or (sel < #list)) then\
- \009\009\009sel = sel + 1\
- \009\009\009draw(sel)\
- \009\009elseif e == \"key\" and but == 203 and sel > 2 then\
- \009\009\009sel = sel - 2\
- \009\009\009draw(sel)\
- \009\009elseif e == \"key\" and but == 205 and sel < 3 then\
- \009\009\009sel = sel + 2\
- \009\009\009draw(sel)\
- \009\009elseif e == \"mouse_click\" then\
- \009\009\009for i, v in ipairs(list) do\
- \009\009\009\009if x >= v[2] - 1 and x <= v[2] + v[1]:len() + 3 and y >= v[3] - 1 and y <= v[3] + 1 then\
- \009\009\009\009\009return list[i][1]\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- \
- local function menu()\
- \009term.setBackgroundColor(colors.gray)\
- \009term.setTextColor(colors.white)\
- \009term.clear()\
- \009term.setCursorPos(1, 1)\
- \
- \009term.setBackgroundColor(colors.lightGray)\
- \009for i = 2, 4 do term.setCursorPos(1, i) term.clearLine() end\
- \009term.setCursorPos(3, 3)\
- \009term.write(\"Lightshot \" .. version)\
- \
- \009local opt = prompt({{\"Record a Video\", w/2 - 16, 9}, {\"Record an Animation\", w/2 - 21, 13},\
- \009\009{\"Update Lightshot\", w/2 + 4, 9}, {\"Exit\", w/2 + 4, 13, bg = (term.isColor and term.isColor())\
- \009\009and colors.red or colors.black, highlight = (term.isColor and term.isColor()) and colors.pink\
- \009\009or colors.black}}, \"vertical\")\
- \009if opt == \"Record a Video\" or opt == \"Record an Animation\" then\
- \009\009term.setBackgroundColor(colors.gray)\
- \009\009for i = 7, 14 do term.setCursorPos(1, i) term.clearLine() end\
- \009\009term.setBackgroundColor(colors.cyan)\
- \009\009for i = 8, 11 do term.setCursorPos(7, i) term.write(string.rep(\" \", w - 14)) end\
- \009\009drawButton({\"Control to Return to Menu\", 7, 14}, true)\
- \009\009term.setBackgroundColor(colors.cyan)\
- \009\009term.setCursorPos(8, 9)\
- \009\009term.write(\"Where to save the recording?\")\
- \009\009term.setCursorPos(9, 10)\
- \009\009term.write(\"/\")\
- \009\009local loc = modRead({visibleLength = w - 14, exitOnKey = \"control\"})\
- \009\009if not loc or loc == \"\" then return \"menu\" end\
- \
- \009\009term.setCursorPos(8, 9)\
- \009\009term.write(string.rep(\" \", 28))\
- \009\009term.setCursorPos(8, 9)\
- \009\009loc = \"/\" .. loc\
- \009\009if fs.isReadOnly(loc) then term.write(\"File is Read Only!\") sleep(1.6) return \"menu\"\
- \009\009elseif fs.isDir(loc) then term.write(\"Location is a directory!\") sleep(1.6) return \"menu\"\
- \009\009elseif opt == \"Record a Video\" then\
- \009\009\009if fs.exists(loc) then fs.delete(loc) end\
- \009\009\009term.setTextColor(colors.white)\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clear()\
- \009\009\009term.setCursorPos(2, 5)\
- \009\009\009term.write(\"Press F1 to end the recording\")\
- \009\009\009term.setCursorPos(2, 6)\
- \009\009\009term.write(\"Press F3 to pause or unpause the recording\")\
- \
- \009\009\009if term.isColor and term.isColor() then term.setTextColor(colors.yellow) end\
- \009\009\009for i = 1, 3 do\
- \009\009\009\009term.setCursorPos(2, 3)\
- \009\009\009\009term.clearLine()\
- \009\009\009\009term.write(\"Recording in \" .. 4 - i .. \"...\")\
- \009\009\009\009sleep(1)\
- \009\009\009end\
- \
- \009\009\009return \"record\", loc\
- \009\009elseif opt == \"Record an Animation\" then\
- \009\009\009if loc:sub(-4, -1) ~= \".nfa\" then\
- \009\009\009\009term.write(\"File Not An nPaintPro Animation!\")\
- \009\009\009\009sleep(1.6)\
- \009\009\009\009return \"menu\"\
- \009\009\009end\
- \
- \009\009\009term.setCursorPos(8, 9)\
- \009\009\009term.write(\"Duration between frames (seconds):\")\
- \009\009\009term.setCursorPos(9, 10)\
- \009\009\009term.write(string.rep(\" \", w - 16))\
- \009\009\009term.setCursorPos(9, 10)\
- \009\009\009local dur = modRead({visibleLength = w - 14, exitOnKey = \"control\"})\
- \009\009\009if not dur or dur == \"\" then return \"menu\" end\
- \
- \009\009\009term.setCursorPos(8, 9)\
- \009\009\009term.write(string.rep(\" \", 38))\
- \009\009\009term.setCursorPos(8, 9)\
- \009\009\009dur = tonumber(dur)\
- \009\009\009if not dur then term.write(\"Duration must be an integer!\") sleep(1.6) return \"menu\"\
- \009\009\009else return \"tomovie\", loc, dur end\
- \009\009end\
- \009elseif opt == \"Update Lightshot\" then\
- \009\009term.setTextColor(colors.white)\
- \009\009term.setBackgroundColor(colors.lightGray)\
- \009\009term.setCursorPos(3, 3)\
- \009\009term.clearLine()\
- \009\009term.write(\"Checking for Updates...\")\
- \009\009term.setCursorPos(3, 3)\
- \009\009if updateClient() then\
- \009\009\009term.clearLine()\
- \009\009\009term.write(\"Updated!\")\
- \009\009\009sleep(1.6)\
- \009\009\009opt = \"Exit\"\
- \009\009else\
- \009\009\009term.clearLine()\
- \009\009\009term.write(\"No Updates Found!\")\
- \009\009\009sleep(1.6)\
- \009\009\009return \"menu\"\
- \009\009end\
- \009end if opt == \"Exit\" then return nil end\
- end\
- \
- local function main()\
- \009local action, location, duration = \"menu\", nil, nil\
- \009while action == \"menu\" do action, location, duration = menu() end\
- \
- \009if action and location then\
- \009\009clock = os.clock()\
- \009\009add(recordHeader)\
- \009\009term.redirect(newTerm)\
- \
- \009\009term.setTextColor(colors.white)\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clear()\
- \009\009term.setCursorPos(1, 1)\
- \009\009if action == \"record\" then\
- \009\009\009parallel.waitForAny(function()\
- \009\009\009\009record(location)\
- \009\009\009end, function()\
- \009\009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009\009term.setTextColor(colors.white)\
- \009\009\009\009term.clear()\
- \009\009\009\009term.setCursorPos(1, 1)\
- \
- --[[\
- \009\009\009\009-- Run startup\
- \009\009\009\009if fs.exists(\"/startup\") and not fs.isDir(\"/startup\") then shell.run(\"/startup\") end\
- \009\009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009\009term.setTextColor(colors.white)\
- \009\009\009\009term.clear()\
- \009\009\009\009term.setCursorPos(1, 1)\
- ]]--\
- \
- \009\009\009\009-- Run shell\
- \009\009\009\009shell.run(\"/rom/programs/shell\")\
- \009\009\009\009os.queueEvent(event_exitRecording)\
- \009\009\009end)\
- \
- \009\009\009if term.isColor() then term.setTextColor(colors.yellow)\
- \009\009\009else term.setTextColor(colors.white) end\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clear()\
- \009\009\009term.setCursorPos(2, 3)\
- \009\009\009print(\"Recording Saved!\")\
- \009\009\009sleep(1.1)\
- \009\009elseif action == \"tomovie\" then\
- \009\009\009movie(location, duration)\
- \009\009end\
- \009else\
- \009\009return \"exit\"\
- \009end\
- end\
- \
- -- Run\
- local oldDir = shell.dir()\
- while main() ~= \"exit\" do end\
- shell.setDir(oldDir)\
- \
- -- Exit Message\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.white)\
- term.clear()\
- term.setCursorPos(1, 1)\
- centerPrint(\"Thanks for Using Lightshot \" .. version .. \"!\")\
- centerPrint(\"Made by GravityScore and 1lann\")",
- },
- [ "programs/RedLevel/" ] = {
- content = "--]] Block Table [--\
- term.redirect(term.native())\
- local w, h = term.getSize()\
- local sMenuIndex = 1\
- local inSave = false\
- local inGame = true\
- local sPlay = false\
- local bOff = 2\
- local selBlock = bOff\
- \
- local map = {}\
- local blocks = {\
- [0]={name=\"Air\",color=\"black\",bcolor=\"black\",graphic=\" \",solid=false},\
- {name=\"Player\",color=\"blue\",bcolor=\"black\",graphic=\"@\",solid=true},\
- {name=\"Dirt\",color=\"yellow\",bcolor=\"brown\",graphic=\" \",solid=true}, -- 1\
- {name=\"Stone\",color=\"lightGray\",bcolor=\"gray\",graphic=\"@\",solid=true}, -- 2\
- {name=\"Sand\",color=\"white\",bcolor=\"yellow\",graphic=\"+\",solid=true}, -- 3\
- {name=\"Scifi\",color=\"purple\",bcolor=\"blue\",graphic=\"0\",solid=true}, -- 4\
- {name=\"Grass\",color=\"green\",bcolor=\"brown\",graphic=\"*\",solid=true}, -- 5\
- {name=\"Iron\",color=\"white\",bcolor=\"lightGray\",graphic=\"/\",solid=true}, -- 6\
- {name=\"Gravel\",color=\"white\",bcolor=\"brown\",graphic=\"G\",solid=true}, -- 7\
- {name=\"Quartz\",color=\"lightGray\",bcolor=\"white\",graphic=\"X\",solid=true}, -- 8\
- }\
- \
- \
- \
- local sMenu = {\
- {name=\"Save\",run=function()\
- \
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Export BlockMap To File : \")\
- tf = read()\
- f = fs.open(tf,\"w\")\
- f.write(textutils.serialize(blocks))\
- f.close()\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Exported To File - \"..tf) \
- os.pullEvent(\"key\") \
- \
- term.setCursorPos(1,h)\
- term.clearLine() \
- write(\"Save Map As: \")\
- sa=read()\
- f = fs.open(sa,\"w\")\
- --for i = 1, #map do\
- -- f.writeLine(table.concat(map[i]))\
- -- end\
- f.write(textutils.serialize(map):gsub(\"\\n%s*\",\"\"))\
- f.close()\
- term.setCursorPos(1,h)\
- term.clearLine() write(\"Saved As \"..sa)\
- drawMap()\
- inSave=false\
- end};\
- {name=\"Load\",run=function()\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Blocks Map File : \")\
- tf = read()\
- f = fs.open(tf,\"r\")\
- blocks = textutils.unserialize(f.readAll())\
- f.close()\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Imported From File - \"..tf) \
- os.pullEvent(\"key\")\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Load Map: \")\
- sa=read()\
- \
- if(fs.exists(sa) and sa ~= \"\" and sa ~= \" \")then\
- f = fs.open(sa,\"r\")\
- smap = textutils.unserialize(f.readAll())\
- f.close()\
- if(type(smap) ~= \"table\")then\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Not a valid save file!\")\
- os.pullEvent(\"key\")\
- else\
- term.setCursorPos(1,h)\
- term.clearLine()\
- map=smap\
- write(\"Save loaded \"..sa)\
- os.pullEvent(\"key\") \
- end\
- -- for line in f.readLine do\
- -- map[#map+1] = {}\
- -- for i = 1, #line do\
- -- local l = line:sub(i,i)\
- -- map[#map][i] = tonumber(l) or tostring(l)\
- -- end\
- -- end\
- else\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"File Not Found - \"..sa) \
- os.pullEvent(\"key\") \
- end\
- inSave=false\
- drawMap()\
- end};\
- -- {name=\"Play\",run=function()\
- -- sPlay=true\
- -- inSave=false\
- -- end};\
- \
- {name=\"AddBlock\",run=function()\
- term.setCursorPos(1,h)\
- term.clearLine()\
- local nb = {}\
- write(\"Name: \")\
- nbName = read()\
- write(\"TextColor: \")\
- nbTCol= read()\
- write(\"BackColor: \")\
- nbBCol = read()\
- write(\"Graphic: \")\
- nbGraph = read()\
- write(\"Solid?: \")\
- sol = read()\
- \009 \
- \009if(sol == \"true\")then\
- \009 issol = true;\
- \009else\
- \009 issol = false;\
- \009end\
- \
- nb = {name=nbName,color=nbTCol,bcolor=nbBCol,graphic=nbGraph,solid=issol}\
- \
- table.insert(blocks,nb)\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Block Created - \"..nbName) \
- os.pullEvent(\"key\") \
- inSave=false\
- drawMap()\
- end};\
- \
- \
- {name=\"RemoveBlock\",run=function()\
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Name: \")\
- nbName = read()\
- for i = 1, #blocks do\
- if(blocks[i].name == nbName)then\
- table.remove(blocks,i)\
- end\
- end\
- \
- term.setCursorPos(1,h)\
- term.clearLine()\
- write(\"Block(s) Removed - \"..nbName) \
- os.pullEvent(\"key\") \
- drawMenu()\
- inSave=false\
- drawMap()\
- end};\
- \
- {name=\"Exit\",run=function() inGame = false\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.white)\
- term.clear()\
- term.setCursorPos(1,1)\
- end};\
- }\
- \
- function drawMenu()\
- term.setCursorPos(1,h)\
- term.setTextColor(colors.white)\
- term.setBackgroundColor(colors.gray)\
- if(not inSave)then\
- if(selBlock < 8)then mCalc = bOff else mCalc = (selBlock-(8+(bOff-1)))+bOff end\
- for i = mCalc, (mCalc-1)+8 do\
- if(blocks[i]==nil)then \
- selBlock = 1\
- else\
- if(i ~= selBlock)then\
- write(\"[\")\
- term.setTextColor(colors[blocks[i].color])\
- term.setBackgroundColor(colors[blocks[i].bcolor])\
- write(blocks[i].graphic)\
- term.setTextColor(colors.white)\
- term.setBackgroundColor(colors.gray)\
- write(\"] \")\
- else\
- write(\">\")\
- term.setTextColor(colors[blocks[i].color])\
- term.setBackgroundColor(colors[blocks[i].bcolor])\
- write(blocks[i].graphic)\
- term.setTextColor(colors.white)\
- term.setBackgroundColor(colors.gray)\
- write(\"< \")\
- end \
- end\
- end\
- term.setTextColor(colors.yellow)\
- write(\"Press Ctrl For Menu\")\
- end\
- \
- if(inSave)then\
- term.setCursorPos(1,h)\
- term.clearLine()\
- term.setTextColor(colors.white)\
- for i = 1, #sMenu do\
- if(i == sMenuIndex)then\
- term.setTextColor(colors.yellow)\
- write(\"[\")\
- term.setTextColor(colors.white)\
- write(sMenu[i].name)\
- term.setTextColor(colors.yellow)\
- write(\"]\")\
- else\
- term.setTextColor(colors.yellow)\
- write(\" \")\
- term.setTextColor(colors.white)\
- write(sMenu[i].name)\
- term.setTextColor(colors.yellow)\
- write(\" \") \
- end \
- term.setTextColor(colors.white)\
- end\
- end\
- end\
- \
- function buildMap(w,h)\
- for i = 1, h do\
- map[i] = {}\
- for c = 1, w do\
- map[i][c] = 0\
- end \
- end\
- end\
- \
- function drawMap()\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- term.setCursorPos(1,1)\
- for i = 1, #map do\
- for c = 1, #map[i] do\
- if(blocks[map[i][c]] == nil)then map[i][c] = 0 end\
- term.setTextColor(colors[blocks[map[i][c]].color])\
- term.setBackgroundColor(colors[blocks[map[i][c]].bcolor])\
- write(blocks[map[i][c]].graphic) \
- end\
- write(\"\\n\")\
- end \
- end\
- \
- function isPlayer()\
- local is = false\
- for i = 1, #map do\
- for c = 1, #map[i] do\
- if(map[i][c] == tonumber(4))then\
- is=true\
- end\
- end\
- end\
- return is\
- end\
- \
- function getPlayerX()\
- local fx = 1\
- for i = 1, #map do\
- for c = 1, #map[i] do\
- if(map[i][c] == tonumber(4))then\
- fx=i\
- end\
- end\
- end\
- return fx\
- end\
- \
- function getPlayerY()\
- local fy = 1\
- for i = 1, #map do\
- for c = 1, #map[i] do\
- if(map[i][c] == tonumber(4))then\
- fy=c\
- end\
- end\
- end\
- return fy\
- end\
- \
- function drawMapBlock(x,y)\
- if(blocks[map[x][y]] == nil)then map[x][y] = 0 end\
- term.setCursorPos(tonumber(y),tonumber(x))\
- term.setTextColor(colors[blocks[map[x][y]].color])\
- term.setBackgroundColor(colors[blocks[map[x][y]].bcolor])\
- print(blocks[map[x][y]].graphic) \
- end\
- \
- function placeBlock(id,x,y)\
- for i = 1, #blocks do\
- \
- if(i == id)then\
- map[x][y] = id \
- end\
- end\
- end\
- \
- function breakBlock(x,y)\
- map[x][y] = 0\
- end\
- \
- buildMap(w,h-1)\
- drawMap()\
- \
- \
- \
- \
- function update()\
- drawMenu()\
- \
- a = {os.pullEvent()}\
- term.setCursorPos(1,1)\
- --if(a[1]==\"timer\" and not sPlay)then gTimer=os.startTimer(fps) end\
- \
- if( (a[1] == \"mouse_click\" and a[4] < h) or (a[1] == \"mouse_drag\" and a[4] < h) and not inSave)then\
- if(a[2] == 1)then\
- placeBlock(selBlock,a[4],a[3]) \
- drawMapBlock(a[4],a[3]) \
- elseif(a[2] == 2)then\
- breakBlock(a[4],a[3]) \
- drawMapBlock(a[4],a[3]) \
- end\
- elseif(a[1] == \"mouse_scroll\" and not inSave )then \
- if(a[2] == 1 and selBlock < #blocks)then\
- selBlock = selBlock + 1\
- elseif(a[2] == -1 and selBlock > bOff) then\
- selBlock = selBlock - 1\
- end\
- elseif(a[1] == \"key\")then\
- if(a[2] == keys.enter and inSave)then sMenu[sMenuIndex].run() end\
- if(a[2] == 29)then inSave = not inSave end\
- if(a[2] == keys.left and sMenuIndex > 1 and inSave)then\
- sMenuIndex = sMenuIndex - 1\
- elseif(a[2] == keys.right and sMenuIndex < #sMenu and inSave)then\
- sMenuIndex = sMenuIndex + 1 \
- end\
- end\
- end\
- \
- while inGame do\
- update() \
- end",
- },
- [ "apis/Redgame/" ] = {
- content = "--]] RedGame API By: Redxone[[--\
- \
- function init()\
- \009w,h = term.getSize()\
- \009pmap = {}\
- \009 for i = 1, h do\
- pmap[i] = {}\
- for c = 1, w do\
- pmap[i][c] = 0\
- end \
- end\
- \
- gmap = {}\
- \009emp={}\
- \009gplayer={}\
- \009gblocks={}\
- \009doors={}\
- \009maps={}\
- \009mapName = \"\"\
- \
- end\
- \
- function getGMAP()\
- \009return gmap\
- end\
- \
- function getPMAP()\
- \009return pmap\
- end\
- \
- function getGBLOCKS()\
- \009return gblocks\
- end\
- \
- function setPMAP(x,y,id)\
- \009pmap[y][x] = id\
- end\
- \
- function setGMAP(x,y,id)\
- \009gmap[y][x] = id\
- end\
- \
- function openTextbox()\
- \009paintutils.drawBox(1,h-5,w,h,colors.gray)\
- \009paintutils.drawFilledBox(2,h-4,w-1,h-1,colors.blue)\
- end\
- \
- clearTextbox = openTextbox\
- \
- function drawTextbox(text,ln,speed)\
- \009term.setCursorPos(6,h- ( 4 - ( ln-1 ) ) )\
- \009term.setTextColor(colors.white)\
- \009textutils.slowPrint(text,speed)\
- end\
- \
- function createYesNo(YText,NText,ln)\
- \009local sel = 1\
- \009local waiting = true\
- \009local opt = {\
- \009\009{name=YText};\
- \009\009{name=NText};\
- \009}\
- \
- \009function waitResult()\
- \009\009while waiting do\
- \009\009\009for i = 1, #opt do\
- \009\009\009\009term.setCursorPos((w/2) - #opt[i].name/2,h- ( 4 - ( (ln+i)-1 ) ) )\
- \009\009\009\009if(sel == i )then\
- \009\009\009\009\009write(\"[\"..opt[i].name..\"]\")\
- \009\009\009\009else\
- \009\009\009\009\009write(\" \"..opt[i].name..\" \")\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009a = {os.pullEvent(\"key\")}\
- \
- \009\009\009if(a[2] == keys.w and sel > 1)then\
- \009\009\009\009sel = sel - 1\
- \009\009\009end\
- \009\009\009if(a[2] == keys.s and sel < #opt)then\
- \009\009\009\009sel = sel + 1\
- \009\009\009end\
- \009\009\009if(a[2] == keys.space)then\
- \009\009\009\009if(sel == 1)then waiting = false return \"ok\" end\
- \009\009\009\009if(sel == 2)then waiting = false return \"no\" end\
- \009\009\009end\
- \009\009end\
- \009end\
- \009return waitResult()\
- end\
- \
- \
- function addDoor(fromx,fromy,tox,toy,fromMap,toMap)\
- \009doors[#doors+1] = {fx=fromx,fy=fromy,tx=tox,ty=toy,fMap=fromMap,tMap=toMap}\
- end\
- \
- function draw()\
- \
- \009for i = 1, #gmap do\
- \009\009for c = 1, #gmap[i] do\
- \009\009\009term.setCursorPos(c,i)\
- \009\009\009term.setTextColor(colors[ gblocks[ gmap[i][c] ].color ])\
- \009\009\009term.setBackgroundColor(colors[ gblocks[ gmap[i][c] ].bcolor ])\
- \009\009\009write(gblocks[ gmap[i][c] ].graphic)\
- \009\009end\
- \009end\
- \
- \009for i = 1, #pmap do\
- \009\009for c = 1, #pmap[i] do\
- \009\009\009if(pmap[i][c] ~= 0)then\
- \009\009\009\009term.setCursorPos(c,i)\
- \009\009\009\009term.setTextColor(colors[ gblocks[ pmap[i][c] ].color ])\
- \009\009\009\009term.setBackgroundColor(colors[ gblocks[ pmap[i][c] ].bcolor ])\
- \009\009\009\009write(gblocks[ pmap[i][c] ].graphic)\
- \009\009\009end\
- \009\009end\
- \009end\
- \
- end\
- \
- \
- function closeTextbox()\
- \009os.pullEvent(\"key\")\
- \009draw()\
- \009term.setCursorPos(1,h)\
- \009term.setBackgroundColor(colors[gblocks[0].bcolor])\
- \009term.clearLine()\
- end\
- \
- function closeTextboxRaw()\
- \009draw()\
- \009term.setCursorPos(1,h)\
- \009term.setBackgroundColor(colors[gblocks[0].bcolor])\
- \009term.clearLine()\
- end\
- \
- \
- function drawMapPixel(x,y)\
- \009term.setCursorPos(y,x)\
- \009term.setTextColor(colors[ gblocks[ gmap[x][y] ].color ])\
- \009term.setBackgroundColor(colors[ gblocks[ gmap[x][y] ].bcolor ])\
- \009write(gblocks[ gmap[x][y] ].graphic)\
- \009if(pmap[x][y] ~= 0)then\
- \009\009term.setCursorPos(y,x)\
- \009\009term.setTextColor(colors[ gblocks[ pmap[x][y] ].color ])\
- \009\009term.setBackgroundColor(colors[ gblocks[ pmap[x][y] ].bcolor ])\
- \009\009write(gblocks[ pmap[x][y] ].graphic)\
- \009end\
- end\
- \
- function lookupBlock(id)\
- \009for i = 1, #gmap do\
- \009\009for c = 1, #gmap[i] do\
- \009\009\009if(gmap[i][c] == id)then return true end\
- \009\009end\
- \009end\
- \009return false\
- end\
- \
- function findBlockAt(id)\
- \009inf = {}\
- \009for i = 1, #gmap do\
- \009\009for c = 1, #gmap[i] do\
- \009\009\009if(gmap[i][c] == tonumber(id))then \
- \009\009\009\009 return i,c \
- \009\009\009end\
- \009\009end\
- \009end\
- \009return nil\
- end\
- \
- function getBlockAt(x,y)\
- \009return gmap[y][x]\
- end\
- \
- function setBlockAt(id,x,y)\
- \009gmap[y][x] = id\
- \009drawMapPixel(y,x)\
- end\
- \
- function breakBlockAt(x,y)\
- \009gmap[y][x] = 0\
- \009drawMapPixel(y,x)\
- end\
- \
- function editBlock(id,color,bcolor,graphic,solid)\
- \009gblocks[id].color = color\
- \009gblocks[id].bcolor = bcolor\
- \009gblocks[id].graphic = graphic\
- \009gblocks[id].solid = solid\
- \009draw()\
- end\
- function getCurrentMap()\
- \009return mapName\
- end\
- \
- \
- function addMap(name,levmap,blocks)\
- \009if(maps[name] ~= nil)then error(\"[Redgame] - > AddMap - > Map already added!\") end\
- \009maps[name] = {level=levmap,blockmap=blocks}\
- end\
- \
- function setSolid(id,solid)\
- \009gblocks[id].solid = solid\
- end\
- \
- function getResource(file)\
- \009f = fs.open(file,\"r\")\
- \009res = textutils.unserialize(f.readAll())\
- \009f.close()\
- \009if(type(res) ~= \"table\")then error(\"[RedGame]: getResource -> file [\"..file..\"] must contain only a table!\") end\
- \009return res\
- end\
- \
- function setMap(map)\
- \009if(maps[map] == nil)then\
- \009\009error(\"[RedGame] -> setMap -> No such map.\")\
- \009end\
- \009gmap=maps[map].level\
- \009mapName = map\
- \009gblocks = maps[map].blockmap\
- \009draw()\
- end\
- \
- function getMap()\
- \009return gmap\
- end\
- \
- \
- \
- \
- function createPlayer(block,startX,startY)\
- \
- \009local player = {\
- \
- \009\009x=startX,\
- \009\009y=startY,\
- \009\009tickrate=tonumber(0.1),\
- \009\009physicsTick = os.startTimer(0.1),\
- \009\009jump_height=2,\
- \009\009hspd = 0,\
- \009\009vspd = 0,\
- \009\009blockid = block,\
- \009\009multidir = false,\
- \009\009physic_control= {\
- \009\009\009[\"direction_up\"] = keys.w,\
- \009\009\009[\"direction_down\"] = keys.s,\
- \009\009\009[\"direction_left\"] = keys.a,\
- \009\009\009[\"direction_right\"] = keys.d,\
- \009\009},\
- \009\009lastMove = \"player_up\",\
- \009\009events = {},\
- \009\009interactions ={},\
- \
- \009\009addInteraction = function(self,mydmap,x,y,func)\
- \009\009\009self.interactions[#self.interactions+1] = {onmap=mydmap,x=x,y=y,active=true,event=func}\
- \009\009end,\
- \
- \009\009removeInteraction = function(self,mydmap,x,y)\
- \009\009\009for i = 1, #self.interactions do\
- \009\009\009\009if(self.interactions[i].x == x and self.interactions[i].y == y and self.interactions[i].onmap == mydmap)then\
- \009\009\009\009\009self.interactions[i].active=false;\
- \009\009\009\009end\
- \009\009\009end \
- \009\009end,\
- \
- \009\009setPhysicsTick = function(self,time)\
- \009\009\009self.tickrate = tonumber(time)\
- \009\009\009self.physicsTick = os.startTimer(time)\
- \009\009end,\
- \
- \009\009addEvent = function(self,check,evfunc)\
- \009\009\009table.insert(self.events,{type=check,run=evfunc})\
- \009\009end,\
- \
- \009\009getBlockUnder = function(self)\
- \009\009\009\009if(gmap[self.y][self.x] ~= 0)then\
- \009\009\009\009\009return gmap[self.y][self.x]\
- \009\009\009\009end\
- \009\009\009\009return 0\
- \009\009end,\
- \
- \
- \009\009checkCollision = function(self,x,y)\
- \009\009\009hasColl = false\
- \009\009\009if( gblocks[gmap[y][x]].solid or pmap[y][x] ~= 0)then hasColl = true end\
- \009\009\009if( gmap[y][x] == 0 and pmap[y][x] == 0)then hasColl = false end\
- \009\009\009return hasColl\
- \009\009end,\
- \
- \009\009jump = function(self,ammount)\
- \009\009\009if(self:checkCollision(self.x,self.y+1))then\
- \009\009\009\009for i = 1, ammount do\
- \009\009\009\009\009if(not self:checkCollision(self.x,self.y-1))then\
- \009\009\009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009\009\009self.y = self.y - 1\
- \009\009\009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009moveUp=function(self,ammount)\
- \009\009\009if(not self:checkCollision(self.x,self.y-1) and not self:checkPhysics(\"gravity\"))then\
- \009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009self.y = self.y - ammount\
- \009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009end\
- \
- \009\009\009if(not self:checkCollision(self.x,self.y-1) and self:checkPhysics(\"gravity\"))then\
- \009\009\009\009self:jump(self.jump_height)\
- \009\009\009end\
- \009\009end,\
- \
- \009\009moveDown=function(self,ammount)\
- \009\009\009if(not self:checkCollision(self.x,self.y+1))then\
- \009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009self.y = self.y + ammount\
- \009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009end\009\
- \009\009\
- \009\009end,\
- \
- \009\009moveLeft=function(self,ammount)\
- \009\009\009--pmap[self.y][self.x-1] == 0\
- \009\009\009if(not self:checkCollision(self.x-1,self.y))then\
- \009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009self.x = self.x - ammount\
- \009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009end\009\009\
- \
- \
- \009\009end,\
- \
- \009\009moveRight=function(self,ammount)\
- \009\009\009if(not self:checkCollision(self.x+1,self.y))then\
- \009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009self.x = self.x + ammount\
- \009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009end\009\009\
- \009\009end,\
- \
- \
- \009\009physics = {\
- \
- \009\009\009[\"gravity\"] = {has=false,func=function(self) \
- \009\009\009\009if(not self:checkCollision(self.x,self.y+1))then\
- \009\009\009\009\009\009self:moveDown(1)\
- \009\009\009\009\009\009sleep(0.01)\
- \009\009\009\009end\
- \009\009\009end};\
- \
- \009\009\009[\"smooth_experimental\"] = {has=false,func=function(self) \
- \009\009\009\009\009self.multidir = true\
- \009\009\009\009\009self.physics[\"smooth_experimental\"].has = false\
- \009\009\009end};\
- \
- \009\009},\
- \
- \
- \009\009checkPhysics = function(self,element)\
- \009\009\009for k, v in pairs(self.physics) do\
- \009\009\009\009if(k == element and v.has)then\
- \009\009\009\009\009return true\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009return false\
- \009\009end,\
- \
- \009\009checkInteract = function(self)\
- \009\009\009for i = 1, #self.interactions do\
- \009\009\009\009if( ((self.y == self.interactions[i].y-1) \
- \009\009\009\009\009and (self.x == self.interactions[i].x)) \
- \009\009\009\009\009or ((self.y == self.interactions[i].y+1)\
- \009\009\009\009 and (self.x == self.interactions[i].x))\
- \009\009\009\009\009or ((self.y == self.interactions[i].y)\
- \009\009\009\009 and (self.x == self.interactions[i].x+1))\
- \009\009\009\009\009or ((self.y == self.interactions[i].y)\
- \009\009\009\009 and (self.x == self.interactions[i].x-1))\
- \009\009\009\009 )then\
- \009\009\009\009\009if(self.interactions[i].onmap == getCurrentMap() and self.interactions[i].active)then\
- \009\009\009\009\009\009self.interactions[i].event()\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009controls = {\
- \009\009\009{name = \"player_interact\",event=\"key\",key=keys.space,func=function(self) self:checkInteract() end};\
- \009\009\009{name=\"player_up\",event=\"key\",key=keys.w,func=function(self) self.lastMove = \"player_up\" self:moveUp(1) end};\
- \009\009\009{name=\"player_down\",event=\"key\",key=keys.s,func=function(self) self.lastMove = \"player_down\" self:moveDown(1) end};\
- \009\009\009{name=\"player_left\",event=\"key\",key=keys.a,func=function(self) self.lastMove = \"player_left\" self:moveLeft(1) end};\
- \009\009\009{name=\"player_right\",event=\"key\",key=keys.d,func=function(self)self.lastMove = \"player_right\" self:moveRight(1) end};\
- \009\009},\
- \
- \009\009--]] movement functions\
- \
- \009\009put = function(self)\
- \009\009\009pmap[self.y][self.x] = self.blockid \
- \009\009end,\
- \
- \009\009unput = function(self)\
- \009\009\009pmap[self.y][self.x] = 0; \
- \009\009\009drawMapPixel(self.y,self.x)\
- \009\009end,\
- \
- \009\009applyPhysics = function(self,element)\
- \009\009\009if(self.physics[element] ~= nil)then\
- \009\009\009\009if(self.physics[element].has == false)then\
- \009\009\009\009\009self.physics[element].has = true\
- \009\009\009\009end\
- \009\009\009else\
- \009\009\009\009error(\"[RedGame]: player -> addPhysicsElement -> no such element!\")\
- \009\009\009end\
- \009\009end,\
- \
- \009\009setJumpHeight = function(self,h)\
- \009\009\009self.jump_height = h\
- \009\009end,\
- \
- \009\009createPhysics = function(self,element,physic)\
- \009\009\009\009if(self.physics[element] ~= nil)then error(\"[RedGame]: player - > createPhysicsElement -> element already exists!\") end\
- \009\009\009\009if(type(physic) ~= \"table\")then error(\"[RedGame]: player -> createPhysicsElement -> must be in table format eg {func=function(self) physics stuff end};\") end\
- \009\009\009\009 metaindex = {has=false,func=function(self) end};\
- \009\009\009\009physic = setmetatable(physic, {__index = metaindex})\
- \009\009\009\009self.physics[element] = physic\
- \009\009end,\
- \
- \009\009remapPhysicsControl = function(self,name,to)\
- \009\009\009\009if(self.physic_control[name])then\
- \009\009\009\009\009self.physic_control[name] = to\
- \009\009\009\009else\
- \009\009\009\009\009error(\"[RedGame]: player -> remapPhysicsControl invalid control!\")\
- \009\009\009\009end\
- \009\009end,\
- \
- \009\009remapControl = function(self,name,to)\
- \009\009\009for i = 1, #self.controls do\
- \009\009\009\009if(self.controls[i].name == name)then\
- \009\009\009\009\009self.controls[i].key = to\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009\009addControl=function(self,controltable)\
- \009\009\009if(type(controltable) ~= \"table\")then\
- \009\009\009\009error(\"[RedGame]:addControl -> control must be a table in this format: {name=<control name>,event=<event>,key=<key in string format>,func=function() <actions> end}\")\
- \009\009\009else\
- \009\009\009\009table.insert(self.controls,controltable)\
- \009\009\009end\
- \009\009end,\
- \
- \009\009importControls=function(self,controltable)\
- \009\009\009if(type(controltable) ~= \"table\")then\
- \009\009\009\009error(\"[RedGame]:importControls -> control must be a table in this format: controls = { {name=<control name>,event=<event>,key=<key in string format>,func=function() <actions> end}, ect... }\")\
- \009\009\009else\
- \009\009\009\009self.controls = controltable\
- \009\009\009end\
- \009\009end,\
- \
- \
- \009\009setPos = function(self,x,y)\
- \009\009\009pmap[self.y][self.x] = 0\
- \009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009self.x = x\
- \009\009\009self.y = y\
- \009\009\009self:checkCollision(self.x,self.y)\
- \009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009drawMapPixel(self.y,self.x)\
- \009\009end,\
- \
- \009\009update=function(self)\
- \
- \009\009\009for i = 1, #doors do\
- \009\009\009\009if(getCurrentMap() == doors[i].fMap and self.x == doors[i].fx and self.y == doors[i].fy)then\
- \009\009\009\009\009setMap(doors[i].tMap)\
- \009\009\009\009\009self:setPos(doors[i].tx,doors[i].ty)\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009if(self.multidir)then\
- \009\009\009\009pmap[self.y][self.x] = 0\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009\009if(not self:checkCollision(self.x+self.hspd,self.y))then\
- \009\009\009\009\009self.x = self.x + self.hspd\
- \009\009\009\009end\
- \009\009\009\009if(not self:checkCollision(self.x,self.y+self.vspd))then\
- \009\009\009\009\009self.y = self.y + self.vspd\
- \009\009\009\009end\
- \009\009\009\009pmap[self.y][self.x] = self.blockid\
- \009\009\009\009drawMapPixel(self.y,self.x)\
- \009\009\009end\
- \
- \009\009\009a = {os.pullEvent()}\
- \
- \009\009\009for k, v in pairs(self.events) do\
- \009\009\009\009if(v.type == a[1])then\
- \009\009\009\009\009v.run(a)\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009if(a[1]==\"timer\")then\
- \009\009\009\009self.physicsTick=os.startTimer(self.tickrate)\
- \009\009\009\009for k, v in pairs(self.physics) do\
- \009\009\009\009\009if(v.has)then v.func(self) end\
- \009\009\009\009end\
- \009\009\009end\
- \
- \009\009\009if(not self.multidir)then\
- \009\009\009\009for i = 1, #self.controls do\
- \009\009\009\009\009if(a[1] == self.controls[i].event and a[2] == self.controls[i].key)then\
- \009\009\009\009\009\009self.controls[i].func(self)\
- \009\009\009\009\009end\
- \009\009\009\009end \
- \009\009\009end\
- \
- \009\009\009if(self.multidir)then\
- \009\009\009\009\009\009if(a[2] ~= self.physic_control[\"direction_up\"] and a[2] ~= self.physic_control[\"direction_down\"])then\
- \009\009\009\009\009\009\009self.vspd = 0\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009if(a[2] ~= self.physic_control[\"direction_left\"] and a[2] ~= self.physic_control[\"direction_right\"])then\
- \009\009\009\009\009\009\009self.hspd = 0\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009if(a[2] == self.physic_control[\"direction_up\"])then\
- \009\009\009\009\009\009\009if(self:checkPhysics(\"gravity\"))then\
- \009\009\009\009\009\009\009\009if(self:checkCollision(self.x,self.y+1))then\
- \009\009\009\009\009\009\009\009\009self.vspd = -self.jump_height\
- \009\009\009\009\009\009\009\009end\
- \009\009\009\009\009\009\009else\
- \009\009\009\009\009\009\009\009self.vspd = -self.jump_height\
- \009\009\009\009\009\009\009end\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009if(a[2] == self.physic_control[\"direction_down\"])then\
- \009\009\009\009\009\009\009self.vspd = 1\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009if(a[2] == self.physic_control[\"direction_left\"])then\
- \009\009\009\009\009\009\009self.hspd = -1\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009if(a[2] == self.physic_control[\"direction_right\"])then\
- \009\009\009\009\009\009\009self.hspd = 1\
- \009\009\009\009\009\009end\
- \009\009\009end\
- \009\009end,\
- \
- \009}\
- \
- \009return player\
- end",
- },
- [ "games/GameOfLife/" ] = {
- content = "--]] Game of life, by Redxone(Lewisk3), Special thanks to: MultMine [[--\
- -- Rules:\
- -- if less than 2, die\
- -- if more then 3, die\
- -- if has 2 or 3, live\
- -- if more then 3, die\
- -- if has exactly 3 and is dead, live\
- os.loadAPI(\"CrossBow/apis/grid\")\
- ------------------------------------\
- term.setBackgroundColor(colors.black)\
- term.clear()\
- term.setCursorPos(1,1)\
- term.setBackgroundColor(colors.gray)\
- term.setTextColor(colors.white)\
- term.clearLine()\
- local w, h = term.getSize()\
- -- check for updates -- \
- term.setBackgroundColor(colors.gray)\
- term.setTextColor(colors.white)\
- term.clear()\
- term.setCursorPos((w/2) - 11, 4)\
- write(\"Checking for updates...\")\
- if(http)then\
- \009\009term.setCursorPos((w/2) - 1, (h/2) - 1)\
- \009\009for i = 1, 5 do\
- \009\009\009term.setCursorPos((w/2) - 1, (h/2) - 1)\
- \009\009\009write(\":\")\
- \009\009\009sleep(0.2)\
- \009\009\009term.setCursorPos((w/2) - 1, (h/2) - 1)\
- \009\009\009write(\"/\")\
- \009\009\009sleep(0.2)\
- \009\009\009term.setCursorPos((w/2) - 1, (h/2) - 1)\
- \009\009\009write(\"-\")\
- \009\009\009sleep(0.2)\
- \009\009\009term.setCursorPos((w/2) - 1, (h/2) - 1)\
- \009\009\009write(\"\\\\\")\009\
- \009\009end\
- \009local gameupdate = http.get(\"http://pastebin.com/raw/R3HfhA4x\")\
- \009sleep(0.2)\
- \009if(gameupdate == nil)then\
- gameupdate = gameupdate.readAll()\
- \009\009f = fs.open(shell.getRunningProgram() ,\"r\")\
- \009\009_contents = f.readAll()\
- \009\009f.close()\
- \009\009if(_contents ~= gameupdate)then\
- \009\009\009term.setCursorPos((w/2) - 11, 4)\
- \009\009\009write(\"Update found, updating...\")\
- \009\009\009f = fs.open(shell.resolve(shell.getRunningProgram()),\"w\")\
- \009\009\009f.write(gameupdate)\
- \009\009\009f.close()\
- \009\009\009sleep(0.5)\
- \009\009\009term.setCursorPos((w/2) - 11, 4)\
- \009\009\009term.clearLine()\
- \009\009\009write(\" Restarting game...\")\
- \009\009\009sleep(0.5)\
- \009\009\009return shell.run(shell.getRunningProgram())\
- \009\009end\
- \009else\
- \009\009term.setCursorPos((w/2) - 11, 4)\
- \009\009write(\"Updating disable for CrossBow. launching game...\")\
- \009\009sleep(0.2)\
- \009end\
- end\
- term.clear()\
- term.setCursorPos((w/2) - 12, (h/2) - 1)\
- print(\"Creating cell universe...\")\
- local verse = grid.create(82,50)\
- local ngen = grid.create(82,50)\
- sleep(0.2)\
- local isPaused = false\
- local running = true\
- local generation = 0\
- local speed = 0.01\
- local xoff, yoff = 0, 0\
- local genTimer = os.startTimer(speed)\
- function newCell(alive)\
- local cell = {isAlive=true}\
- if(not alive)then cell.isAlive = false end\
- return cell\
- end\
- --- Fill universe with dead cells ---\
- --verse:fill(newCell(false))\
- --ngen:fill(newCell(false))\
- --------------------------------------\
- function drawCell(x,y)\
- if(x <= w and y <= 50 and y >= 2)then\
- term.setCursorPos(x,y)\
- if(verse:get(x+xoff,y+yoff).isAlive==true)then\
- if(isPaused)then term.setBackgroundColor(colors.yellow) else term.setBackgroundColor(colors.green) end\
- term.setTextColor(colors.black)\
- write(' ')\
- else\
- if(isPaused)then term.setBackgroundColor(colors.gray) else term.setBackgroundColor(colors.black) end\
- term.setTextColor(colors.lightGray)\
- if(isPaused)then write('L') else write (' ') end\
- end\
- end\
- end\
- function updateview()\
- for x = 1, verse:getHeight() do\
- for y = 1, verse:getWidth() do\
- drawCell(y,x)\
- end\
- end\
- end\
- function life()\
- for x = 1, verse:getHeight() do\
- for y = 1, verse:getWidth() do\
- local friends = 0\
- drawCell(y,x)\
- \009\009 for _y = -1, 1 do\
- \009\009 for _x = -1, 1 do\
- \009\009 if _y ~= 0 or _x ~= 0 then\
- \009\009 if(verse:get(y+_y,x+_x).isAlive == true) then friends = friends + 1 end\
- \009\009 end\
- \009\009 end\
- \009\009 end\
- -- Die conditions\
- if(verse:get(y,x).isAlive and friends < 2)then\
- ngen:set(y,x,newCell(false))\
- elseif(friends > 3 and verse:get(y,x).isAlive)then\
- ngen:set(y,x,newCell(false))\
- end\
- -- Live conditions\
- if(verse:get(y,x).isAlive and (friends == 2 or friends == 3))then\
- ngen:set(y,x,newCell(true))\
- end\
- if(verse:get(y,x).isAlive ~= true and (friends == 3))then\
- ngen:set(y,x,newCell(true))\
- end\
- end\
- end\
- verse:replace(ngen:getRaw())\
- ngen = grid.create(82,50)\
- end\
- function infoBar()\
- term.setCursorPos(1,1)\
- term.setBackgroundColor(colors.gray)\
- term.setTextColor(colors.white)\
- term.clearLine()\
- local printgeneration = generation\
- if generation > 999 then printgeneration = 999 end\
- write(\" Editing:\" .. tostring(isPaused) .. \" Generation: \" .. printgeneration .. \",\" .. speed .. \" X:\" .. xoff .. \",Y:\" .. yoff)\
- term.setCursorPos(w,1)\
- term.setBackgroundColor(colors.red)\
- write('X')\
- term.setCursorPos(w-1,1)\
- term.setBackgroundColor(colors.lightGray)\
- write('C')\
- end\
- function endscr()\
- \009term.setBackgroundColor(colors.black)\
- term.clear()\
- term.setCursorPos(1,1)\
- term.setBackgroundColor(colors.gray)\
- term.setTextColor(colors.white)\
- term.clearLine()\
- write(\"Thank you for playing Lewisk3's Game Of Life! Credits: John Conway, Multmine\")\
- term.setCursorPos(w,1)\
- term.setBackgroundColor(colors.brown)\
- write('X')\
- \009term.setBackgroundColor(colors.black)\
- term.setCursorPos(1,3)\
- \
- end\
- \
- verse:loop(drawCell)\
- while running do\
- term.current().setVisible(false)\
- infoBar()\
- ev = {os.pullEvent()}\
- if(ev[1] == 'key')then\
- if(ev[2] == keys.space)then isPaused = not isPaused end\
- if(ev[2] == keys.w and yoff > 0)then yoff = yoff - 1 end\
- if(ev[2] == keys.a and xoff > 0)then xoff = xoff - 1 end\
- if(ev[2] == keys.s and yoff < verse:getHeight()-h)then yoff = yoff + 1 end\
- if(ev[2] == keys.d and xoff < verse:getWidth()-w)then xoff = xoff + 1 end\
- if(ev[2] == keys.up and speed > 0.01)then speed = speed - 0.01 end \
- if(ev[2] == keys.down)then speed = speed + 0.01 end\
- updateview()\
- end\
- if(ev[1] == 'timer' and ev[2] == genTimer)then\
- if(not isPaused)then life() generation = generation + 1 end\
- genTimer = os.startTimer(speed)\
- elseif(ev[1] == \"mouse_click\" or ev[1] == \"mouse_drag\")then\
- \009if(ev[3] == w and ev[4] == 1)then running = false endscr() end\
- \009if(ev[3] == w-1 and ev[4] == 1)then verse = grid.create(verse:getWidth(),verse:getHeight()) verse:fill({}) ngen = grid.create(ngen:getWidth(),ngen:getHeight()) updateview() end\
- if(isPaused)then \
- if(ev[2] == 1)then verse:set(ev[3]+xoff,ev[4]+yoff,newCell(true)) end\
- if(ev[2] == 2)then verse:set(ev[3]+xoff,ev[4]+yoff,{}) end\
- drawCell(ev[3],ev[4])\
- end\
- end\
- term.current().setVisible(true)\
- end",
- },
- [ "programs/configs/novapins/" ] = {
- content = "{\
- {\
- t = \"text\",\
- n = \" \",\
- },\
- {\
- n = \"&4-&7=&8] &rGameOfLife\",\
- href = \"CrossBow/games/GameOfLife\",\
- t = \"game\",\
- },\
- {\
- n = \"&4-&7=&8] &r2048\",\
- href = \"CrossBow/games/2048\",\
- t = \"game\",\
- },\
- {\
- n = \"&e[=] &5Apis\",\
- href = \"CrossBow/apis\",\
- t = \"folder\",\
- },\
- }",
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement