Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- false
- {
- [ "/c" ] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " ddddd55555 ",
- " 5555ddddd555555 ",
- " 55555555dddd555555 ",
- " 55555555555dddd55555 ",
- "5555555 ddd55555",
- "55555 dd5555",
- "d555 555 ",
- "5ddd ",
- "d555 ",
- "dddd ",
- "ddddd ",
- " ddddd 5555 ",
- " ddddddd ddd555",
- " dddddddddddd55555ddd",
- " dddddddddddddddd55 ",
- " dddddddddddddd ",
- " dddddd ",
- "",
- },
- [ "/test" ] = {
- "local mon = peripheral.find(\"monitor\")",
- "term.redirect(mon)",
- "os.loadAPI(\"pain\")",
- "shell.run(\"render\")",
- "term.setBackgroundColor(colors.black)",
- "term.clear()",
- "local space = 2",
- "local dif = 1",
- "function ion(txt)",
- " term.native().setCursorPos(1,2)",
- " term.native().write(txt..\" \")",
- "end",
- "pain.renderPAINFS(\"BETA\",2,35)",
- "while true do",
- " render(1,space)",
- " if (space >= 5) or (space <= 1) then",
- " dif = dif*-1",
- " end",
- " space = space + dif",
- " ion(space..\"/\"..dif)",
- " sleep(0.2)",
- "end",
- "",
- },
- [ "/r" ] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " 55555555d 5555555 ",
- " 55555555 d555555555 ",
- " 555555555ddd55555555 ",
- " 5555555555dddd5555555 ",
- " 555555555555dddd555555",
- " 5555555555555dddd55555",
- " 5555555555 d55555",
- " ddd5555 55555",
- " 555d555 5555",
- " ddd5dd5 ",
- " dddd55d ",
- " ddddddd5 ",
- " dddddddd ",
- " dddddddd ",
- " ddddddd ",
- "dddddddd ",
- "ddddddd ",
- "",
- },
- [ "/P" ] = {
- " 5555d55555555555 ",
- " 5555555dd5555555555555 ",
- " 55555555d555555555555555 ",
- " 55555555dd5555555555555555 ",
- " 55555555dd5555555555555555 ",
- " 555555555dd 55555555555",
- " 5555555555d 55555555",
- " 55555555555 55555",
- " 55555555555 55555",
- " 5555555555 5555",
- " 555555555 5555",
- " 5555555555 55555",
- " d55555555555555 5555555",
- " d55555555555555555ddd555555",
- " 5d55555555555555555ddd555 ",
- " d5d55555555555555555ddd5 ",
- " ddd5d555555555555555 ",
- " dddd5d55555 ",
- " dddd5d55555 ",
- " ddddd5d5555 ",
- " dddddd5d5555 ",
- " ddddddd5d55 ",
- " dddddddd5dd ",
- " ddddddddd55 ",
- " ddddddddddd ",
- " dddddddddddd ",
- " ddddddddddd ",
- " ddddddddddd ",
- " ddddddddddd ",
- "ddddddddddd ",
- "dddddddddd ",
- "ddddddddd ",
- "dddddddd ",
- " ddddd ",
- "",
- },
- [ "/j" ] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " 5555 ",
- " 555555",
- " d5555 ",
- " dd55 ",
- " dddd ",
- "",
- "",
- " 55dd ",
- " 5555dd ",
- " 55555dd ",
- " 555555d ",
- " 555555d",
- " 5555555",
- " 55 5555555",
- " ddd 555555",
- "5555d 555555",
- "dddd55 ddd555",
- "dddddd 555ddd",
- "dddddd dddd555",
- "ddddddd dddddddd ",
- "dddddddddddddddddd ",
- " dddddddddddddddd ",
- " ddddddddddddd ",
- " dddddddddd ",
- "",
- },
- [ "/e" ] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " ddddd5555555 ",
- " 55dddddd5555555 ",
- " 55555dddddd5555555 ",
- " 555555 55555 ",
- "555555 dd55 ",
- "555555 dddd",
- "dd5555 555d",
- "55ddddd 55555",
- "dd5555555ddddddd555555",
- "ddddddddd5555555ddddd ",
- "ddddddd ",
- " dddddd ",
- " dddddddd ",
- " ddddddddd dddddd",
- " ddddddddddddddddddd",
- " ddddddddddddddddd ",
- " ddddddddddddd ",
- "",
- },
- [ "/o" ] = {
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " d5555 ",
- " 55ddd55555 ",
- " 55555ddd55555 ",
- " 555555dddd5555 ",
- " 55555555dddddddd ",
- "555555 dddddd",
- "dd555 ddddd",
- "55dd 555",
- "dd55 555",
- "dddd 555",
- "ddddd 5ddd",
- "dddddd dd55 ",
- " dddddddddddddddd ",
- " ddddddddddddddd ",
- " ddddddddddddd ",
- " dddddddddd ",
- " dddddd ",
- "",
- },
- [ "/pain" ] = {
- "--[[\r",
- " PAIN picture editor for ComputerCraft\r",
- " Get it with\r",
- " pastebin get wJQ7jav0 pain\r",
- " std pb wJQ7jav0 pain\r",
- " std ld pain pain\r",
- " \r",
- " This is a stable release. You fool!\r",
- "--]]\r",
- "\r",
- "local displayHelp = function()\r",
- " local progname = fs.getName(shell.getRunningProgram())\r",
- " print(progname..\" <filename>\")\r",
- " print(\"Press F1 in program for more.\")\r",
- "end\r",
- "\r",
- "local pMode = 0\r",
- "\r",
- "local tArg = {...}\r",
- "if (not tArg[1]) and shell then\r",
- " return displayHelp()\r",
- "end\r",
- "\r",
- "if tArg[2] == \"view\" then\r",
- " pMode = 1\r",
- "elseif tArg[2] == \"moo\" then\r",
- " return print(\"This PAIN does not have Super Cow Powers.\")\r",
- "end\r",
- "\r",
- "local fileName\r",
- "if not term.isColor() then\r",
- " error(\"Only for Advanced computers\")\r",
- "end\r",
- "local barmsg = \"Press F1 for help.\"\r",
- "local tse = textutils.serialise\r",
- "local tun = textutils.unserialise\r",
- "local paintEncoded\r",
- "local lastPaintEncoded\r",
- "local frame = 1\r",
- "local doRender = false\r",
- "local metaHistory = {}\r",
- "local bepimode = false --this is a family-friendly program! now stand still while I murder you\r",
- "local evenDrawGrid = true --will you evenDraw(the)Grid ?\r",
- "local renderBlittle = false --whether or not to render all in blittle\r",
- "local firstTerm, blittleTerm = term.current()\r",
- "local firstBG = term.getBackgroundColor()\r",
- "local firstTX = term.getTextColor()\r",
- "\r",
- "local grid\r",
- "\r",
- "local yield = function()\r",
- " os.queueEvent(\"yield\")\r",
- " os.pullEvent(\"yield\")\r",
- "end\r",
- "\r",
- "local paint = {\r",
- " scrollX = 0,\r",
- " scrollY = 0,\r",
- " t = colors.gray,\r",
- " b = colors.white,\r",
- " m = 1, --in case you want to use PAIN as a level editor or something\r",
- " c = \" \",\r",
- " doGray = false,\r",
- "}\r",
- "\r",
- "local scr_x, scr_y = term.getSize()\r",
- "local scrollX, scrollY = 0, 0\r",
- "\r",
- "local keysDown = {}\r",
- "local miceDown = {}\r",
- "\r",
- "local doRenderBar = 1 -- 1 and 0. Not true or false\r",
- "\r",
- "local fixstr = function(str)\r",
- " return str:gsub(\"\\\\(%d%d%d)\",string.char)\r",
- "end\r",
- "\r",
- "local choice = function(input,breakkeys)\r",
- " repeat\r",
- " event, key = os.pullEvent(\"key\")\r",
- " if type(key) == \"number\" then key = keys.getName(key) end\r",
- " if key == nil then key = \" \" end\r",
- " if type(breakkeys) == \"table\" then\r",
- " for a = 1, #breakkeys do\r",
- " if key == breakkeys[a] then\r",
- " return \"\"\r",
- " end\r",
- " end\r",
- " end\r",
- " until string.find(input, key)\r",
- " return key\r",
- "end\r",
- "local explode = function(div,str)\r",
- " if (div=='') then return false end\r",
- " local pos,arr = 0,{}\r",
- " for st,sp in function() return string.find(str,div,pos,true) end do\r",
- " table.insert(arr,str:sub(pos,st-1))\r",
- " pos = sp + 1\r",
- " end\r",
- " table.insert(arr,str:sub(pos))\r",
- " return arr\r",
- "end\r",
- "\r",
- "local function cutString(max_line_length, str) --from stack overflow\r",
- " local lines = {}\r",
- " local line\r",
- " str:gsub('(%s*)(%S+)', \r",
- " function(spc, word) \r",
- " if not line or #line + #spc + #word > max_line_length then\r",
- " table.insert(lines, line)\r",
- " line = word\r",
- " else\r",
- " line = line..spc..word\r",
- " end\r",
- " end\r",
- " )\r",
- " table.insert(lines, line)\r",
- " return lines\r",
- "end\r",
- "\r",
- "local cutUp = function(len,tbl)\r",
- " local output = {}\r",
- " local e = 0\r",
- " local s\r",
- " for a = 1, #tbl do\r",
- " if #(tbl[a]:gsub(\" \",\"\")) == 0 then\r",
- " s = {\"\"}\r",
- " else\r",
- " s = cutString(len,tbl[a])\r",
- " end\r",
- " for b = 1, #s do\r",
- " table.insert(output,s[b])\r",
- " end\r",
- " end\r",
- " return output\r",
- "end\r",
- "\r",
- "local getEvents = function(...)\r",
- " local output\r",
- " while true do\r",
- " output = {os.pullEvent()}\r",
- " for a = 1, #arg do\r",
- " if type(arg[a]) == \"boolean\" then\r",
- " if doRender == arg[a] then\r",
- " return {}\r",
- " end\r",
- " elseif output[1] == arg[a] then\r",
- " return unpack(output)\r",
- " end\r",
- " end\r",
- " end\r",
- "end\r",
- "\r",
- "local sanitize = function(sani,tize)\r",
- " local _,x = string.find(sani,tize)\r",
- " if x then\r",
- " return sani:sub(x+1)\r",
- " else\r",
- " return sani\r",
- " end\r",
- "end\r",
- "local ro = function(input, max)\r",
- " return math.floor(input % max)\r",
- "end\r",
- "\r",
- "local guiHelp = function()\r",
- " term.redirect(firstTerm)\r",
- " scr_x, scr_y = term.current().getSize()\r",
- " local _helpText = [[\r",
- "\r",
- " 'PAIN' Help Page\r",
- "Programmed by LDDestroier/EldidiStroyrr\r",
- "\r",
- "(use UP/DOWN or scrollwheel, exit with Q)\r",
- "If you want to use PAIN to its full capacity, then READ EVERYTHING HERE! It's not TOO long, and it's completely worth it!\r",
- "\r",
- "Syntax:\r",
- ">pain <filename> [view]\r",
- "\r",
- "[view]: disable all writing capability to view a file\r",
- "\r",
- "You can see what colors are selected based on the word \"PAIN\" on the hotbar.\r",
- "\r",
- "Hotkeys:\r",
- " left/right ctrl: toggle the menu\r",
- "\r",
- " left click:\r",
- " +shift = drag and let go to make a line\r",
- " -alone = place pixel\r",
- "\r",
- " right click: delete pixel\r",
- "\r",
- " middle click OR \"t\": place text down with current colors\r",
- "\r",
- " \"[\" or mouse scroll down:\r",
- " +shift = change to previous text color\r",
- " -alone = change to previous background color\r",
- "\r",
- " \"]\" or mouse scroll up:\r",
- " +shift = change to next text color\r",
- " -alone = change to next background color\r",
- "\r",
- " spacebar:\r",
- " +shift = toggle grid\r",
- " -alone = toggle bar visibility\r",
- "\r",
- " arrowkeys:\r",
- " +shift = move entire picture\r",
- " +tab = move one pixel at a time\r",
- " -alone = looks around the canvas smoothly\r",
- "\r",
- " \"+\" (or equals):\r",
- " +left alt = swap the current frame with the next frame\r",
- " -alone = change to next frame\r",
- "\r",
- " \"-\":\r",
- " +left alt = swap the current frame with the previous frame\r",
- " -alone = change to previous frame\r",
- "\r",
- " \"a\": set the coordinates to 0,0\r",
- "\r",
- " \"b\": toggle redirect to blittle, to preview in teletext characters\r",
- "\r",
- " \"c\": input coordinates to move the canvas to\r",
- "\r",
- " \"g\": toggle grayscale mode. everything is in shades of gray. if you Save, it saves in grayscale.\r",
- "\r",
- " \"f\":\r",
- " +shift = fill all empty pixels with background color\r",
- " -alone = absolutely nothing\r",
- "\r",
- " \"m\": set metadata for pixels (for game makers, otherwise safe to ignore)\r",
- "\r",
- "\r",
- " Le Menu (access with CTRL):\r",
- "\r",
- " -left click on a menu item to select it.\r",
- " -if you click on the menubar, let go on an option to select it.\r",
- "\r",
- " \"Save\"\r",
- " Saves all frames to a specially formatted PAIN paint file. The format PAIN uses is very inefficient despite my best efforts, so Export if you don't use text or multiple frame.\r",
- "\r",
- " \"Export\"\r",
- " Exports current frame to the basic paint format, which doesn't save text, but is WAY more space-efficient. Specify a path, too.\r",
- "\r",
- " \"Del. Frame\"\r",
- " Deletes the current frame. Tells you off if you try to delete the only frame.\r",
- "\r",
- " \"Clear\"\r",
- " Deletes all pixels on the current frame.\r",
- "\r",
- " \"Exit\"\r",
- " Durr I dunno, I think it exits.\r",
- "\r",
- "\r",
- "I hope my PAIN causes you joy.\r",
- "]]\r",
- " _helpText = explode(\"\\n\",_helpText)\r",
- " helpText = cutUp(scr_x,_helpText)\r",
- " local helpscroll = 0\r",
- " term.setBackgroundColor(colors.gray)\r",
- " term.setTextColor(colors.white)\r",
- " term.clear()\r",
- " local evt, key\r",
- " while true do\r",
- " term.clear()\r",
- " for a = 1, scr_y do\r",
- " term.setCursorPos(1,a)\r",
- " term.clearLine()\r",
- " term.write(helpText[a-helpscroll] or \"\")\r",
- " end\r",
- " repeat\r",
- " evt,key = os.pullEvent()\r",
- " until evt == \"key\" or evt == \"mouse_scroll\"\r",
- " if evt == \"key\" then\r",
- " if key == keys.up then\r",
- " helpscroll = helpscroll + 1\r",
- " elseif key == keys.down then\r",
- " helpscroll = helpscroll - 1\r",
- " elseif key == keys.pageUp then\r",
- " helpscroll = helpscroll + scr_y\r",
- " elseif key == keys.pageDown then\r",
- " helpscroll = helpscroll - scr_y\r",
- " elseif (key == keys.q) or (key == keys.space) then\r",
- " doRender = true\r",
- " if renderBlittle then term.redirect(blittleTerm) end\r",
- " scr_x, scr_y = term.current().getSize()\r",
- " return\r",
- " end\r",
- " elseif evt == \"mouse_scroll\" then\r",
- " helpscroll = helpscroll - key\r",
- " end\r",
- " if helpscroll > 0 then\r",
- " helpscroll = 0\r",
- " elseif helpscroll < -(#helpText-(scr_y-3)) then\r",
- " helpscroll = -(#helpText-(scr_y-3))\r",
- " end\r",
- " end\r",
- "end\r",
- "\r",
- "local tableRemfind = function(tbl, str)\r",
- " local out = tbl\r",
- " for a = 1, #tbl do\r",
- " if tbl[a] == str then\r",
- " table.remove(out,a)\r",
- " return out,a\r",
- " end\r",
- " end\r",
- " return {}\r",
- "end\r",
- "\r",
- "local stringShift = function(str,amt)\r",
- " return str:sub(ro(amt-1,#str)+1)..str:sub(1,ro(amt-1,#str))\r",
- "end\r",
- "\r",
- "local deepCopy\r",
- "deepCopy = function(obj)\r",
- " if type(obj) ~= 'table' then return obj end\r",
- " local res = {}\r",
- " for k, v in pairs(obj) do res[deepCopy(k)] = deepCopy(v) end\r",
- " return res\r",
- "end\r",
- "\r",
- "local renderBottomBar = function(txt)\r",
- " term.setCursorPos(1,scr_y)\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " term.setTextColor(colors.black)\r",
- " term.clearLine()\r",
- " term.write(txt)\r",
- "end\r",
- "\r",
- "local bottomPrompt = function(txt,history,cho,breakkeys)\r",
- " renderBottomBar(txt)\r",
- " local out\r",
- " sleep(0)\r",
- " if cho then\r",
- " out = choice(cho,breakkeys)\r",
- " else\r",
- " out = read(_,history)\r",
- " end\r",
- " return out\r",
- "end\r",
- "\r",
- "local getDotsInLine = function( startX, startY, endX, endY ) --stolen from the paintutils API...hehehe\r",
- " local out = {}\r",
- " \r",
- " startX = math.floor(startX)\r",
- " startY = math.floor(startY)\r",
- " endX = math.floor(endX)\r",
- " endY = math.floor(endY)\r",
- "\r",
- " if startX == endX and startY == endY then\r",
- " out = {{x=startX,y=startY}}\r",
- " return out\r",
- " end\r",
- " \r",
- " local minX = math.min( startX, endX )\r",
- " if minX == startX then\r",
- " minY = startY\r",
- " maxX = endX\r",
- " maxY = endY\r",
- " else\r",
- " minY = endY\r",
- " maxX = startX\r",
- " maxY = startY\r",
- " end\r",
- " \r",
- " local xDiff = maxX - minX\r",
- " local yDiff = maxY - minY\r",
- " \r",
- " if xDiff > math.abs(yDiff) then\r",
- " local y = minY\r",
- " local dy = yDiff / xDiff\r",
- " for x=minX,maxX do\r",
- " table.insert(out,{x=x,y=math.floor(y+0.5)})\r",
- " y = y + dy\r",
- " end\r",
- " else\r",
- " local x = minX\r",
- " local dx = xDiff / yDiff\r",
- " if maxY >= minY then\r",
- " for y=minY,maxY do\r",
- " table.insert(out,{x=math.floor(x+0.5),y=y})\r",
- " x = x + dx\r",
- " end\r",
- " else\r",
- " for y=minY,maxY,-1 do\r",
- " table.insert(out,{x=math.floor(x+0.5),y=y})\r",
- " x = x - dx\r",
- " end\r",
- " end\r",
- " end\r",
- " return out\r",
- "end\r",
- "\r",
- "local movePaintEncoded = function(pe,xdiff,ydiff)\r",
- " local outpootis = deepCopy(pe)\r",
- " for a = 1, #outpootis do\r",
- " outpootis[a].x = outpootis[a].x+xdiff\r",
- " outpootis[a].y = outpootis[a].y+ydiff\r",
- " end\r",
- " return outpootis\r",
- "end\r",
- "\r",
- "local clearRedundant = function(dots)\r",
- " local input = {}\r",
- " local pheight = 0\r",
- " local pwidth = 0\r",
- " for a = 1, #dots do\r",
- " if dots[a].y > pheight then\r",
- " pheight = dots[a].y\r",
- " end\r",
- " if dots[a].x > pwidth then\r",
- " pwidth = dots[a].x\r",
- " end\r",
- " end\r",
- " for a = 1, #dots do\r",
- " if not input[dots[a].y] then input[dots[a].y] = {} end\r",
- " input[dots[a].y][dots[a].x] = dots[a]\r",
- " end\r",
- " local output = {}\r",
- " local frame = 0\r",
- " for y = 1, pheight do\r",
- " for x = 1, pwidth do\r",
- " if input[y] then\r",
- " if input[y][x] then\r",
- " table.insert(output,input[y][x])\r",
- " end\r",
- " end\r",
- " if frame >= 50 then\r",
- " --yield()\r",
- " frame = 0\r",
- " end\r",
- " end\r",
- " end\r",
- " return output\r",
- "end\r",
- "\r",
- "local grayOut = function(color)\r",
- " local c = deepCopy(_G.colors)\r",
- " local grays = {\r",
- " [c.white] = c.white,\r",
- " [c.orange] = c.lightGray,\r",
- " [c.magenta] = c.lightGray,\r",
- " [c.lightBlue] = c.lightGray,\r",
- " [c.yellow] = c.white,\r",
- " [c.lime] = c.lightGray,\r",
- " [c.pink] = c.lightGray,\r",
- " [c.gray] = c.gray,\r",
- " [c.lightGray] = c.lightGray,\r",
- " [c.cyan] = c.lightGray,\r",
- " [c.purple] = c.gray,\r",
- " [c.blue] = c.gray,\r",
- " [c.brown] = c.gray,\r",
- " [c.green] = c.lightGray,\r",
- " [c.red] = c.gray,\r",
- " [c.black] = c.black,\r",
- " }\r",
- " local newColor = grays[color] or 1\r",
- " return newColor\r",
- "end\r",
- "\r",
- "local getOnscreenCoords = function(tbl,_x,_y)\r",
- " local screenTbl = {}\r",
- " for a = 1, #tbl do\r",
- " if tbl[a].x+paint.scrollX > 0 and tbl[a].x+paint.scrollX <= scr_x then\r",
- " if tbl[a].y+paint.scrollY > 0 and tbl[a].y+paint.scrollY <= scr_y then\r",
- " table.insert(screenTbl,{tbl[a].x+paint.scrollX,tbl[a].y+paint.scrollY})\r",
- " end\r",
- " end\r",
- " end\r",
- " if not _x and _y then\r",
- " return screenTbl\r",
- " else\r",
- " for a = 1, #screenTbl do\r",
- " if screenTbl[a][1] == _x and screenTbl[a][2] == _y then\r",
- " return true\r",
- " end\r",
- " end\r",
- " return false\r",
- " end\r",
- "end\r",
- "\r",
- "local fillTool = function(info,cx,cy,color,layer) --takes a frame, not the whole paintEncoded\r",
- " local x,y\r",
- " local output = {}\r",
- " for a = 1, #info do\r",
- " if (info[a].x == cx) and (info[a].y == cy) then\r",
- " x = cx\r",
- " y = cy\r",
- " replaceColor = info[a].b\r",
- " break\r",
- " end\r",
- " end\r",
- " if not x and y then\r",
- " return\r",
- " end\r",
- " if color == replaceColor then\r",
- " return\r",
- " end\r",
- " table.insert(output,{\r",
- " [\"x\"] = x,\r",
- " [\"y\"] = y,\r",
- " [\"b\"] = color,\r",
- " [\"t\"] = color,\r",
- " [\"c\"] = \" \",\r",
- " [\"m\"] = paint.m\r",
- " })\r",
- " local loops = 0\r",
- " local tAffectedPoints = {\r",
- " [1] = {\r",
- " x = x+tTerm.scroll.x,\r",
- " z = z+tTerm.scroll.z\r",
- " }\r",
- " }\r",
- " while #tAffectedPoints > 0 do\r",
- " if loops%200 == 0 then\r",
- " sleep(0.05)\r",
- " end\r",
- " for i=-1,1,2 do\r",
- " local x = tAffectedPoints[1][\"x\"]+i\r",
- " local z = tAffectedPoints[1][\"z\"]\r",
- " if tBlueprint[layer][x][z] == replaceColor and x >= tTerm.viewable.sX and x <= tTerm.viewable.eX and z >= tTerm.viewable.sZ and z <= tTerm.viewable.eZ then\r",
- " drawPoint(x,z,color,layer,true,true)\r",
- " table.insert(tAffectedPoints,{[\"x\"] = x,[\"z\"] = z})\r",
- " end\r",
- " x = tAffectedPoints[1][\"x\"]\r",
- " z = tAffectedPoints[1][\"z\"]+i\r",
- " if tBlueprint[layer][x][z] == replaceColor and x >= tTerm.viewable.sX and x <= tTerm.viewable.eX and z >= tTerm.viewable.sZ and z <= tTerm.viewable.eZ then\r",
- " drawPoint(x,z,color,layer,true,true)\r",
- " table.insert(tAffectedPoints,{[\"x\"] = x,[\"z\"] = z})\r",
- " end\r",
- " end\r",
- " table.remove(tAffectedPoints,1)\r",
- " loops = loops+1\r",
- " end\r",
- "end\r",
- "\r",
- "local saveFile = function(path,info)\r",
- " local output = {}\r",
- " for a = 1, #info do\r",
- " output[a] = clearRedundant(info[a])\r",
- " if a % 8 == 0 then yield() end\r",
- " end\r",
- " local fileout = textutils.serialize(output):gsub(\" \",\"\"):gsub(\"\\n\",\"\"):gsub(\" = \",\"=\"):gsub(\",}\",\"}\")\r",
- " if #fileout >= fs.getFreeSpace(fs.getDir(path)) then\r",
- " barmsg = \"Not enough space.\"\r",
- " return\r",
- " end\r",
- " local file = fs.open(path,\"w\")\r",
- " file.write(fileout)\r",
- " file.close()\r",
- "end\r",
- "local renderBar = function(msg,dontSetVisible)\r",
- " local tsv = term.current().setVisible\r",
- " if (doRenderBar == 0) or renderBlittle then return end\r",
- " if tsv and (not dontSetVisible) then tsv(false) end\r",
- " term.setCursorPos(1,scr_y)\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " term.setTextColor(colors.black)\r",
- " term.clearLine()\r",
- " term.setBackgroundColor(paint.b)\r",
- " term.setTextColor(paint.t)\r",
- " term.setCursorPos(2,scr_y)\r",
- " term.write(\"PAIN\")\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " term.setTextColor(colors.black)\r",
- " term.setCursorPos(7,scr_y)\r",
- " term.write(msg..\" Frame: \"..frame..\"/\"..#paintEncoded)\r",
- " term.write(\" (X:\"..paint.scrollX..\" Y:\"..paint.scrollY..\")\")\r",
- " if tsv and (not dontSetVisible) then tsv(true) end\r",
- "end\r",
- "\r",
- "local rendback = {\r",
- " b = colors.black,\r",
- " t = colors.gray,\r",
- "}\r",
- "\r",
- "local getTablePaint = function(pe)\r",
- " local output = {}\r",
- " for a = 1, #pe do\r",
- " if not output[pe[a].y] then output[pe[a].y] = {} end\r",
- " output[pe[a].y][pe[a].x] = pe[a]\r",
- " end\r",
- " return output\r",
- "end\r",
- "\r",
- "local renderPainyThings = function(xscroll,yscroll,doGrid)\r",
- " if bepimode then\r",
- " grid = {\r",
- " \"Bepis\",\r",
- " \"episB\",\r",
- " \"pisBe\",\r",
- " \"isBep\",\r",
- " \"sBepi\",\r",
- " }\r",
- " else\r",
- " grid = {\r",
- " \"%%..\",\r",
- " \"%%..\",\r",
- " \"%%..\",\r",
- " \"..%%\",\r",
- " \"..%%\",\r",
- " \"..%%\",\r",
- " }\r",
- " end\r",
- " term.setBackgroundColor(rendback.b)\r",
- " term.setTextColor(rendback.t)\r",
- " local badchar = \"/\"\r",
- " local blittlelabel = \"blittle max\"\r",
- " local screenlabel = \"screen max\"\r",
- " if doGrid then\r",
- " for y = 1, scr_y-(renderBlittle and 0 or doRenderBar) do\r",
- " term.setCursorPos(1,y)\r",
- " --the single most convoluted line I've ever written that works, and I love it\r",
- " term.write(stringShift(grid[ro(y+(yscroll+2),#grid)+1],xscroll+1):rep(math.ceil(scr_x/#grid[ro(y+(yscroll+2),#grid)+1])):sub(1,scr_x))\r",
- " term.setCursorPos(1,y)\r",
- " if ((scr_y+1)-yscroll) == y then --regular limit\r",
- " term.write( (string.rep(\"@\", ( (scr_x) ) - (#screenlabel+2) ) ..screenlabel:gsub(\" \",\"@\"):upper()..\"@@\"):sub(xscroll>0 and xscroll or 0) )\r",
- " elseif (((scr_y*3)+1)-yscroll) == y then --blittle limit\r",
- " term.write( (string.rep(\"@\", ( ((scr_x*2)) ) - (#blittlelabel+2) )..blittlelabel:gsub(\" \",\"@\"):upper()..\"@@\"):sub(xscroll>0 and xscroll or 0) )\r",
- " end\r",
- " --Stupid easter eggs, ho!--\r",
- " if 1000-yscroll == y then\r",
- " term.setCursorPos(1000-xscroll,y)\r",
- " term.write(\" What ARE you doing? Stop messing around! \")\r",
- " end\r",
- " if 2016-yscroll == y then\r",
- " term.setCursorPos(200-xscroll,y)\r",
- " term.write(\" MOTHER 3 is the best RPG ever. \")\r",
- " end\r",
- " if 2017-yscroll == y then\r",
- " term.setCursorPos(200-xscroll,y)\r",
- " term.write(\" Wouldn't you agree? \")\r",
- " end\r",
- " if 800-yscroll == y then\r",
- " term.setCursorPos(1700-xscroll,y)\r",
- " term.write(\" Which would you say is better? \")\r",
- " end\r",
- " if 801-yscroll == y then\r",
- " term.setCursorPos(1700-xscroll,y)\r",
- " term.write(\" Cave Story or Braid? \")\r",
- " end\r",
- " if 802-yscroll == y then\r",
- " term.setCursorPos(1700-xscroll,y)\r",
- " term.write(\" It depends what you're looking for. \")\r",
- " end\r",
- " --Is this the end?--\r",
- " if (xscroll > scr_x) and (xscroll < (scr_x*2)+1) then --blittle limit\r",
- " for y = 1, scr_y do\r",
- " if y+yscroll <= (scr_y*3) then\r",
- " if not (y == scr_y and doRenderBar == 1) then\r",
- " term.setCursorPos((scr_x+1)-(xscroll-scr_x),y)\r",
- " term.write(\"@\")\r",
- " end\r",
- " end\r",
- " end\r",
- " elseif (xscroll > 0) then --regular limit\r",
- " for y = 1, scr_y do\r",
- " if y+yscroll <= scr_y then\r",
- " if not (y == scr_y and doRenderBar == 1) then\r",
- " term.setCursorPos((scr_x+1)-xscroll,y)\r",
- " term.write(\"@\")\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " --render areas that won't save\r",
- " if xscroll < 0 then\r",
- " for y = 1, scr_y do\r",
- " if not (y == scr_y and doRenderBar == 1) then\r",
- " term.setCursorPos(1,y)\r",
- " term.write(badchar:rep(-xscroll))\r",
- " end\r",
- " end\r",
- " end\r",
- " if yscroll < 0 then\r",
- " for y = 1, -yscroll do\r",
- " if not (y == scr_y and doRenderBar == 1) then\r",
- " term.setCursorPos(1,y)\r",
- " term.write(badchar:rep(scr_x))\r",
- " end\r",
- " end\r",
- " end\r",
- " else\r",
- " term.clear()\r",
- " end\r",
- "end\r",
- "\r",
- "renderPAIN = function(dots,xscroll,yscroll,doPain)\r",
- " local tsv = term.current().setVisible\r",
- " if tsv then tsv(false) end\r",
- " local beforeTX,beforeBG = term.getTextColor(), term.getBackgroundColor()\r",
- " local cx,cy = term.getCursorPos()\r",
- " local FUCK, SHIT = pcall(function()\r",
- " if doPain then\r",
- " renderPainyThings(xscroll,yscroll,evenDrawGrid)\r",
- " renderBar(barmsg,true)\r",
- " end\r",
- " for a = 1, #dots do\r",
- " local d = dots[a]\r",
- " if doPain then\r",
- " if not ((d.y-yscroll >= 1 and d.y-yscroll <= scr_y-(renderBlittle and 0 or (doRenderBar or 0))) and (d.x-xscroll >= 1 and d.x-xscroll <= scr_x)) then\r",
- " d = nil\r",
- " end\r",
- " end\r",
- " if d then\r",
- " term.setCursorPos(d.x-(xscroll or 0),d.y-(yscroll or 0))\r",
- " term.setTextColor((paint.doGray and grayOut(d.t)) or d.t)\r",
- " term.setBackgroundColor((paint.doGray and grayOut(d.b)) or d.b)\r",
- " term.write(d.c)\r",
- " end\r",
- " end\r",
- " end)\r",
- " term.setBackgroundColor(beforeBG)\r",
- " term.setTextColor(beforeTX)\r",
- " term.setCursorPos(cx,cy)\r",
- " if tsv then tsv(true) end\r",
- " if not FUCK then error(SHIT) end --GODDAMN IT\r",
- "end\r",
- "\r",
- "renderPAINFS = function(filename,xscroll,yscroll,frameNo,doPain)\r",
- " local tun, tse = textutils.unserialize, textutils.serialize\r",
- " local file = fs.open(filename,\"r\")\r",
- " local contents = file.readAll()\r",
- " local amntFrames\r",
- " file.close()\r",
- " local tcontents = tun(contents)\r",
- " if type(tcontents) ~= \"table\" then\r",
- " tcontents = importFromNFP(contents)\r",
- " else\r",
- " amntFrames = #tcontents\r",
- " tcontents = tcontents[frameNo or 1]\r",
- " end\r",
- " renderPAIN(tcontents,xscroll,yscroll,doPain)\r",
- " return amntFrames\r",
- "end\r",
- "\r",
- "local getBlittle = function()\r",
- " if not blittle then\r",
- " local geet = http.get(\"http://pastebin.com/raw/ujchRSnU\")\r",
- " if not geet then\r",
- " return false\r",
- " else\r",
- " geet = geet.readAll()\r",
- " local file = fs.open(\"/.templittle/blittle\",\"w\")\r",
- " file.write(geet)\r",
- " file.close()\r",
- " os.loadAPI(\"/.templittle/blittle\")\r",
- " fs.delete(\"/.templittle/\")\r",
- " if not blittleTerm then\r",
- " blittleTerm = blittle.createWindow()\r",
- " end\r",
- " return blittleTerm, firstTerm\r",
- " end\r",
- " else\r",
- " if not blittleTerm then\r",
- " blittleTerm = blittle.createWindow()\r",
- " end\r",
- " return blittleTerm, firstTerm\r",
- " end\r",
- "end\r",
- "\r",
- "local putDownText = function(x,y)\r",
- " term.setCursorPos(x,y)\r",
- " term.setTextColor((paint.doGray and grayOut(paint.t)) or paint.t)\r",
- " term.setBackgroundColor((paint.doGray and grayOut(paint.b)) or paint.b)\r",
- " local msg = read()\r",
- " if #msg > 0 then\r",
- " for a = 1, #msg do\r",
- " table.insert(paintEncoded[frame],{x=a+(x+paint.scrollX)-1,y=y+paint.scrollY,t=paint.t,b=paint.b,c=msg:sub(a,a),m=paint.m})\r",
- " end\r",
- " end\r",
- "end\r",
- "\r",
- "local deleteDot = function(x,y)\r",
- " local good = false\r",
- " for a = #paintEncoded[frame],1,-1 do\r",
- " local b = paintEncoded[frame][a]\r",
- " if (x == b.x) and (y == b.y) then\r",
- " table.remove(paintEncoded[frame],a)\r",
- " good = true\r",
- " end\r",
- " end\r",
- " return good\r",
- "end\r",
- "\r",
- "CTB = function(_color) --Color To Blit\r",
- " local blitcolors = {\r",
- " [colors.white] = \"0\",\r",
- " [colors.orange] = \"1\",\r",
- " [colors.magenta] = \"2\",\r",
- " [colors.lightBlue] = \"3\",\r",
- " [colors.yellow] = \"4\",\r",
- " [colors.lime] = \"5\",\r",
- " [colors.pink] = \"6\",\r",
- " [colors.gray] = \"7\",\r",
- " [colors.lightGray] = \"8\",\r",
- " [colors.cyan] = \"9\",\r",
- " [colors.purple] = \"a\",\r",
- " [colors.blue] = \"b\",\r",
- " [colors.brown] = \"c\",\r",
- " [colors.green] = \"d\",\r",
- " [colors.red] = \"e\",\r",
- " [colors.black] = \"f\",\r",
- " }\r",
- " return blitcolors[_color] or \"f\"\r",
- "end\r",
- "\r",
- "BTC = function(_color) --Blit To Color\r",
- " local blitcolors = {\r",
- " [\"0\"] = colors.white,\r",
- " [\"1\"] = colors.orange,\r",
- " [\"2\"] = colors.magenta,\r",
- " [\"3\"] = colors.lightBlue,\r",
- " [\"4\"] = colors.yellow,\r",
- " [\"5\"] = colors.lime,\r",
- " [\"6\"] = colors.pink,\r",
- " [\"7\"] = colors.gray,\r",
- " [\"8\"] = colors.lightGray,\r",
- " [\"9\"] = colors.cyan,\r",
- " [\"a\"] = colors.purple,\r",
- " [\"b\"] = colors.blue,\r",
- " [\"c\"] = colors.brown,\r",
- " [\"d\"] = colors.green,\r",
- " [\"e\"] = colors.red,\r",
- " [\"f\"] = colors.black,\r",
- " }\r",
- " return blitcolors[_color]\r",
- "end\r",
- "\r",
- "exportToNFP = function(input)\r",
- " local doop = {}\r",
- " local p = input\r",
- " local pheight = 0\r",
- " local pwidth = 0\r",
- " for a = 1, #p do\r",
- " if p[a].y > pheight then\r",
- " pheight = p[a].y\r",
- " end\r",
- " if p[a].x > pwidth then\r",
- " pwidth = p[a].x\r",
- " end\r",
- " end\r",
- " for k,v in pairs(p) do\r",
- " if not doop[v.y] then doop[v.y] = {} end\r",
- " doop[v.y][v.x] = CTB(v.b)\r",
- " end\r",
- " for y = 1, pheight do\r",
- " if doop[y] then\r",
- " for x = 1, pwidth do\r",
- " if doop[y][x] then\r",
- " nfpoutput = nfpoutput..doop[y][x]\r",
- " else\r",
- " nfpoutput = nfpoutput..\" \"\r",
- " end\r",
- " end\r",
- " end\r",
- " nfpoutput = nfpoutput..\"\\n\"\r",
- " end\r",
- " return nfpoutput\r",
- "end\r",
- "\r",
- "importFromNFP = function(theInput)\r",
- " local output = {}\r",
- " local input = explode(\"\\n\",theInput)\r",
- " for a = 1, #input do\r",
- " line = input[a]\r",
- " for b = 1, #line do\r",
- " if (line:sub(b,b) ~= \" \") and BTC(line:sub(b,b)) then\r",
- " table.insert(output,{\r",
- " x = b,\r",
- " y = a,\r",
- " t = colors.white,\r",
- " b = BTC(line:sub(b,b)) or colors.black,\r",
- " c = \" \",\r",
- " })\r",
- " end\r",
- " end\r",
- " end\r",
- " return output\r",
- "end\r",
- "\r",
- "local getTheDoots = function(pe)\r",
- " local hasBadDots = false\r",
- " local baddestX,baddestY = 1,1\r",
- " barmsg = \"Checking...\"\r",
- " for b = 1, #pe do\r",
- " local doot = pe[b]\r",
- " if doot.x <= 0 or doot.y <= 0 then\r",
- " hasBadDots = true\r",
- " if doot.x < baddestX then\r",
- " baddestX = doot.x\r",
- " end\r",
- " if doot.y < baddestY then\r",
- " baddestY = doot.y\r",
- " end\r",
- " end\r",
- " if b % 64 == 0 then yield() end\r",
- " end\r",
- " return baddestX, baddestY\r",
- "end\r",
- "\r",
- "local function deepcompare(t1,t2,ignore_mt)\r",
- " local ty1 = type(t1)\r",
- " local ty2 = type(t2)\r",
- " if ty1 ~= ty2 then return false end\r",
- " -- non-table types can be directly compared\r",
- " if ty1 ~= 'table' and ty2 ~= 'table' then return t1 == t2 end\r",
- " -- as well as tables which have the metamethod __eq\r",
- " local mt = getmetatable(t1)\r",
- " if not ignore_mt and mt and mt.__eq then return t1 == t2 end\r",
- " for k1,v1 in pairs(t1) do\r",
- " local v2 = t2[k1]\r",
- " if v2 == nil or not deepcompare(v1,v2) then return false end\r",
- " end\r",
- " for k2,v2 in pairs(t2) do\r",
- " local v1 = t1[k2]\r",
- " if v1 == nil or not deepcompare(v1,v2) then return false end\r",
- " end\r",
- " return true\r",
- "end\r",
- "\r",
- "local displayMenu = function()\r",
- " menuOptions = {\"Save\",\"Export\",\"Del.frame\",\"Clear\",\"Exit\"}\r",
- " local diss = \" \"..table.concat(menuOptions,\" \")\r",
- " local cleary = scr_y-math.floor(#diss/scr_x)\r",
- " for a = cleary,scr_y do\r",
- " term.setCursorPos(1,a)\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " term.clearLine()\r",
- " end\r",
- " local menuPoses = {}\r",
- " local menuFunctions = {\r",
- " [1] = function() --Save\r",
- " local hasBadDots = false\r",
- " for a = 1, #paintEncoded do\r",
- " local radx,rady = getTheDoots(paintEncoded[a])\r",
- " if radx ~= 1 or rady ~= 1 then\r",
- " hasBadDots = true\r",
- " end\r",
- " end\r",
- " if hasBadDots then\r",
- " local ting = bottomPrompt(\"Dot(s) are OoB! Save or fix? (Y/N/F)\",_,\"ynf\",{keys.leftCtrl,keys.rightCtrl})\r",
- " if ting == \"f\" then\r",
- " for a = 1, #paintEncoded do\r",
- " local baddestX, baddestY = getTheDoots(paintEncoded[a])\r",
- " paintEncoded[a] = movePaintEncoded(paintEncoded[a],-(baddestX-1),-(baddestY-1))\r",
- " end\r",
- " elseif ting ~= \"y\" then\r",
- " barmsg = \"\"\r",
- " return false\r",
- " end\r",
- " end\r",
- " local output = deepCopy(paintEncoded)\r",
- " if paint.doGray then\r",
- " for a = 1, #paintEncoded do\r",
- " for b = 1, #paintEncoded[a] do\r",
- " output[a][b].b = grayOut(paintEncoded[a][b].b)\r",
- " output[a][b].t = grayOut(paintEncoded[a][b].t)\r",
- " if not output[a][b].m then output[a][b].m = 1 end\r",
- " end\r",
- " if a % 2 == 0 then yield() end\r",
- " end\r",
- " end\r",
- " saveFile(fileName,output)\r",
- " lastPaintEncoded = deepCopy(paintEncoded)\r",
- " term.setCursorPos(9,scr_y)\r",
- " barmsg = \"Saved as '\"..fileName..\"'\"\r",
- " doRender = true\r",
- " end,\r",
- " [2] = function() --Export\r",
- " nfpoutput = \"\"\r",
- " local exportName = bottomPrompt(\"Export to: /\")\r",
- " if fs.combine(\"\",exportName) == \"\" then return end\r",
- " if fs.isReadOnly(exportName) then\r",
- " barmsg = \"That's read-only.\"\r",
- " doRender = true\r",
- " return\r",
- " end\r",
- " if fs.exists(exportName) then\r",
- " if bottomPrompt(\"Overwrite? (Y/N)\",_,\"yn\",{keys.leftCtrl,keys.rightCtrl}) ~= \"y\" then return end\r",
- " end\r",
- " local output = exportToNFP(paintEncoded[frame])\r",
- " local file = fs.open(exportName,\"w\")\r",
- " file.write(output)\r",
- " file.close()\r",
- " doRender = true\r",
- " barmsg = \"Exported as '\"..exportName..\"'\"\r",
- " return\r",
- " end,\r",
- " [3] = function() --Del.Frame\r",
- " local outcum = bottomPrompt(\"Thou art sure? (Y/N)\",_,\"yn\",{keys.leftCtrl,keys.rightCtrl})\r",
- " if outcum == \"y\" then\r",
- " if #paintEncoded == 1 then\r",
- " barmsg = \"Ha! You can't do that.\"\r",
- " return\r",
- " end\r",
- " table.remove(paintEncoded,frame)\r",
- " barmsg = \"Deleted frame \"..frame..\".\"\r",
- " if paintEncoded[frame-1] then\r",
- " frame = frame - 1\r",
- " else\r",
- " frame = frame + 1\r",
- " end\r",
- " if #paintEncoded < frame then\r",
- " repeat\r",
- " frame = frame - 1\r",
- " until #paintEncoded >= frame\r",
- " end\r",
- " --renderPAIN(paintEncoded[frame],paint.scrollX,paint.scrollY,true)\r",
- " end\r",
- " doRender = true\r",
- " end,\r",
- " [4] = function() --Clear\r",
- " local outcum = bottomPrompt(\"Clear the frame? (Y/N)\",_,\"yn\",{keys.leftCtrl,keys.rightCtrl})\r",
- " if outcum == \"y\" then\r",
- " paintEncoded[frame] = {}\r",
- " barmsg = \"Cleared frame \"..frame..\".\"\r",
- " --renderPAIN(paintEncoded[frame],paint.scrollX,paint.scrollY,true)\r",
- " end\r",
- " doRender = true\r",
- " end,\r",
- " [5] = function() --Exit\r",
- " if not deepcompare(lastPaintEncoded,paintEncoded) then\r",
- " local outcum = bottomPrompt(\"Abandon unsaved work? (Y/N)\",_,\"yn\",{keys.leftCtrl,keys.rightCtrl})\r",
- " sleep(0)\r",
- " if outcum == \"y\" then\r",
- " return \"exit\"\r",
- " else\r",
- " doRender = true\r",
- " return nil\r",
- " end\r",
- " else\r",
- " return \"exit\"\r",
- " end\r",
- " end,\r",
- " }\r",
- " local cursor = 1\r",
- " local redrawmenu = true\r",
- " local initial = os.time()\r",
- " local clickdelay = 0.003\r",
- " while true do\r",
- " if redrawmenu then\r",
- " term.setCursorPos(2,cleary)\r",
- " term.clearLine()\r",
- " for a = 1, #menuOptions do\r",
- " if a == cursor then\r",
- " term.setTextColor(colors.black)\r",
- " term.setBackgroundColor(colors.white)\r",
- " else\r",
- " term.setTextColor(colors.black)\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " end\r",
- " menuPoses[a] = {term.getCursorPos()}\r",
- " write(menuOptions[a])\r",
- " term.setBackgroundColor(colors.lightGray)\r",
- " if a ~= #menuOptions then\r",
- " write(\" \")\r",
- " end\r",
- " end\r",
- " redrawmenu = false\r",
- " end\r",
- " local event,key,x,y = getEvents(\"key\",\"char\",\"mouse_click\",\"mouse_up\",\"mouse_drag\")\r",
- " if event == \"key\" then\r",
- " if key == keys.left then\r",
- " redrawmenu = true\r",
- " cursor = cursor - 1\r",
- " elseif key == keys.right then\r",
- " redrawmenu = true\r",
- " cursor = cursor + 1\r",
- " elseif key == keys.enter then\r",
- " local res = menuFunctions[cursor]()\r",
- " if res == \"exit\" then\r",
- " return \"exit\"\r",
- " else\r",
- " return\r",
- " end\r",
- " elseif key == keys.leftCtrl or key == keys.rightCtrl then\r",
- " doRender = true\r",
- " return\r",
- " end\r",
- " elseif event == \"char\" then\r",
- " for a = 1, #menuOptions do\r",
- " if key:lower() == menuOptions[a]:sub(1,1):lower() and a ~= cursor then\r",
- " cursor = a\r",
- " redrawmenu = true\r",
- " break\r",
- " end\r",
- " end\r",
- " elseif event == \"mouse_click\" or event == \"mouse_up\" then\r",
- " if y < cleary then\r",
- " return\r",
- " elseif key == 1 and initial+clickdelay < os.time() then --key? more like button\r",
- " for a = 1, #menuPoses do\r",
- " if y == menuPoses[a][2] then\r",
- " if x >= menuPoses[a][1] and x <= menuPoses[a][1]+#menuOptions[a] then\r",
- " local res = menuFunctions[a]()\r",
- " if res == \"exit\" then\r",
- " return \"exit\"\r",
- " else\r",
- " return\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " --elseif event == \"mouse_drag\" then\r",
- " end\r",
- " if (initial+clickdelay < os.time()) and string.find(event,\"mouse\") then\r",
- " if key == 1 then --key? key? what key? all I see is button!\r",
- " for a = 1, #menuPoses do\r",
- " if y == menuPoses[a][2] then\r",
- " if x >= menuPoses[a][1] and x <= menuPoses[a][1]+#menuOptions[a] then\r",
- " cursor = a\r",
- " redrawmenu = true\r",
- " break\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " end\r",
- " if cursor < 1 then\r",
- " cursor = #menuOptions\r",
- " elseif cursor > #menuOptions then\r",
- " cursor = 1\r",
- " end\r",
- " end\r",
- "end\r",
- "\r",
- "local lastMX,lastMY\r",
- "\r",
- "local doNonEventDrivenMovement = function() --what a STUPID function name, man\r",
- " local didMove\r",
- " while true do\r",
- " didMove = false\r",
- " if (not keysDown[keys.leftShift]) and (not isDragging) and (not keysDown[keys.tab]) then\r",
- " if keysDown[keys.right] then\r",
- " paint.scrollX = paint.scrollX + 1\r",
- " didMove = true\r",
- " elseif keysDown[keys.left] then\r",
- " paint.scrollX = paint.scrollX - 1\r",
- " didMove = true\r",
- " end\r",
- " if keysDown[keys.down] then\r",
- " paint.scrollY = paint.scrollY + 1\r",
- " didMove = true\r",
- " elseif keysDown[keys.up] then\r",
- " paint.scrollY = paint.scrollY - 1\r",
- " didMove = true\r",
- " end\r",
- " if didMove then\r",
- " if lastMX and lastMY then\r",
- " if miceDown[1] then\r",
- " os.queueEvent(\"mouse_click\",1,lastMX,lastMY)\r",
- " end\r",
- " if miceDown[2] then\r",
- " os.queueEvent(\"mouse_click\",2,lastMX,lastMY)\r",
- " end\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " end\r",
- " sleep(0)\r",
- " end\r",
- "end\r",
- "\r",
- "local linePoses = {}\r",
- "local dragPoses = {}\r",
- "\r",
- "local getInput = function() --gotta catch them all\r",
- " local button, x, y, oldmx, oldmy, origx, origy\r",
- " local isDragging = false\r",
- " local proceed = false\r",
- " renderBar(barmsg)\r",
- " while true do\r",
- " doRender = false\r",
- " local oldx,oldy = paint.scrollX,paint.scrollY\r",
- " local evt = {getEvents(\"mouse_scroll\",\"mouse_click\", \"mouse_drag\",\"mouse_up\",\"key\",\"key_up\",true)}\r",
- " if (evt[1] == \"mouse_scroll\") and (not viewing) then\r",
- " local dir = evt[2]\r",
- " if dir == 1 then\r",
- " if keysDown[keys.leftShift] or keysDown[keys.rightShift] then\r",
- " paint.t = paint.t * 2\r",
- " if paint.t > 32768 then\r",
- " paint.t = 32768\r",
- " end\r",
- " else\r",
- " paint.b = paint.b * 2\r",
- " if paint.b > 32768 then\r",
- " paint.b = 32768\r",
- " end\r",
- " end\r",
- " else\r",
- " if keysDown[keys.leftShift] or keysDown[keys.rightShift] then\r",
- " paint.t = math.ceil(paint.t / 2)\r",
- " if paint.t < 1 then\r",
- " paint.t = 1\r",
- " end\r",
- " else\r",
- " paint.b = math.ceil(paint.b / 2)\r",
- " if paint.b < 1 then\r",
- " paint.b = 1\r",
- " end\r",
- " end\r",
- " end\r",
- " renderBar(barmsg)\r",
- " elseif ((evt[1] == \"mouse_click\") or (evt[1] == \"mouse_drag\")) and (not viewing) then\r",
- " if evt[1] == \"mouse_click\" then\r",
- " origx, origy = evt[3], evt[4]\r",
- " end\r",
- " oldmx,oldmy = x or evt[3], y or evt[4]\r",
- " lastMX,lastMY = evt[3],evt[4]\r",
- " button,x,y = evt[2],evt[3],evt[4]\r",
- " if renderBlittle then\r",
- " x = 2*x\r",
- " y = 3*y\r",
- " lastMX = 2*lastMX\r",
- " lastMY = 3*lastMY\r",
- " end\r",
- " linePoses = {{x=oldmx,y=oldmy},{x=x,y=y}}\r",
- " miceDown[button] = true\r",
- " doRender = true\r",
- " if y <= scr_y-(renderBlittle and 0 or doRenderBar) then\r",
- " if (button == 3) then\r",
- " putDownText(x,y)\r",
- " miceDown = {}\r",
- " keysDown = {}\r",
- " elseif button == 1 then\r",
- " if keysDown[keys.leftShift] and evt[1] == \"mouse_click\" then\r",
- " isDragging = true\r",
- " end\r",
- " if isDragging then\r",
- " if evt[1] == \"mouse_click\" then\r",
- " dragPoses[1] = {x=x,y=y}\r",
- " end\r",
- " dragPoses[2] = {x=x,y=y}\r",
- " else\r",
- " if evt[1] == \"mouse_drag\" then\r",
- " local points = getDotsInLine(linePoses[1].x,linePoses[1].y,linePoses[2].x,linePoses[2].y)\r",
- " for a = 1, #points do\r",
- " table.insert(paintEncoded[frame],{\r",
- " x = points[a].x + paint.scrollX,\r",
- " y = points[a].y + paint.scrollY,\r",
- " c = paint.c,\r",
- " b = paint.b,\r",
- " t = paint.t,\r",
- " m = paint.m,\r",
- " })\r",
- " end\r",
- " else\r",
- " table.insert(paintEncoded[frame],{\r",
- " x = x + paint.scrollX,\r",
- " y = y + paint.scrollY,\r",
- " c = paint.c,\r",
- " b = paint.b,\r",
- " t = paint.t,\r",
- " m = paint.m,\r",
- " })\r",
- " end\r",
- " end\r",
- " elseif button == 2 and y <= scr_y-(renderBlittle and 0 or doRenderBar) then\r",
- " deleteDot(x+paint.scrollX,y+paint.scrollY)\r",
- " end\r",
- " elseif origy >= scr_y-(renderBlittle and 0 or doRenderBar) then\r",
- " keysDown = {}\r",
- " local res = displayMenu()\r",
- " if res == \"exit\" then break end\r",
- " doRender = true\r",
- " end\r",
- " elseif (evt[1] == \"mouse_up\") and (not viewing) then\r",
- " origx,origy = 0,0\r",
- " local button = evt[2]\r",
- " miceDown[button] = false\r",
- " oldmx,oldmy = nil,nil\r",
- " lastMX, lastMY = nil,nil\r",
- " if isDragging then\r",
- " local points = getDotsInLine(dragPoses[1].x,dragPoses[1].y,dragPoses[2].x,dragPoses[2].y)\r",
- " for a = 1, #points do\r",
- " table.insert(paintEncoded[frame],{\r",
- " x = points[a].x + paint.scrollX,\r",
- " y = points[a].y + paint.scrollY,\r",
- " c = paint.c,\r",
- " b = paint.b,\r",
- " t = paint.t,\r",
- " m = paint.m,\r",
- " })\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " isDragging = false\r",
- " elseif evt[1] == \"key\" then\r",
- " local key = evt[2]\r",
- " if (not keysDown[keys.leftShift]) and (keysDown[keys.tab]) then\r",
- " if key == keys.right and (not keysDown[keys.right]) then\r",
- " paint.scrollX = paint.scrollX + 1\r",
- " doRender = true\r",
- " elseif key == keys.left and (not keysDown[keys.left]) then\r",
- " paint.scrollX = paint.scrollX - 1\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.down and (not keysDown[keys.down]) then\r",
- " paint.scrollY = paint.scrollY + 1\r",
- " doRender = true\r",
- " elseif key == keys.up and (not keysDown[keys.up]) then\r",
- " paint.scrollY = paint.scrollY - 1\r",
- " doRender = true\r",
- " end\r",
- " end\r",
- " keysDown[key] = true\r",
- " if key == keys.space then\r",
- " if keysDown[keys.leftShift] then\r",
- " evenDrawGrid = not evenDrawGrid\r",
- " else\r",
- " doRenderBar = math.abs(doRenderBar-1)\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.b then\r",
- " local blTerm, oldTerm = getBlittle()\r",
- " renderBlittle = not renderBlittle\r",
- " term.setBackgroundColor(colors.black)\r",
- " term.clear()\r",
- " if renderBlittle then\r",
- " term.redirect(blTerm)\r",
- " blTerm.setVisible(true)\r",
- " else\r",
- " term.redirect(oldTerm)\r",
- " blTerm.setVisible(false)\r",
- " end\r",
- " doRender = true\r",
- " scr_x, scr_y = term.current().getSize()\r",
- " end\r",
- " if (key == keys.c) and (not renderBlittle) then\r",
- " local newX = tonumber(bottomPrompt(\"Goto X:\"))\r",
- " local newY\r",
- " if newX then\r",
- " newY = tonumber(bottomPrompt(\"Goto Y:\"))\r",
- " paint.scrollX = newX or paint.scrollX\r",
- " paint.scrollY = newY or paint.scrollY\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " if (keysDown[keys.leftShift]) and (not isDragging) then\r",
- " if key == keys.left then\r",
- " paintEncoded[frame] = movePaintEncoded(paintEncoded[frame],-1,0)\r",
- " doRender = true\r",
- " elseif key == keys.right then\r",
- " paintEncoded[frame] = movePaintEncoded(paintEncoded[frame],1,0)\r",
- " doRender = true\r",
- " elseif key == keys.up then\r",
- " paintEncoded[frame] = movePaintEncoded(paintEncoded[frame],0,-1)\r",
- " doRender = true\r",
- " elseif key == keys.down then\r",
- " paintEncoded[frame] = movePaintEncoded(paintEncoded[frame],0,1)\r",
- " doRender = true\r",
- " end\r",
- " end\r",
- " if keysDown[keys.leftAlt] then\r",
- " if #paintEncoded > 1 then\r",
- " if key == keys.equals and paintEncoded[frame+1] then --basically plus\r",
- " local first = deepCopy(paintEncoded[frame])\r",
- " local next = deepCopy(paintEncoded[frame+1])\r",
- " paintEncoded[frame] = next\r",
- " paintEncoded[frame+1] = first\r",
- " frame = frame + 1\r",
- " barmsg = \"Swapped prev frame.\"\r",
- " end\r",
- " if key == keys.minus and paintEncoded[frame-1] then\r",
- " local first = deepCopy(paintEncoded[frame])\r",
- " local next = deepCopy(paintEncoded[frame-1])\r",
- " paintEncoded[frame] = next\r",
- " paintEncoded[frame-1] = first\r",
- " frame = frame - 1\r",
- " barmsg = \"Swapped next frame.\"\r",
- " end\r",
- " end\r",
- " end\r",
- " if not renderBlittle then\r",
- " if key == keys.m then\r",
- " local incum = bottomPrompt(\"Set meta: \",metaHistory)\r",
- " paint.m = incum:gsub(\" \",\"\") ~= \"\" and incum or paint.m\r",
- " if paint.m ~= metaHistory[#metaHistory] then\r",
- " table.insert(metaHistory,paint.m)\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.f7 then\r",
- " bepimode = not bepimode\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.t then\r",
- " renderBottomBar(\"Click to place text.\")\r",
- " local mevt\r",
- " repeat\r",
- " mevt = {os.pullEvent(\"mouse_click\")}\r",
- " until mevt[2] == 1 and mevt[4] < scr_y-(renderBlittle and 0 or doRenderBar)\r",
- " local x,y = mevt[3],mevt[4]\r",
- " if renderBlittle then\r",
- " x = 2*x\r",
- " y = 3*y\r",
- " end\r",
- " putDownText(x,y)\r",
- " miceDown = {}\r",
- " keysDown = {}\r",
- " end\r",
- " if not keysDown[keys.leftAlt] then\r",
- " if key == keys.equals then --basically 'plus'\r",
- " if not paintEncoded[frame+1] then\r",
- " paintEncoded[frame+1] = {}\r",
- " local sheet = paintEncoded[frame]\r",
- " if keysDown[keys.leftShift] then\r",
- " paintEncoded[frame+1] = deepCopy(sheet)\r",
- " end\r",
- " end\r",
- " frame = frame + 1\r",
- " doRender = true\r",
- " elseif key == keys.minus then\r",
- " if frame > 1 then\r",
- " frame = frame - 1\r",
- " doRender = true\r",
- " end\r",
- " end\r",
- " end\r",
- " if (key == keys.leftCtrl or key == keys.rightCtrl) then\r",
- " keysDown = {}\r",
- " local res = displayMenu()\r",
- " if res == \"exit\" then break end\r",
- " doRender = true\r",
- " end\r",
- " end\r",
- " if (key == keys.f and keysDown[keys.leftShift]) then\r",
- " local deredots = {}\r",
- " for a = 1, #paintEncoded[frame] do\r",
- " local dot = paintEncoded[frame][a]\r",
- " if dot.x-paint.scrollX > 0 and dot.x-paint.scrollX <= scr_x then\r",
- " if dot.y-paint.scrollY > 0 and dot.y-paint.scrollY <= scr_y then\r",
- " table.insert(deredots,{dot.x-paint.scrollX, dot.y-paint.scrollY})\r",
- " end\r",
- " end\r",
- " end\r",
- " for y = 1, scr_y-(renderBlittle and 0 or doRenderBar) do\r",
- " for x = 1, scr_x do\r",
- " local good = true\r",
- " for a = 1, #deredots do\r",
- " if (deredots[a][1] == x) and (deredots[a][2] == y) then\r",
- " good = bad\r",
- " break\r",
- " end\r",
- " end\r",
- " if good then\r",
- " table.insert(paintEncoded[frame],{\r",
- " x = x+paint.scrollX,\r",
- " y = y+paint.scrollY,\r",
- " c = \" \",\r",
- " t = paint.t,\r",
- " b = paint.b,\r",
- " m = paint.m,\r",
- " })\r",
- " end\r",
- " end\r",
- " end\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.g then\r",
- " paint.doGray = not paint.doGray\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.a then\r",
- " paint.scrollX = 0\r",
- " paint.scrollY = 0\r",
- " doRender = true\r",
- " end\r",
- " if key == keys.f1 then\r",
- " guiHelp()\r",
- " end\r",
- " if key == keys.leftBracket then\r",
- " os.queueEvent(\"mouse_scroll\",2,1,1)\r",
- " elseif key == keys.rightBracket then\r",
- " os.queueEvent(\"mouse_scroll\",1,1,1)\r",
- " end\r",
- " elseif evt[1] == \"key_up\" then\r",
- " local key = evt[2]\r",
- " keysDown[key] = false\r",
- " end\r",
- " if (oldx~=paint.scrollX) or (oldy~=paint.scrollY) then\r",
- " doRender = true\r",
- " end\r",
- " if doRender then\r",
- " renderPAIN(paintEncoded[frame],paint.scrollX,paint.scrollY,true)\r",
- " doRender = false\r",
- " end\r",
- " end\r",
- "end\r",
- "\r",
- "if not shell then return end\r",
- "\r",
- "fileName = shell.resolve(tostring(tArg[1]))\r",
- "\r",
- "if not fs.exists(fileName) then\r",
- " paintEncoded = {{}}\r",
- "else\r",
- " local file = fs.open(fileName,\"r\")\r",
- " local contents = file.readAll()\r",
- " file.close()\r",
- " if type(tun(contents)) ~= \"table\" then\r",
- " if pMode ~= 1 then print(\"Importing from NFP...\") end\r",
- " paintEncoded = {importFromNFP(contents)}\r",
- " if fileName:sub(-4,-1) == \".nfp\" then\r",
- " fileName = fileName:sub(1,-5)\r",
- " end\r",
- " else\r",
- " paintEncoded = tun(contents)\r",
- " end\r",
- "end\r",
- "\r",
- "paintEncoded = tun(tse(paintEncoded):gsub(\"bg\",\"b\"):gsub(\"txt\",\"t\"):gsub(\"char\",\"c\"):gsub(\"meta\",\"m\")) -- gotta have backwards compatibility, sorta\r",
- "\r",
- "if not paintEncoded[frame] then paintEncoded = {paintEncoded} end\r",
- "if pMode == 1 then\r",
- " doRenderBar = 0\r",
- " renderPAIN(paintEncoded[tonumber(tArg[5]) or 1],tonumber(tArg[3]) or 0,tonumber(tArg[4]) or 0)\r",
- " sleep(0)\r",
- " return\r",
- "else\r",
- " renderPAIN(paintEncoded[frame],paint.scrollX,paint.scrollY,true)\r",
- "end\r",
- "lastPaintEncoded = deepCopy(paintEncoded)\r",
- "\r",
- "parallel.waitForAny(getInput,doNonEventDrivenMovement)\r",
- "\r",
- "term.setCursorPos(1,scr_y)\r",
- "term.setBackgroundColor(colors.black)\r",
- "term.clearLine()",
- },
- [ "/t" ] = {
- "",
- " 55555555 ",
- " 55555555 ",
- " 55555555 ",
- " 55555555 ",
- " 55555555 ",
- " d555555 ",
- " ddd5555 ",
- " dddd555 ",
- " dddd55 55555555 ",
- " 555dddddd5555555555555 ",
- "55555555ddddd5555555555 ",
- "5555555555dddd5555 ",
- " 555555555d ",
- " 55555 ",
- " 55555 ",
- " 55555 ",
- " 55555 ",
- " dd555 ",
- " 55dd5 dd5555",
- " dd55dd 5dddd55",
- " dddd55 5555ddd",
- " ddddddd 555555d",
- " dddddd d555555",
- " ddddddd 55d55555",
- " dddddddd ddd5dd55 ",
- " ddddddddddddddd55dd ",
- " dddddddddddddddd5 ",
- " ddddddddddddddddd ",
- " dddddddddddddddd ",
- " ddddddddddddddd ",
- " ddddddddddddd ",
- " ddddddddddd ",
- " ddddddd ",
- "",
- },
- [ "/render" ] = {
- "local mon = peripheral.find(\"monitor\") if mon then mon.setTextScale(0.5) end",
- "local sx,sy = term.getSize()",
- "letters = {}",
- "letters[1] = {",
- " path = \"/P\", --path to paint file",
- " x = 1, --start x",
- " xsize = 31, --horizontal size of paint file",
- "}",
- "letters[2] = {",
- " path = \"/r\",",
- " x = letters[1].x+letters[1].xsize-2,",
- " xsize = 25,",
- "}",
- "letters[3] = {",
- " path = \"o\",",
- " x = letters[2].x+letters[2].xsize+1,",
- " xsize = 18,",
- "}",
- "letters[4] = {",
- " path = \"j\",",
- " x = letters[3].x+letters[3].xsize+2,",
- " xsize = 19,",
- "}",
- "letters[5] = {",
- " path = \"e\",",
- " x = letters[4].x+letters[4].xsize+2,",
- " xsize = 22,",
- "}",
- "letters[6] = {",
- " path = \"c\",",
- " x = letters[5].x+letters[5].xsize+2,",
- " xsize = 22,",
- "}",
- "letters[7] = {",
- " path = \"t\",",
- " x = letters[6].x+letters[5].xsize-4,",
- " xsize = 28,",
- "}",
- "letters[8] = {",
- " path = \"BETA\",",
- " xsize = 170,",
- " y = 37,",
- "}",
- "letters[8].x = (sx/2)-(letters[8].xsize/2)",
- "local totalWidth = 0",
- "for a = 1, #letters do",
- " totalWidth = totalWidth + letters[a].xsize",
- " if a > 1 then",
- " totalWidth = totalWidth + letters[a].x-letters[a-1].x",
- " end",
- "end",
- "",
- "clearLines = function(start,stop)",
- " local cx,cy = term.getCursorPos()",
- " for y = start,stop do",
- " term.setCursorPos(1,y)",
- " term.clearLine()",
- " end",
- " term.setCursorPos(cx,cy)",
- "end",
- "p = {}",
- "l = {}",
- "for a = 1, #letters do",
- " p[a] = paintutils.loadImage(letters[a].path)",
- " l[a] = letters[a]",
- "end",
- "",
- "render = function(x,spacing)",
- " term.setBackgroundColor(colors.black)",
- " clearLines(1,35)",
- " for a = 1, #p do",
- " local drawX = (x+l[a].x)-(spacing*(a-(#letters/2)))",
- " if a == 8 then --draw \"</BETA>\"",
- " drawX = 1",
- " end",
- " paintutils.drawImage(p[a],drawX,l[a].y or 2)",
- " end",
- "end",
- "--render(1,1)",
- "",
- },
- [ "/BETA" ] = {
- " 11111111 111111 11111111111111111111 11111111111111111111111 11111111111111111111111 11111111 11111111 ",
- " 11111111 111111 111111111111111111111 11111111111111111111111 11111111111111111111111 1111111111 11111111 ",
- " 11111111 111111 1111111111111111111111 11111111111111111111111 11111111111111111111111 1111111111 11111111 ",
- " 11111111 111111 1111111111111111111111 11111111111111111111111 11111111111111111111111 111111111111 11111111 ",
- " 11111111 111111 111111 111111 11111 1 1 1111 1 111111111111 11111111 ",
- " 11111111 111111 111111 11111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 1111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 11111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 11111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111111111111111111 111111111111111111 1111 111111 111111 11111111 ",
- " 11111111 111111 11111111111111111111111 111111111111111111 1111 111111111111111111 11111111 ",
- " 11111111 111111 111111 1111111 111111111111111111 1111 11111111111111111111 11111111 ",
- "11111111 111111 111111 111111 11111 1111 11111111111111111111 11111111",
- " 11111111 111111 111111 11111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 1111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 1111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 1111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 1111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 11111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 111111 11111 1111 111111 111111 11111111 ",
- " 11111111 111111 111111 11111111 11111 1 1111 111111 111111 11111111 ",
- " 11111111 111111 111111111111111111111111 11111111111111111111111 1111 111111 111111 11111111 ",
- " 11111111 111111 11111111111111111111111 11111111111111111111111 1111 111111 111111 11111111 ",
- " 11111111 111111 1111111111111111111111 11111111111111111111111 1111 111111 111111 11111111 ",
- " 11111111 111111 11111111111111111111 11111111111111111111111 111111 11111111 11111111 11111111 ",
- "",
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement