diff --git a/dodge.lua b/dodge.lua new file mode 100644 index 0000000..93b1020 --- /dev/null +++ b/dodge.lua @@ -0,0 +1,213 @@ +--[[ + Wall Dodge! What a riveting game! + Dodge the walls before they kill you. + + Download with: + pastebin get fDTts7wz dodge + std PB fDTts7wz dodge + std ld dodge dodge +--]] + +local scr_x, scr_y = term.getSize() +local keysDown = {} --holds all pressed keys. It's way better than using "key" event for movement +local walls = {} --holds all screen data for walls. I could do slants if I wanted, not just walls +local frame = 0 --for every screen update-oh, you know what a frame is +local maxFrame = 26 --max frames until new wall +local fframe = 0 --not a typo. is the buffer of spaces until the spaces between walls shrinks +local maxFFrame = 6 --max fframes until the space between walls gets slightly tighter (down to 5, good luck m8) +local pause = false --pausing is a nice thing +local tsv = term.current().setVisible --it is my belief that monitors and normal computers do not have the setVisible method for term.current() +for a = 1, scr_x do + table.insert(walls,{top=1,bottom=scr_y,color=colors.black}) +end + +local score = 0 --increases for every wall. +local time = 0 --in seconds, increases in increments of 0.1 + +local addNewWall = function(top,bottom,color) + table.remove(walls,1) + table.insert(walls,{top=top,bottom=bottom,color=color}) +end + +local guyX = 2 +local guyY = math.floor(scr_y/2) + +local maxY = scr_y-1 +local minY = 2 + +local clearLines = function(y1,y2) + local _x,_y = term.getCursorPos() + for a = y1, y2 or y1 do + term.setCursorPos(1,a) + term.clearLine() + end + term.setCursorPos(_x,_y) +end + +local renderTEXT = function(_txt) + local txt = _txt or "YOU ARE DEAD" + local midY = math.floor(scr_y/2) + for a = 0, 2 do + term.setBackgroundColor(colors.gray) + clearLines(midY-a,midY+a) + sleep(0.1) + end + term.setCursorPos(4,midY) + term.write(txt) +end + +local trymove = function(dir) + if (guyY+dir)>=minY and (guyY+dir)<=maxY then + guyY = guyY + dir + return true + end + return false +end + +local render = function() + if tsv then tsv(false) end + term.setBackgroundColor(colors.white) + term.setTextColor(colors.white) + term.clear() + term.setCursorPos(guyX,guyY) + term.setBackgroundColor(colors.black) + term.write(" ") + term.setCursorPos(1,1) + term.clearLine() + term.setCursorPos(1,scr_y) + term.clearLine() + for x = 1, #walls do + term.setBackgroundColor(walls[x].color) + for y = 1, walls[x].top do + term.setCursorPos(x,y) + term.write(" ") + end + for y = walls[x].bottom, scr_y do + term.setCursorPos(x,y) + term.write(" ") + end + end + term.setCursorPos(2,1) + term.setBackgroundColor(colors.black) + term.write("SCORE: "..score.." | TIME: "..time) + if tsv then tsv(true) end +end + +local keepTime = function() + time = 0 + while true do + sleep(0.1) + if not pause then + time = time + 0.1 + end + end +end + +local doGame = function() + local wf = 0 + local gap = 2 + local ypos, randomcol + while true do + if not pause then + if frame >= maxFrame or wf > 0 then + if frame >= maxFrame then + frame = 0 + fframe = fframe + 1 + ypos = math.random(4,scr_y-3) + wf = 3 + randomcol = 2^math.random(1,14) + end + if wf > 0 then + wf = wf - 1 + end + if not term.isColor() then + randomcol = colors.black --Shame. + end + addNewWall(ypos-gap,ypos+gap,randomcol) + else + frame = frame + 1 + addNewWall(1,scr_y,colors.black) + end + if fframe >= maxFFrame then + fframe = 0 + if maxFrame > 7 then + maxFrame = maxFrame - 1 + end + end + if keysDown[keys.up] then + trymove(-1) + end + if keysDown[keys.down] then + trymove(1) + end + if walls[guyX-1].top > 1 or walls[guyX-1].bottom < scr_y then + if walls[guyX].top < walls[guyX-1].top or walls[guyX].bottom > walls[guyX-1].bottom then + score = score + 1 + end + end + render() + end + sleep(0) + if guyY<=walls[guyX].top or guyY>=walls[guyX].bottom then + return "dead" + end + end +end + +local getInput = function() + while true do + local evt = {os.pullEvent()} + if evt[1] == "key" then + if evt[2] == keys.q then + return "quit" + end + if evt[2] == keys.p then + pause = not pause + if pause then + local pauseMSGs = { + "PAUSED", + "Paused. Press 'P' to resume", + "The game is paused", + "GAME PAUSE !", + "What, gotta catch your breath??", + "Paused, the game is, hmmm?", + "PAUSED GAME", + "GAME PAUSED", + "THE GAME IS PAUSED", + "THE PAUSED IS GAME", + "Buh-buh-buh-BEEP", + "UNPAUSE WITH 'P'", + "Tip: press UP to go up", + "Tip: press DOWN to go down", + "Tip: read Narbonic comic, you tool", + "Tip: read Skin Horse comic, you twat", + "YOU HAVE NO CHANCE TO SURVIVE MAKE YOUR TIME", + "-PAUSED-", + "=PAUSED=", + "PAISED", + "THOUST GAME BE PAUSETH", + "Yon game is paused. Obvious exits are 'Q', 'CTRL+T'", + "Tip: don't hit the walls", + "Tip: press 'P' to pause the game", + } + renderTEXT(pauseMSGs[math.random(1,#pauseMSGs)]) + keysDown[keys.up] = false + keysDown[keys.down] = false + end + end + keysDown[evt[2]] = true + end + if evt[1] == "key_up" then + keysDown[evt[2]] = false + end + end +end + +local uut = parallel.waitForAny(getInput,doGame,keepTime) +if uut == 2 then + renderTEXT() +end +sleep(0.05) +term.setCursorPos(1,scr_y) +term.setBackgroundColor(colors.black) +term.clearLine() \ No newline at end of file diff --git a/drawtoy.lua b/drawtoy.lua new file mode 100644 index 0000000..dbb1166 --- /dev/null +++ b/drawtoy.lua @@ -0,0 +1,207 @@ +--[[ + pastebin get tfyqv2ww toy + std pb tfyqv2ww toy +--]] + +local channel = 180 +local modem +local scr_x, scr_y = term.getSize() +local valchar = "#" --character used for fading +local hedchar = "@" --character used for tip of line +local s = { --default color combinations + [1] = { --A classical black-and-white color fade, perfect for looking classy and pretentious. + colors.black, + colors.gray, + colors.lightGray, + colors.white, + }, + [2] = { --If you're feeling blue, then this randomly selected set of four colors should make you feel even worse! + colors.black, + colors.blue, + colors.cyan, + colors.lightBlue, + }, + [3] = { --This one's purple. Tha-that's it. Like purple? Good. + colors.black, + colors.red, + colors.magenta, + colors.pink, + }, + [4] = { --I'll admit, the creativity is lacking in this color. I mean, what was I thinking? + colors.black, + colors.gray, + colors.green, + colors.lime, + }, + [5] = { --NOBODY CALLS ME YELLOW + colors.black, + colors.brown, + colors.orange, + colors.yellow, + }, +} +local p = math.random(1,#s) +local g = function(num,sa) --This interprets the color palate and turns it into a fadey thing. + if not sa then sa = s[p] end + local values = { + [1] = {bg=sa[1], txt=sa[1], char=valchar}, + [2] = {bg=sa[1], txt=sa[2], char=valchar}, + [3] = {bg=sa[2], txt=sa[1], char=valchar}, + [4] = {bg=sa[2], txt=sa[2], char=valchar}, + [5] = {bg=sa[3], txt=sa[2], char=valchar}, + [6] = {bg=sa[3], txt=sa[3], char=valchar}, + [7] = {bg=sa[3], txt=sa[4], char=valchar}, + [8] = {bg=sa[4], txt=sa[3], char=valchar}, + [9] = {bg=sa[4], txt=sa[4], char=hedchar}, + } + if not num then return #values end + return values[num] +end +local size = g() +local grid = {} +local ah = {} +for b = 1, scr_x do + ah[b] = {v = 0, r = s[p]} +end +for b = 1, scr_y do + grid[b] = ah +end + +local between = function(num,min,max) + return (num > min and num or min) < max and num or max +end + +local getDotsInLine = function( startX, startY, endX, endY ) --graciously stolen from the paintutils, and PAIN + local out = {} + startX = math.floor(startX) + startY = math.floor(startY) + endX = math.floor(endX) + endY = math.floor(endY) + if startX == endX and startY == endY then + out = {{x=startX,y=startY}} + return out + end + local minX = math.min( startX, endX ) + if minX == startX then + minY = startY + maxX = endX + maxY = endY + else + minY = endY + maxX = startX + maxY = startY + end + local xDiff = maxX - minX + local yDiff = maxY - minY + if xDiff > math.abs(yDiff) then + local y = minY + local dy = yDiff / xDiff + for x=minX,maxX do + table.insert(out,{x=x,y=math.floor(y+0.5)}) + y = y + dy + end + else + local x = minX + local dx = xDiff / yDiff + if maxY >= minY then + for y=minY,maxY do + table.insert(out,{x=math.floor(x+0.5),y=y}) + x = x + dx + end + else + for y=minY,maxY,-1 do + table.insert(out,{x=math.floor(x+0.5),y=y}) + x = x - dx + end + end + end + return out +end +local getModemInput = function() + while true do + local _,side,freq,rfreq,msg,dist = os.pullEvent("modem_message") + if freq == channel then + if type(msg) == "table" then + if type(msg.x) == "number" and type(msg.y) == "number" and type(msg.r) == "table" then + if (msg.x >= 1 and msg.x <= scr_x) and (msg.y >= 1 and msg.y <= scr_y) and (#msg.r == 4) then + grid[msg.y][msg.x] = {v = size, r = msg.r} + end + end + end + end + end +end +local render = function(grid) + local q + for y = 1, #grid do + for x = 1, #grid[y] do + q = grid[y][x] + if q then + term.setCursorPos(x,y) + term.setTextColor(g( between( q.v+1, 1, size ), q.r ).txt ) + term.setBackgroundColor(g( between(q.v+1,1,size), q.r ).bg ) + term.write(g(between(q.v+1,1,size),q.r).char) + end + end + end +end +local downByOne = function(grid) + local output = {} + for y = 1, #grid do + output[y] = {} + for x = 1, #grid[y] do + output[y][x] = {} + if grid[y][x].v > 0 then + output[y][x].v = grid[y][x].v - 1 + else + output[y][x].v = 0 + end + output[y][x].r = grid[y][x].r + end + end + return output +end +local getInput = function() + local mx,my,oldx,oldy,dots + while true do + local evt = {os.pullEvent()} + modem = peripheral.find("modem") + if modem then modem.open(channel) end + if evt[1] == "key" then + if evt[2] == keys.q then + sleep(0) + return + end + elseif evt[1] == "mouse_click" or evt[1] == "mouse_drag" then + oldx,oldy = mx or evt[3],my or evt[4] + mx,my = evt[3],evt[4] + dots = getDotsInLine(oldx,oldy,mx,my) + for a = 1, #dots do + grid[dots[a].y][dots[a].x] = {v = size, r = s[p]} + if modem then + modem.transmit(channel,channel,{x=dots[a].x, y=dots[a].y, r=s[p]}) + end + end + elseif evt[1] == "mouse_up" then + mx,my = nil,nil + end + end +end +local dothRendering = function() + local t = false --term.current().setVisible + while true do + if t then t(false) end + render(grid) + if t then t(true) end + grid = downByOne(grid) + sleep(0) + end +end + +local funclist = { + getInput, + dothRendering, + getModemInput, +} + +parallel.waitForAny(unpack(funclist)) \ No newline at end of file diff --git a/progdor.lua b/progdor.lua new file mode 100644 index 0000000..ef4012a --- /dev/null +++ b/progdor.lua @@ -0,0 +1,448 @@ +--[[ + PROGDOR file bundling program + +Download with: + pastebin get YXx5jjMV progdor + std ld progdor progdor + +This is a stable release. You fool! +--]] + +local doCompress = false --even if this is false, it will decompress compressed files. nifty, huh? + +local doPastebin = false +local tArg = {...} +local input, outpath +if tArg[1] == "-p" then --the p is for pastebin + doPastebin = true + input = tArg[2] + outpath = tArg[3] +else + input = tArg[1] + outpath = tArg[2] +end + +local progdor = fs.getName(shell.getRunningProgram()) +local dir = shell.dir() +local displayHelp = function() + local txt = progdor.." [output]\nCompression is "..tostring(doCompress):upper().."." + return print(txt) +end + +local yield = function() + os.queueEvent("yield") + os.pullEvent("yield") +end + +-- CCA API START -- + +local bit = bit32 +local function pack(bn1, bn2) + return bit.band(bn1, 0xFF), bit.rshift(bn1, 8) + bit.lshift(bit.band(bn2, 0xF), 4), bit.rshift(bn2, 4) +end +local function upack(b1, b2, b3) + return (b1 + bit.lshift(bit.band(b2, 0xF), 8)), (bit.lshift(b3,4) + bit.band(bit.rshift(b2, 4), 0xF)) +end +local function createDict(bool) + local ret = {} + for i = 1, 255 do + if bool then + ret[string.char(i)] = i + else + ret[i] = string.char(i) + end + end + if not bool then ret[256] = 256 end + return ret +end +local function cp(sInput) + local dic = createDict(true) + local s = "" + local ch + local dlen = 256 + local result = {} + local temp + for i = 1, #sInput do + if dlen == 4095 then + result[#result + 1] = dic[s] + result[#result + 1] = 256 + dic = createDict(true) + dlen = 256 + s = "" + end + ch = sInput:sub(i, i) + temp = s..ch + if dic[temp] then + s = temp + else + result[#result + 1] = dic[s] + dlen = dlen +1 + dic[temp] = dlen + s = ch + end + end + result[#result + 1] = dic[s] + + return result +end +local function dc(data) + local dic = createDict(false) + local entry + local ch + local currCode + local result = {} + result[#result + 1] = dic[data[1]] + prefix = dic[data[1]] + for i = 2, #data do + currCode = data[i] + if currCode == 256 then + dic = createDict(false) + prefix = "" + else + entry = dic[currCode] + if entry then--exists in dictionary + ch = entry:sub(1, 1) + result[#result + 1] = entry + if prefix ~= "" then + dic[#dic+1] = prefix .. ch + end + else + ch = prefix:sub(1, 1) + result[#result + 1] = prefix..ch + dic[#dic + 1] = prefix..ch + end + + prefix = dic[currCode] + end + end + + return table.concat(result) +end +local function trim(inp) + for i = 0,2 do + if inp[#inp] == 0 then + inp[#inp] = nil + end + end +end +local function decompress(input) + local rec = {} + for i = 1, #input, 3 do + if i % 66 == 0 then + yield() + end + rec[#rec+1], rec[#rec+2] = upack(input[i], input[i+1] or 0, input[i+2] or 0) + end + trim(rec) + return dc(rec) +end +local function compress(input) + local rec = {} + local data = cp(input) + for i=1, #data, 2 do + yield() + rec[#rec+1], rec[#rec+2], rec[#rec+3] = pack(data[i], data[i+1] or 0) + end + trim(rec) + return rec +end + +-- CCA API END -- + +local fixstr = function(str) + return str:gsub("\\(%d%d%d)",string.char) +end + +local explode = function(div,str) + if (div=='') then return false end + local pos,arr = 0,{} + for st,sp in function() return string.find(str,div,pos,true) end do + table.insert(arr,str:sub(pos,st-1)) + pos = sp + 1 + end + table.insert(arr,str:sub(pos)) + return arr +end +local sanitize = function(sani,tize) + local _,x = string.find(sani,tize) + if x then + return sani:sub(x+1) + else + return sani + end +end +local tablize = function(input) + if type(input) == "string" then + return explode("\n",input) + elseif type(input) == "table" then + return table.concat(input,"\n") + end +end +local compyress = function(input) + return string.char(unpack(compress(input))) +end +local decompyress = function(input) + local out = {} + for a = 1, #input do + table.insert(out,string.byte(input:sub(a,a))) + end + return decompress(out) +end +local listAll +listAll = function(_path, _files, noredundant) + local path = _path or "" + local files = _files or {} + if #path > 1 then table.insert(files, path) end + for _, file in ipairs(fs.list(path)) do + local path = fs.combine(path, file) + if (file ~= thisProgram) then + local guud = true + if guud then + if fs.isDir(path) then + listAll(path, files, noredundant) + else + table.insert(files, path) + end + end + end + end + if noredundant then + for a = 1, #files do + if fs.isDir(tostring(files[a])) then + if #fs.list(tostring(files[a])) ~= 0 then + table.remove(files,a) + end + end + end + end + return files +end +if not (input) then + return displayHelp() +end +if not outpath then + outpath = input +end + +local choice = function(input,verbose) + if not input then + input = "yn" + end + if verbose then + write("[") + for a = 1, #input do + write(input:sub(a,a):upper()) + if a < #input then + write(",") + end + end + write("]?") + end + local evt,char + repeat + evt,char = os.pullEvent("char") + until string.find(input:lower(),char:lower()) + if verbose then + print(char:upper()) + end + local pos = string.find(input:lower(),char:lower()) + return pos, char:lower() +end + +local postToPastebin = function(name, contents) + local key = "0ec2eb25b6166c0c27a394ae118ad829" + local response = http.post( + "http://pastebin.com/api/api_post.php", + "api_option=paste&".. + "api_dev_key="..key.."&".. + "api_paste_format=lua&".. + "api_paste_name="..textutils.urlEncode(name).."&".. + "api_paste_code="..textutils.urlEncode(contents) + ) + if response then + local sResponse = response.readAll() + response.close() + local sCode = string.match( sResponse, "[^/]+$" ) + return sCode + else + return false + end + return +end + +function doPack(input,output,doCompress,verbose) --make sure that shell exists before using verbose mode + local tx = term.getTextColor() + if not doPastebin then + if not fs.exists(input) then return 3 end + if fs.isReadOnly(output) then return 5 end + end + local packageSelf = true + local packageReadOnly = true + local ro_asked = false + local ps_asked = false + if fs.isDir(input) then --if not a package + local out = {} + local list = listAll(input,nil,true) + if verbose then + for a = 1, #list do --this checks for self and read-only files + if fs.isReadOnly(list[a]) and (not ro_asked) then + write("Include read-only files? ") + if choice("yn",true) == 2 then + packageReadOnly = false + end + ro_asked = true + end + if fs.combine("",list[a]) == shell.getRunningProgram() and (not ps_asked) then + write("Include self? ") + if choice("yn",true) == 2 then + packageSelf = false + end + ps_asked = true + end + end + end + for a = 1, #list do --this loop kills fascists + local is_self = fs.combine("",list[a]) == fs.combine("",shell.getRunningProgram()) + if not ((is_self and not packageSelf) or (fs.isReadOnly(list[a]) and not packageReadOnly)) then + if verbose then + write("[") + if term.isColor() then term.setTextColor(colors.lightGray) end + write(sanitize(list[a],fs.combine(dir,input))) + term.setTextColor(tx) + write("]") + end + if fs.isDir(list[a]) then + out[sanitize(list[a],fs.combine(dir,input))] = true + else + local file = fs.open(list[a],"r") + local cont = file.readAll() + file.close() + if doCompress then + out[sanitize(list[a],fs.combine(dir,input))] = tablize(compyress(cont)) + else + out[sanitize(list[a],fs.combine(dir,input))] = tablize(cont) + end + end + local tx = term.getTextColor() + if fs.getName(list[a]):lower() == "peasant" then + if term.isColor() then + term.setTextColor(colors.orange) + end + print(" BURNINATED") + else + if term.isColor() then + term.setTextColor(colors.green) + end + print(" GOOD") + end + term.setTextColor(tx) + else + if fs.getName(list[a]):lower() == "peasant" then + print("Spared "..list[a]) + else + print("Skipped "..list[a]) + end + end + end + local fullOutput = tostring(doCompress).."\n"..fixstr(textutils.serialize(out)) + local sCode + if doPastebin then + print("Uploading...") + sCode = postToPastebin(input,fullOutput) + return 7, "Code = '"..sCode.."'" + else + if fs.isDir(output) then fs.delete(output) end + local file = fs.open(output,"w") + file.write(fullOutput) + file.close() + return 1 + end + else --if a package + local list, isCompy + if not doPastebin then + local file = fs.open(input,"r") + isCompy = file.readLine() + list = file.readAll() + file.close() + else + local file = http.get("http://pastebin.com/raw/"..tostring(input)) + if file then + isCompy = file.readLine() + list = file.readAll() + else + return 6 + end + end + local list = textutils.unserialize(list) + if type(list) ~= "table" then + return 4 + end + if fs.exists(output) then + fs.delete(output) + end + local amnt = 0 + for k,v in pairs(list) do + amnt = amnt + 1 + end + local num = 0 + for k,v in pairs(list) do + num = num + 1 + if v == true then + fs.makeDir(fs.combine(output,fs.combine(k,dir))) + else + local file = fs.open(fs.combine(output,fs.combine(k,dir)),"w") + if verbose then + write("[") + if term.isColor() then term.setTextColor(colors.lightGray) end + write(k) + term.setTextColor(tx) + write("]") + end + if isCompy:gsub(" ","") == "true" then + file.write(decompyress(tablize(v))) + else + file.write(tablize(v)) + end + file.close() + local tx = term.getTextColor() + if fs.getName(k):lower() == "peasant" then + if term.isColor() then + term.setTextColor(colors.orange) + end + print(" UNBURNINATED") + else + if term.isColor() then + term.setTextColor(colors.green) + end + print(" GOOD") + end + term.setTextColor(tx) + end + end + return 2 + end +end + +local success, res, otherRes = pcall( function() return doPack(input,outpath,doCompress,true) end ) --functionized it! + +if not success then + term.setTextColor(colors.white) + print("\n***Something went wrong!***") + return printError(res) +end + +if res then + local msgs = { + [1] = "Successfully packed '"..input.."/' as '"..outpath.."'", + [2] = "Successfully unpacked '"..input.."' to '"..outpath.."/'", + [3] = "That file/folder does not exist.", + [4] = "That file isn't a packed folder.", + [5] = "You don't have permission.", + [6] = "Failed to connect.", + [7] = "Uploaded successfully.", + } + print(msgs[res]) + if otherRes then + print(otherRes) + end +end \ No newline at end of file diff --git a/quickdraw.lua b/quickdraw.lua new file mode 100644 index 0000000..c994a9a --- /dev/null +++ b/quickdraw.lua @@ -0,0 +1,288 @@ +--[[ + QuickDraw! + Can you outshoot the cowbow? + I bet you can! It's actually really easy... + + pastebin get uGTzMxNL quickdraw + std pb uGTzMxNL quickdraw + std ld quickdraw +--]] + +local difficulty = 1.2 --amount of time you have to shoot im' + +local isRunning = true --whether the game should loop +local over = false --whether you or the guy is dead + +local wins = 0 +local losses = 0 + +local s = { + enemy = { + getready = {{},{},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,4096,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,128,4096,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,128,4096,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,128,4096,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,256,4096,128,4096,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},}, + shoot1 = {{},{},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,128,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,4096,128,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,256,0,4096,4096,128,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},}, + shoot2 = {{},{},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{0,0,0,0,0,0,0,0,0,0,0,0,256,4096,4096,128,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,4096,128,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},}, + laugh = {{},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,1,1,32768,1,1,32768,1,1,32768,32768,1,1,32768,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,0,0,0,1,1,1,1,32768,1,1,32768,1,32768,1,1,32768,1,32768,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,0,1,1,1,1,1,1,32768,32768,32768,32768,1,32768,32768,32768,32768,1,32768,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,0,0,0,1,1,1,1,32768,1,1,32768,1,32768,1,1,32768,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,0,0,0,0,0,1,1,32768,1,1,32768,1,32768,1,1,32768,1,32768,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,4096,128,4096,4096,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,4096,128,4096,0,4096,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,4096,128,4096,0,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,4096,128,4096,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},}, + dead = {{},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,1,1,1,32768,32768,1,1,32768,1,32768,1,32768,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,16,16,16,16,0,4096,0,1,1,1,1,32768,1,1,32768,1,32768,1,32768,1,32768,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,16,16,16,16,0,1,1,1,1,1,1,32768,32768,32768,32768,1,32768,32768,32768,1,32768,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,0,16,16,0,0,4096,0,1,1,1,1,32768,1,1,32768,1,32768,1,32768,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,4096,0,4096,4096,128,4096,0,4096,0,0,0,1,1,32768,1,1,32768,1,32768,1,32768,1,32768,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,4096,128,4096,4096,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,4096,4096,128,4096,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,2048,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,2048,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},{0,0,0,0,0,0,0,0,0,0,0,0,0,2048,0,0,2048,},}, + }, + bg = {{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,1,1,1,1,8,8,8,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,},{8,8,8,1,1,1,1,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,16,16,16,16,8,8,8,8,8,},{8,8,8,1,1,1,1,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,16,16,8,8,8,8,8,8,},{8,8,8,1,1,1,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,1,1,8,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,1,1,1,8,8,8,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,128,128,128,128,128,128,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,},{8,8,8,8,8,128,128,128,128,128,128,128,128,128,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,},{16,16,16,16,16,128,128,128,128,128,128,128,128,128,16,16,16,16,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,16,16,16,128,128,128,128,128,128,128,128,128,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,16,16,16,128,128,128,128,128,128,128,128,128,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,},{256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},}, +} +_s = s + +local scr_x, scr_y = term.getSize() + +local yield = function() + os.queueEvent("yield") + os.pullEvent("yield") +end + +local RPGslowprint = function(text,rate) + local cX,cY = term.getCursorPos() + yield() + local uutcome = parallel.waitForAny(function() + textutils.slowPrint(text,rate or 20) + end, function() + os.pullEvent("key") + end) + if uutcome == 2 then + term.setCursorPos(cX,cY) + print(text) + end +end + +local displayHelp = function(cli) + local helptext = [[ + QuickDraw by EldidiStroyrr + + HOW TO PLAY: + + 1) Click and hold on the green square for three seconds. + 2) As soon as it says DRAW, quickly move your mouse over the guy and let go. + 3) If you win, it'll get slightly harder + + Press 'Q' to quit ingame. +]] + if cli then + print(helptext) + else + term.setBackgroundColor(colors.gray) + term.setTextColor(colors.white) + term.setCursorPos(1,2) + term.clear() + RPGslowprint(helptext,30) + term.setCursorPos(2,scr_y-1) + term.write("Press any key to continue!") + yield() + os.pullEvent("key") + end +end + +function mixImages( img1, img2 ) + local output = { } + for a = 1, #img2 do + output[ a ] = { } + if not img1[ a ] then + for b = 1, #img2[ a ] do + output[ a ][ b ] = img2[ a ][ b ] + end + else + for b = 1, #img2[ a ] do + if img1[ a ][ b ] then + if img1[ a ][ b ] ~= 0 then + output[ a ][ b ] = img1[ a ][ b ] + else + output[ a ][ b ] = img2[ a ][ b ] + end + else + output[ a ][ b ] = img2[ a ][ b ] + end + end + end + end + return output +end + +local function clear() + local b,t = term.getBackgroundColor(), term.getTextColor() + term.setBackgroundColor(colors.black) + term.clear() + term.setBackgroundColor(b) +end + +local function cprint(txt) + local pX, pY = term.getCursorPos() + term.setCursorPos((scr_x/2)-math.floor(#txt/2),(scr_y/2)+4) + term.write(txt) + term.setCursorPos(pX,pY) +end + +local gameArea, alive + +local function handleShooting() + currentSprite = "getready" + sleep(difficulty/4) + paintutils.drawImage(mixImages(s.enemy.shoot1,s.bg),1,1) + currentSprite = "shoot1" + sleep(difficulty/4) + paintutils.drawImage(mixImages(s.enemy.shoot2,s.bg),1,1) + currentSprite = "shoot2" + sleep(difficulty/2) + os.queueEvent("thoseWhoDig",false) + return false, "dead" +end + +function drawHitBox(color) + paintutils.drawFilledBox(scr_x-3,scr_y-2,scr_x,scr_y,color) + term.setBackgroundColor(colors.lightBlue) + term.setTextColor(colors.white) + local txt = "YOU: "..wins.." / ENEMY: "..losses + term.setCursorPos(scr_x-(#txt+1)+1,1) + term.write(txt) + term.setBackgroundColor(colors.lightGray) + term.setTextColor(colors.gray) + local txt = "TIME: "..tostring(difficulty):sub(1,5).." SEC" + term.setCursorPos(2,scr_y-1) + term.write(txt) +end + +function exitGame() + if not isRunning then + term.setCursorPos(1,scr_y) + term.setBackgroundColor(colors.black) + term.write(string.rep(" ",scr_x-4)) + term.setCursorPos(1,scr_y) + sleep(0) + end + error() +end + +currentSprite = "getready" + +local function countdown() + term.setCursorPos((scr_x/2)-2,scr_y/2) + term.setTextColor(colors.black) + term.setBackgroundColor(colors.lightBlue) + cprint("3...") + sleep(0.8) + cprint("2...") + sleep(0.8) + cprint("1...") + sleep(0.8) + cprint("DRAW!") +end + +function getInput() + alive = true + os.pullEvent("getMeSomeInput") + while true do + local evt + if gameArea == "beginning1" then + evt = {os.pullEvent()} + if evt[1] == "mouse_click" then + if evt[3] >= scr_x-3 and evt[4] >= scr_y-2 then + local res = parallel.waitForAny(function() + while true do + local evt = {os.pullEvent()} + if evt[1] == "mouse_up" or evt[1] == "mouse_click" then + break + elseif evt[1] == "mouse_drag" then + if (evt[3] < scr_x-3) or (evt[4] < scr_y-2) then + break + end + end + end + end, countdown) + if (res == 1) and not over then + cprint("FOUL!!") + exitGame() + end + os.queueEvent("imready") + parallel.waitForAny(function() + while alive do + evt = {os.pullEvent()} + if evt[1] == "mouse_up" then + local x,y = evt[3],evt[4] + if _s.enemy[currentSprite][y] then + if _s.enemy[currentSprite][y][x] then + if _s.enemy[currentSprite][y][x] ~= 0 then + os.queueEvent("thoseWhoDig",true,x,y) + break + end + end + end + sleep(0.2) + elseif evt[1] == "mouse_click" then --yay for anticheating + sleep(1) + end + end + end, handleShooting) + end + elseif evt[1] == "key" then + if evt[2] == keys.q then + isRunning = false + exitGame() + end + end + end + end +end + +local flash = { + colors.white, + colors.lightGray, + colors.black, + colors.gray, +} + +local tArg = {...} +if tArg[1] == "help" then + return displayHelp(true) +end + +function game() + over = false + term.setTextColor(colors.white) + while true do + gameArea = "beginning1" + paintutils.drawImage(mixImages(s.enemy.getready,s.bg),1,1) + drawHitBox(colors.green) + currentSprite = "getready" + os.queueEvent("getMeSomeInput") + os.pullEvent("imready") + os.queueEvent("shootStart!") + local _,alive,x,y = os.pullEvent("thoseWhoDig") + over = true + if not alive then + for a = 1, #flash do + term.setBackgroundColor(flash[a]) + term.clear() + sleep(0.1) + end + losses = losses + 1 + paintutils.drawImage(mixImages(s.enemy.laugh,s.bg),1,1) + term.setTextColor(colors.red) + term.setBackgroundColor(colors.lightBlue) + sleep(0.5) + exitGame() + else + paintutils.drawImage(mixImages(s.enemy.dead,s.bg),1,1) + paintutils.drawPixel(x,y,colors.red) + sleep(0.2) + term.setBackgroundColor(colors.lightBlue) + term.setTextColor(colors.black) + cprint("YOU WIN!") + wins = wins + 1 + sleep(0.8) + difficulty = difficulty * 0.92 + exitGame() + end + end +end + +clear() +displayHelp(false) +while isRunning do + parallel.waitForAny(getInput,game) + if isRunning then + sleep(0.8) + end +end \ No newline at end of file diff --git a/sdodge.lua b/sdodge.lua new file mode 100644 index 0000000..beb781e --- /dev/null +++ b/sdodge.lua @@ -0,0 +1,214 @@ +--[[ +SUPER Dodge!! +A remake of that last game I made. Mostly an experiment with cool background. +Get with + pastebin get 5BUnGkUJ dodge2 +And soon + std ld dodge2 dodge2 + +This game isn't finished, but it is certainly playable. + +...you fool! +--]] +local scr_x, scr_y = term.getSize() +local sprite = {} +sprite.dw = {{128,128,128,128,128,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,128,256,256,128,128,},{0,16384,16384,16384,16384,0,},{16384,2,2,2,2,16384,},{16384,2,2,16,16,16384,},{16384,16,16,16,2,16384,},{0,16384,16384,16384,16384,0,},} +sprite.uw = {{0,16384,16384,16384,16384,0,},{16384,16,16,2,2,16384,},{16384,16,2,2,2,16384,},{16384,2,2,16,16,16384,},{0,16384,16384,16384,16384,0,},{128,128,256,256,128,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,256,256,256,256,128,},{128,128,128,128,128,128,},} +sprite.guy = {{2,0,8192,32,32,0},{16384,8192,8192,32,2048,32},{2,0,8192,32,32,0}} +sprite.guybig = {{},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32768,32768,32,32,32,32,32,32,32,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32768,8,8,32768,32,32,32,32,32,32,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,8,8,8,8,32768,32,32,32,32,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32768,8,8,8,32768,32,32,32,32,32,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,32,32,32,32,32,32,32,32,32,32,32,32,32768,32768,32768,32,32,32,32,32,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,8192,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,8192,8192,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,8192,8192,8192,8192,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,8192,8192,8192,8192,8192,8192,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,32,32,32,32,32,32,32,0,0,0,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,256,256,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,0,0,0,0,0,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,256,256,256,256,256,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,2,2048,256,256,256,256,8192,8192,8192,8192,8192,8192,8192,8192,8192,8192,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,0,2,2,2,2,2,2,2048,2048,2048,256,256,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,2,2,2,2,2,2,16,16,16,16,16,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,2,2,2,2,2,2,16,16,16,16,16,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,0,2,2,2,2,16,16,16,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,2,0,0,0,2,2,2,2,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,0,0,0,0,0,2,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}} +sprite.title = {{1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,},{1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,},{1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,},{1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,},{0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,},{0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,},{1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,},{1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,},{},{8,8,8,8,8,0,0,0,0,8,8,8,8,8,0,0,8,8,8,8,8,0,0,0,0,8,8,8,8,0,0,8,8,8,8,8,8,},{8,8,8,8,8,8,0,0,8,8,8,8,8,8,8,0,8,8,8,8,8,8,0,0,8,8,8,8,8,8,0,8,8,8,8,8,8,},{8,8,0,0,8,8,8,0,8,8,0,0,0,8,8,0,8,8,0,0,8,8,8,0,8,8,0,0,8,8,0,8,8,0,0,0,0,},{8,8,0,0,0,8,8,0,8,8,0,0,0,8,8,0,8,8,0,0,0,8,8,0,8,8,0,0,0,0,0,8,8,8,8,8,0,},{8,8,0,0,0,8,8,0,8,8,0,0,0,8,8,0,8,8,0,0,0,8,8,0,8,8,0,8,8,8,0,8,8,0,0,0,0,},{8,8,0,0,8,8,8,0,8,8,0,0,0,8,8,0,8,8,0,0,8,8,8,0,8,8,0,0,8,8,0,8,8,0,0,0,0,},{8,8,8,8,8,8,0,0,8,8,8,8,8,8,8,0,8,8,8,8,8,8,0,0,8,8,8,8,8,8,0,8,8,8,8,8,8,},{8,8,8,8,8,0,0,0,0,8,8,8,8,8,0,0,8,8,8,8,8,0,0,0,0,8,8,8,8,0,0,8,8,8,8,8,8,}} +sprite.bg = {{32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},{32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},{4096,32768,32768,32768,32768,32768,32768,32768,32768,4096,4096,4096,4096,4096,4096,4096,4096,4096},{4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,0,0,0,0,0,0,0,0},{},{},{},{},{},{},{},{},{},{},{},{4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,0,0,0,0,0,0,0,0},{4096,32768,32768,32768,32768,32768,32768,32768,32768,4096,4096,4096,4096,4096,4096,4096,4096,4096},{32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},{32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768}} + +local gm = { + x = 2, + y = math.floor(scr_y/2), + score = 0, + hiscore = 0, + deaths = 0, +} +local walls = {} + +local keysDown = {} + +local inc = function(a) + local x,y = term.getCursorPos() + term.setCursorPos(x,y+a) +end + +local addWall = function() + table.insert(walls,{x=scr_x,y=math.random(4,scr_y-4)}) +end + +local moveWalls +moveWalls = function() + for k,v in pairs(walls) do + if walls[k] then + walls[k].x = walls[k].x - 1 + if walls[k].x <= -5 then + walls[k] = nil + moveWalls() + break + end + end + end +end + +local renderBG = function(scroll,bgscroll) + local ivl = 5 --interval + local skew = 2 + term.setBackgroundColor(colors.black) + term.clear() + local pos = (ivl - scroll) + 1 + while pos <= scr_x do + local endpos = ((pos-(scr_x/2))*(skew))+(scr_x/2) + local midpos = ((pos-(scr_x/2))*(skew*0.8))+(scr_x/2) -- skew*0.75 is perfect lines + paintutils.drawLine(endpos, scr_y, midpos, scr_y*0.75, colors.cyan) --render bottom + paintutils.drawLine(midpos, scr_y*0.75, pos , scr_y*0.5, colors.lightBlue) --render bottom + paintutils.drawLine(endpos, 1, midpos, scr_y*0.25, colors.cyan) --render top + paintutils.drawLine(midpos, scr_y*0.25, pos, scr_y*0.5, colors.lightBlue) --render top + pos = pos + ivl + end + for x = 1-bgscroll, scr_x, 18 do + paintutils.drawImage(sprite.bg,x,1) + end +end +local gap = 6 +local t = term.current().setVisible + +local checkCollision = function() + for k,v in pairs(walls) do + if gm.x >= v.x-3 and gm.x <= v.x+3 then --intentionally allowed front and back to touch wall + if math.abs((gm.y+1) - v.y) >= (gap/2)-1 then + return false + end + end + end + return true +end + +local render = function(scroll,bgscroll) + if t then t(false) end + renderBG(scroll,bgscroll) + paintutils.drawImage(sprite.guy,gm.x,gm.y) + + for k,v in pairs(walls) do + paintutils.drawImage(sprite.uw,v.x,v.y+(gap/2)) + paintutils.drawImage(sprite.dw,v.x,(v.y-(gap/2))-scr_y) + end + + term.setCursorPos(2,1) + term.setBackgroundColor(colors.black) + term.clearLine() + write("SCORE: "..gm.score.." ") + if t then t(true) end +end + +local game = function() + local scroll = 1 + local frame = 0 + local maxframe = 32 + local bgscroll = 0 + while true do + render(math.floor(scroll),math.floor(bgscroll)) + scroll = scroll + 0.5 + frame = frame + 1 + bgscroll = bgscroll + 2 + if scroll % 5 == 0 then + scroll = 0 + end + if frame == maxframe then + addWall() + frame = 1 + end + if bgscroll % 18 == 0 then + bgscroll = 0 + end + moveWalls() + + if keysDown[keys.up] and gm.y > 2 then + gm.y = gm.y - 1 + end + if keysDown[keys.down] and gm.y < scr_y-3 then + gm.y = gm.y + 1 + end + local isHit = not checkCollision() + if isHit then + return + end + gm.score = gm.score + 1 + if gm.hiscore < gm.score then --conglaturations + gm.hiscore = gm.score + end + sleep(0) + end +end + +local getInput = function() + while true do + local evt, key = os.pullEvent() + if evt == "key" then + keysDown[key] = true + elseif evt == "key_up" then + keysDown[key] = false + end + if key == keys.q then + return + end + end +end + +local cleanExit = function() + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + term.clear() + term.setCursorPos(1,1) + print("Thanks for playing!") + if t then t(true) end + sleep(0.05) +end + +local showTitle = function() + if gm.deaths == 0 then + local x = -38 + local y = scr_y + repeat + y = y - 1 + x = x + 2 + if t then t(false) end + term.setBackgroundColor(colors.black) + term.clear() + paintutils.drawImage(sprite.guybig,math.floor(x),math.floor(y)) + if t then t(true) end + sleep(0) + until y <= -24 + end + term.setBackgroundColor(colors.white) + term.clear() + sleep(0) + term.setBackgroundColor(colors.black) + term.clear() + paintutils.drawImage(sprite.title,3,2) + sleep(0.1) + term.setCursorPos(4,scr_y) + term.setTextColor(colors.white) + term.setBackgroundColor(colors.black) + term.write("PUSH ANY KEY TO NEXT") + term.setCursorPos(2,1) + write("TOP: "..gm.hiscore.." | LAST: "..gm.score) + os.pullEvent("char") +end + +while true do + showTitle() + walls = {} + gm.y = math.floor(scr_y/2) + gm.score = 0 + keysDown = {} + local res = parallel.waitForAny(getInput,game) + if res == 2 then + gm.deaths = gm.deaths + 1 + else + cleanExit() + break + end +end \ No newline at end of file diff --git a/sinelock.lua b/sinelock.lua new file mode 100644 index 0000000..dc9005d --- /dev/null +++ b/sinelock.lua @@ -0,0 +1,1042 @@ +--[[ + Sinelock v1.3 + The *COOLEST* computer/door lock ever! + Now with slightly less seizure! + + pastebin get XDgeSDTq sinelock + std pb XDgeSDTq sinelock + std ld sinelock sinelock + + Now with salting! +--]] +local scr_x, scr_y = term.getSize() --Gets screen size. Don't modify this + +--Config variables start! +local terminateMode = 2 --0 enables termination, 1 blocks it, 2 provides a taunting screen. +local passFile = ".sl_password" --The ABSOLUTE path of the password file. +local saltFile = ".sl_salt" --The ABSOLUTE path of the salt file. +local characterLimit = 1024 --The cap of characters at the read() prompt. Set this to prevent crashes. +local runProgram = "" --Set to something to run it when correct, and not using doors. +local dahChar = "*" --The character used to hide characters when typed. +local doKeyCards = true --Whether or not the lock also accepts keycards (floppy disks) as well as passwords. +local doEjectDisk = false --Whether or not to eject a keycard after it's accepted, just to speed things up a bit. +local doorSides = {} --If it has anything, the lock will open the doors instead of unlocking the PC. +local doInvertSignal = false --If true, it will invert the redstone signal of the door, in case you need to. +local doShowDoorSides = true --If true, will show the door sides being opened. Set to false if you are paranoid. +local beWavey = true --Whether or not to animate the sine wave. +local readYpos = scr_y-2 --The Y position of the read() prompt +local requireAllPasswords = false --Whether or not the lock asks for ONE of the multiple passwords, or ALL of them in order. +local badlength = 4 --The length in seconds that you have to wait to try again. +local goodlength = 6 --The length in seconds that doors will stay open. +local sineFrameDelay = 0.15 --The amount of time between sine animation frames. Tradeoff of purty vs performance. +local palate = { + frontsine = colors.lightGray, + backsine = colors.gray, + background = colors.black, + rainColor = colors.gray, + rainChar = "|", + promptBG = colors.gray, + promptTXT = colors.white, + wrongBG = colors.black, + wrongTXT = colors.gray, +} +local language = "english" +local lang = { + english = { + wrong1 = "YOU ARE WRONG.", + wrong2 = "YOU ARE WRONG. AS ALWAYS.", + right1 = "Correct!", + right2 = "Correct, finally!", + }, + spanish = { + wrong1 = "ESTA USTED EQUIVOCADO.", + wrong2 = "ESTA USTED EQUIVOCADO. TODAVIA OTRA VEZ.", + right1 = "Correcto!", + right2 = "Asi es, por fin!", + noTerminate = "No termine!", + }, + german = { + wrong1 = "SIE LIEGEN FALSCH.", + wrong2 = "SIE LIEGEN FALSCH. WIE IMMER.", + right1 = "Richtig!", + right2 = "Richtig, endlich!", + noTerminate = "Nicht zu beenden!", + }, + dutch = { + wrong1 = "U BENT ONJUIST.", + wrong2 = "JE BENT ONJUIST, ALS ALTIJD.", + right1 = "Dat is juist!", + right2 = "Dat is juist, eindelijk!", + noTerminate = "Niet te beeindigen!", + }, + latin = { --As a joke + wrong1 = "ERRAS", + wrong2 = "TU DEFICIENTES!", + right1 = "Quod suus 'verum!", + right2 = "Quod suus 'verum, demum!", + noTerminate = "Vade futuo te ipsum!", + }, + italian = { + wrong1 = "HAI SBAGLIATO.", + wrong2 = "HAI SBAGLIATO, COME SEMPRE D'ALTRONDE.", + right1 = "CORRETTO!", + right2 = "CORRETTO, FINALMENTE!", + noTerminate = "Non cercare di terminarmi", + }, +} + +-- Config variables end. Don't touch anything else, m'kay? +if not _VERSION then + return printError("Sorry, only CC 1.7 and later supported.") +end +local csv, salt, doSine +local floor, ceil, random, abs = math.floor, math.ceil, math.random, math.abs +local sin, cos = math.sin, math.cos +local rhite = term.write +local setTextColor, setBackgroundColor, getTextColor, getBackgroundColor = term.setTextColor, term.setBackgroundColor, term.getTextColor, term.getBackgroundColor +local setCursorPos, setCursorBlink, getCursorPos, getSize = term.setCursorPos, term.setCursorBlink, term.getCursorPos, term.getSize +local sineLevel = 1 +local isTerminable = false +local kaykaycoolcool = true +if term.current().setVisible then + csv = true +else + csv = false +end + +local writeError = function(...) + local tx,bg = getTextColor(),getBackgroundColor() + if term.isColor() then + setTextColor(colors.red) + else + setTextColor(colors.white) + end + rhite(table.concat(arg," ")) + setTextColor(tx) + setBackgroundColor(bg) +end + +local goodPullEvent +if terminateMode == 1 then + if os.pullEvent ~= os.pullEventRaw then + goodPullEvent = os.pullEvent + end + os.pullEvent = os.pullEventRaw +end + +local keepLooping = true + +---- SHA256 START ---- +--SHA256 implementation done by GravityScore. + +local MOD = 2^32 +local MODM = MOD-1 + +local function memoize(f) + local mt = {} + local t = setmetatable({}, mt) + function mt:__index(k) + local v = f(k) + t[k] = v + return v + end + return t +end + +local function make_bitop_uncached(t, m) + local function bitop(a, b) + local res,p = 0,1 + while a ~= 0 and b ~= 0 do + local am, bm = a % m, b % m + res = res + t[am][bm] * p + a = (a - am) / m + b = (b - bm) / m + p = p*m + end + res = res + (a + b) * p + return res + end + return bitop +end + +local function make_bitop(t) + local op1 = make_bitop_uncached(t,2^1) + local op2 = memoize(function(a) return memoize(function(b) return op1(a, b) end) end) + return make_bitop_uncached(op2, 2 ^ (t.n or 1)) +end + +local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4}) + +local function bxor(a, b, c, ...) + local z = nil + if b then + a = a % MOD + b = b % MOD + z = bxor1(a, b) + if c then z = bxor(z, c, ...) end + return z + elseif a then return a % MOD + else return 0 end +end + +local function band(a, b, c, ...) + local z + if b then + a = a % MOD + b = b % MOD + z = ((a + b) - bxor1(a,b)) / 2 + if c then z = bit32_band(z, c, ...) end + return z + elseif a then return a % MOD + else return MODM end +end + +local function bnot(x) return (-1 - x) % MOD end + +local function rshift1(a, disp) + if disp < 0 then return lshift(a,-disp) end + return floor(a % 2 ^ 32 / 2 ^ disp) +end + +local function rshift(x, disp) + if disp > 31 or disp < -31 then return 0 end + return rshift1(x % MOD, disp) +end + +local function lshift(a, disp) + if disp < 0 then return rshift(a,-disp) end + return (a * 2 ^ disp) % 2 ^ 32 +end + +local function rrotate(x, disp) + x = x % MOD + disp = disp % 32 + local low = band(x, 2 ^ disp - 1) + return rshift(x, disp) + lshift(low, 32 - disp) +end + +local k = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, +} + +local function str2hexa(s) + return (string.gsub(s, ".", function(c) return string.format("%02x", string.byte(c)) end)) +end + +local function num2s(l, n) + local s = "" + for i = 1, n do + local rem = l % 256 + s = string.char(rem) .. s + l = (l - rem) / 256 + end + return s +end + +local function s232num(s, i) + local n = 0 + for i = i, i + 3 do n = n*256 + string.byte(s, i) end + return n +end + +local function preproc(msg, len) + local extra = 64 - ((len + 9) % 64) + len = num2s(8 * len, 8) + msg = msg .. "\128" .. string.rep("\0", extra) .. len + assert(#msg % 64 == 0) + return msg +end + +local function initH256(H) + H[1] = 0x6a09e667 + H[2] = 0xbb67ae85 + H[3] = 0x3c6ef372 + H[4] = 0xa54ff53a + H[5] = 0x510e527f + H[6] = 0x9b05688c + H[7] = 0x1f83d9ab + H[8] = 0x5be0cd19 + return H +end + +local function digestblock(msg, i, H) + local w = {} + for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end + for j = 17, 64 do + local v = w[j - 15] + local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3)) + v = w[j - 2] + w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10)) + end + + local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8] + for i = 1, 64 do + local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22)) + local maj = bxor(band(a, b), band(a, c), band(b, c)) + local t2 = s0 + maj + local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25)) + local ch = bxor (band(e, f), band(bnot(e), g)) + local t1 = h + s1 + ch + k[i] + w[i] + h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2 + end + + H[1] = band(H[1] + a) + H[2] = band(H[2] + b) + H[3] = band(H[3] + c) + H[4] = band(H[4] + d) + H[5] = band(H[5] + e) + H[6] = band(H[6] + f) + H[7] = band(H[7] + g) + H[8] = band(H[8] + h) +end + +local function sha256(...) + local msg = table.concat(arg,",") + msg = preproc(msg, #msg) + local H = initH256({}) + for i = 1, #msg, 64 do digestblock(msg, i, H) end + return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) .. + num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4)) +end + +---- SHA256 END ---- + +local terminates = 0 +local sillyTerminate = function() + local goodpull = _G.os.pullEvent + os.pullEvent = os.pullEventRaw + terminates = terminates + 1 + local script = { + "You shall not pass!", + "THOU shalt not pass!", + "Stop trying to pass!", + "...maybe I'm not clear.", + "YOU. SHALL NOT. PASS!!", + "Pass thou shalt not!", + "Hey, piss off, will ya?", + "I haven't got all day.", + "...no, shut up. I don't.", + "I won't tell you it!", + "No password for you.", + "It's been hashed!", + "Hashed...with a salt!", + "I'll never tell you the salt.", + "You know why?", + "Because that requires passing!", + "WHICH THOU SHALT NOT DO!", + "(oh btw don't pass k?)", + "You! Don't pass!", + "That means YOU!", + "Cut it out!", + "Re: Cut it out!", + "Perhaps if you keep it up...", + "..hmm...", + "..oh I give up.", + "", + "What? Is this what you wanted?", + "Huh? No? I-it's not?", + "Well then...!", + "", + "YEAH I SAID IT", + "You think you're a terminating machine!", + "You think you're above consequence!", + "...w-...", + "eat my shorts", + "Your attempts are futile anyhow.", + "Here I am getting drunk off your sweat,", + "...while you push CTRL and T.", + "Or maybe you're pressing that [T] button.", + "Like, um, in CCEmuRedux.", + "But it matters not!", + "For you see, my defences are great!", + "Nothing can bust my rock-hard abs!", + "", + "Oh bualls.", + "That was embarrasing.", + "...?", + "What're YOU lookin' at??", + "You callin' me UNSTABLE!?", + "HUH!??", + "...", + "...w-well at least I admit it", + "...b-bakka", + ".......", + "Hey, have you ever played EarthBound?", + "(Yes. I'm gonna rant.)", + "It's an RPG on the Super Nintendo.", + "Like, instead of fighting fantasy demons,", + "you fight stop signs and cars and shit", + "And, like, you hit rabid dogs with a bat", + "And you have magical PSI spells", + "...speaking of PSI, I happen to use it a lot.", + "...er, *I* as in the coder of this lock...", + "And by PSI, I mean the mod.", + "You don't see too many psychic locks these days.", + "A shame, really.", + "I bet a PSI lock could act as a heater with PSI Fire.", + "Or maybe it can kill rats with PSI Ground or Thunder", + "Maybe, you can get a psychic KEY lock, so, like,", + "you could put it on that Psychonauts head door thing.", + "...WHAT!? just a suggestion.", + "Psychonauts is another game I reccommend.", + "It has some really clever dialogue.", + "I'm sure you'd like it quite a lot.", + "I know, because you've been here for ten fucking minutes.", + "And you're not ONE STEP closer to getting the password", + "Which I've been guarding very, very closely.", + "Yes. Extremely closely.", + "Excrutiatingly, some would say.", + "You know, I should probably get to shouting.", + "*ahem*", + "...", + "*aahhhechhemmemmhmm*", + "*aachkskacehchachkhackcoughfartfuckdammitaaucahkh*", + "...", + "STAHP IT", + "STAHP TEHRMINATIN", + "do it for the CHILDREN", + "okay fuck the children, who needs 'em", + "then", + "um", + "THINK OF THE...THE...", + "the babies...?", + "um", + "", + "That's a fucking horrible idea.", + "I'd rather eat my own brain then think about that.", + "I'd sooner kiss a pig!", + "I'd sooner swallow an avocado pit!", + "...", + "You know, you suck so much.", + "You suck so much, and I'm sick of writing this script", + "If my knuckles bleed, you're paying my insurance", + "In order to save time, money, and my joints,", + "I believe it would be in order to...", + "...to say,", + "NO TERMINATING.", + } + setCursorBlink(false) + local mess + if terminates > #script then + mess = script[#script] + else + mess = script[terminates] + end + if mess == "" then + setBackgroundColor(colors.black) + if term.isColor() then + setTextColor(colors.yellow) + else + setTextColor(colors.white) + end + term.clear() + setCursorPos(1,1) + print(os.version()) + write("> ") + setTextColor(colors.white) + read() + printError("shell:350: Unable to pass") + sleep(2) + elseif mess == "" then + setBackgroundColor(colors.black) + if term.isColor() then + setTextColor(colors.red) + else + setTextColor(colors.white) + end + term.clear() + setCursorPos(1,scr_y/2) + local toobad = " T"..("O"):rep(scr_x-8).." BAD!" + for a = 1, #toobad do + for y = 1, scr_y do + setCursorPos(a,y) + rhite(toobad:sub(a,a)) + end + sleep(0) + end + sleep(1.5) + for a = 1, 16 do + if a%3 == 0 then + setBackgroundColor(colors.white) + elseif a%3 == 1 then + setBackgroundColor(colors.black) + else + if term.isColor() then + setBackgroundColor(colors.red) + else + setBackgroundColor(colors.gray) + end + end + term.clear() + sleep(0) + end + elseif mess == "" then + writeError("Terminated") + setBackgroundColor(colors.black) + setTextColor(colors.white) + term.blit(">","4","f") + read() + sleep(0.75) + for a = 1, 2 do + sleep(0.05) + term.scroll(1) + end + for a = 1, scr_y do + sleep(0.05) + term.scroll(-1) + end + sleep(0.25) + setBackgroundColor(colors.gray) + term.clear() + sleep(0.1) + setBackgroundColor(colors.lightGray) + term.clear() + sleep(0.1) + setBackgroundColor(colors.white) + term.clear() + sleep(0.25) + local msg = "taht didn't happan" + term.setCursorPos(scr_x-#msg,scr_y) + setTextColor(colors.black) + rhite(msg) + sleep(1) + elseif mess == "" then + setBackgroundColor(colors.white) + setTextColor(colors.black) + term.clear() + setCursorPos(2,3) + print("Since you're such a smart bastard, why don't you come up with something objectionable to think about?\n") + setBackgroundColor(colors.gray) + setTextColor(colors.white) + term.clearLine() + local yourFuckingShittyAssResponceThatSucksSoMuchBallsThatIWouldRatherListenToThatFuckingOwlFromOcarinaOfTimeBlatherAboutHisFuckingDayThanSitWithYouForAnotherGoddamnedSecondReeeeee = read() + setBackgroundColor(colors.white) + setTextColor(colors.black) + for a = 1, 5 do + sleep(0.6) + write(".") + end + sleep(1) + term.setTextColor(colors.red) + for a = 1, 20 do + sleep(0.05) + write(".") + end + sleep(0.5) + else + setBackgroundColor(colors.gray) + setTextColor(colors.white) + setCursorPos(math.max(1,(scr_x/2)-(#mess/2)),scr_y/2) + if language == "english" then + write(mess) + else + write(lang[language].noTerminate) + end + sleep(1.5) + end + os.pullEvent = goodpull + return terminates +end + +local shuffle = function(txt) + local output = "" + for a = 1, #txt do + if a % 2 == 0 then + output = output..txt:sub(a,a) + else + output = txt:sub(a,a)..output + end + end + return output +end + +local goodpass = function(pswd,count) + isTerminable = true + doSine = false + setCursorBlink(false) + local flashes = { + colors.white, + colors.lightGray, + colors.gray, + } + if type(pswd) == "table" then + pswd = pswd[1] + end + setTextColor(colors.black) + local correctmsg + if count < 10 then + correctmsg = lang[language].right1 + else + correctmsg = lang[language].right2 + end + for a = 1, #flashes do + setBackgroundColor(flashes[#flashes-(a-1)]) + term.clear() + setCursorPos((scr_x/2)-(#correctmsg/2),scr_y/2) + rhite(correctmsg) + sleep(0) + end + if #doorSides == 0 then + sleep(0.4) + keepLooping = false + else + local doormsg + if doShowDoorSides then + doormsg = "Applying RS to "..table.concat(doorSides,", ").."." + else + doormsg = "Applying redstone." + end + setCursorPos((scr_x/2)-(#doormsg/2),(scr_y/2)+2) + rhite(doormsg) + for a = 1, #doorSides do + redstone.setOutput(doorSides[a],not doInvertSignal) + end + if terminateMode == 1 then + os.pullEvent = goodPullEvent + end + sleep(goodlength) + if terminateMode == 1 then + os.pullEvent = os.pullEventRaw + end + for a = 1, #doorSides do + redstone.setOutput(doorSides[a],doInvertSignal) + end + end + for a = 1, #flashes do + setBackgroundColor(flashes[a]) + term.clear() + setCursorPos((scr_x/2)-(#correctmsg/2),scr_y/2) + rhite(correctmsg) + sleep(0) + end + setBackgroundColor(colors.black) + term.clear() + setCursorPos(1,1) + if terminateMode == 1 and goodPullEvent and (#doorSides == 0) then + os.pullEvent = goodPullEvent + end + setCursorBlink(true) + isTerminable = false + return true +end + +local badpass = function(pswd,count) + doSine = false + local getevent = os.pullEvent + os.pullEvent = os.pullEventRaw + setCursorBlink(false) + setBackgroundColor(palate.wrongBG) + setTextColor(palate.wrongTXT) + term.clear() + if type(pswd) == "table" then + pswd = pswd[1] + end + local badmsg + if count < 10 then + if pswd == sha256("bepis",salt) then + badmsg = "Bepis." + else + badmsg = lang[language].wrong1 + end + else + if pswd == sha256("bepis",salt) then + badmsg = "BEPIS!" + else + badmsg = lang[language].wrong2 + end + end + setCursorPos((scr_x/2)-(#badmsg/2),scr_y/2) + rhite(badmsg) + sleep(badlength) + doSine = true + setCursorBlink(true) + os.pullEvent = getevent + return "man you suck" +end + +local readPassFile = function() + local _output, _salt + if fs.exists(passFile) then + local file = fs.open(passFile,"r") + _output = file.readLine() + file.close() + end + if fs.exists(saltFile) then + local file = fs.open(saltFile,"r") + _salt = file.readLine() + file.close() + end + return _output, _salt +end + +local addNewPassword = function(pword,_path) + local file = fs.open(_path or passFile,"a") + file.write( sha256(pword,salt) ) + file.close() +end + +local rendersine = function(move) + move = move or 0 + local res1,res2,x,y + if csv then term.current().setVisible(false) end + setBackgroundColor(colors.black) + setCursorBlink(false) + for a = 1, scr_y do + if a ~= readYpos then + for b = 1, scr_x do + x = b+floor(scr_x/2) + y = a-floor(scr_y/2) + res1 = abs( floor(sin((x/(scr_x/7.3))+move)*scr_y/4) - y ) <= 2 + setCursorPos(b,a) + if res1 then + setBackgroundColor(palate.backsine) + else + setBackgroundColor(palate.background) + end + rhite(" ") + res2 = abs( floor(cos((x/(scr_x/12.75))+(move*4))*scr_y/7) - y+2 ) <= 1 + setCursorPos(b,a) + if res2 then + setBackgroundColor(palate.frontsine) + rhite(" ") + elseif not res1 then + setBackgroundColor(palate.background) + setTextColor(palate.rainColor) + if (x % 2 == 0) and ((y+floor(move*-10)+(x % 5)) % 5 <= 1) then + rhite(palate.rainChar) + else + rhite(" ") + end + end + end + end + end + if csv then term.current().setVisible(true) end + setCursorBlink(true) +end + +local sine = function() + doSine = true + while true do + if sineLevel > 900 then + sineLevel = 1 + end + if doSine then + local cX,cY = getCursorPos() + local bg,txt = getBackgroundColor(),getTextColor() + rendersine(sineLevel/10) + setCursorPos(cX,cY) + setBackgroundColor(bg) + setTextColor(txt) + end + sleep(sineFrameDelay) + if kaykaycoolcool then + sineLevel = sineLevel + 1 + end + end +end + +local funcread = function(repchar,rHistory,doFunc,noNewLine,writeFunc,cursorAdjFunc,doFuncEvent,charLimit) + local scr_x,scr_y = term.getSize() + local sx,sy = term.getCursorPos() + local cursor = 1 + local rCursor = #rHistory+1 + local output = "" + term.setCursorBlink(true) + local rite = writeFunc or term.write + cursorAdjFunc = cursorAdjFunc or function() return 0 end + while true do + local evt,key = os.pullEvent() + if evt == doFuncEvent then + pleaseDoFunc = true + elseif evt == "key" then + if key == keys.enter then + if not noNewLine then + write("\n") + end + term.setCursorBlink(false) + return output + elseif key == keys.left then + if cursor-1 >= 1 then + cursor = cursor - 1 + end + elseif key == keys.right then + if cursor <= #output then + cursor = cursor + 1 + end + elseif key == keys.up then + if rCursor > 1 then + rCursor = rCursor - 1 + term.setCursorPos(sx,sy) + rite((" "):rep(#output)) + output = (rHistory[rCursor] or ""):sub(1,charLimit or -1) + cursor = #output+1 + pleaseDoFunc = true + end + elseif key == keys.down then + term.setCursorPos(sx,sy) + rite((" "):rep(#output)) + if rCursor < #rHistory then + rCursor = rCursor + 1 + output = (rHistory[rCursor] or ""):sub(1,charLimit or -1) + cursor = #output+1 + pleaseDoFunc = true + else + rCursor = #rHistory+1 + output = "" + cursor = 1 + end + elseif key == keys.backspace then + if cursor > 1 and #output > 0 then + output = (output:sub(1,cursor-2)..output:sub(cursor)):sub(1,charLimit or -1) + cursor = cursor - 1 + pleaseDoFunc = true + end + elseif key == keys.delete then + if #output:sub(cursor,cursor) == 1 then + output = (output:sub(1,cursor-1)..output:sub(cursor+1)):sub(1,charLimit or -1) + pleaseDoFunc = true + end + end + elseif evt == "char" or evt == "paste" then + output = (output:sub(1,cursor-1)..key..output:sub(cursor+(#key-1))):sub(1,charLimit or -1) + cursor = math.min(#output+1,cursor+#key) + pleaseDoFunc = true + end + local pOut = (output or ""):sub(math.max( 1,(#output+sx)-scr_x) ) + if pleaseDoFunc then + pleaseDoFunc = false + if type(doFunc) == "function" then + doFunc(output:sub(1,charLimit or -1)) + end + term.setCursorPos(sx,sy) + if repchar then + rite(repchar:sub(1,1):rep(#pOut)) + else + rite(pOut) + end + term.write(" ") + end + term.setCursorPos(sx+cursorAdjFunc(pOut)+cursor-math.max( 1,(#output+sx)-scr_x),sy) + end +end + +local arse, arseSHA, passes + +local awaitKeyCard = function() + local bwop,_,side + repeat + _,side = os.pullEvent("disk") + if side then + bwop = fs.combine(disk.getMountPath(side),".sinepw") --bwop! + else + bwop = "" + end + until fs.exists(bwop) and not fs.isDir(bwop) + local file = fs.open(bwop,"r") + local output = file.readLine() + file.close() + arseSHA = output + if doEjectDisk then disk.eject(side) end +end + +local passwordPrompt = function() + if requireAllPasswords then + arse = {} + arseSHA = "" + for a = 1, ceil(#passes/64) do + setCursorPos(1,readYpos) + setBackgroundColor(palate.promptBG) + term.clearLine() + setTextColor(palate.promptTXT) + write("P"..a..">") + arse[#arse+1] = read(dahChar) + arseSHA = arseSHA..sha256(arse[#arse],salt) + end + else + setCursorPos(1,readYpos) + setBackgroundColor(palate.promptBG) + term.clearLine() + setTextColor(palate.promptTXT) + write(">") + arse = funcread(dahChar,{},nil,true,nil,nil,nil,characterLimit) + arseSHA = sha256(arse,salt) + end +end + +local count = 0 + +local lock = function() + if #doorSides > 0 then + for a = 1, #doorSides do + redstone.setOutput(doorSides[a],doInvertSignal) + end + end + while true do + passes, salt = readPassFile() + count = count + 1 + if doKeyCards then + parallel.waitForAny(passwordPrompt,awaitKeyCard) + else + passwordPrompt() + end + local good + if requireAllPasswords then + if passes == arseSHA then + good = true + else + good = false + end + else + if string.find(passes,arseSHA) then + good = true + else + good = false + end + end + if good then + goodpass(arseSHA,count) + if #doorSides == 0 then + return true + else + doSine = true + end + else + badpass(arseSHA,count) + end + end +end + +local choice = function(input) + repeat + event, key = os.pullEvent("key") + if type(key) == "number" then key = keys.getName(key) end + if key == nil then key = " " end + until string.find(input, key) + return key +end + +if not fs.exists(saltFile) then + local file = fs.open(saltFile,"w") + for a = 1, 128 do + local c = string.char(random(1,255)) + file.write(c) + end + file.close() + local f = fs.open(saltFile,"r") + salt = f.readLine() + f.close() +end + +passes, salt = readPassFile() + +local tArg = {...} +if tArg[1] == "addpass" then + if tArg[2] then + print("Really add password? [Y,N]") + local answer = choice("yn") + if answer == "n" then + sleep(0) + return print("Oh, okay.") + else + table.remove(tArg,1) + addNewPassword(table.concat(tArg," ")) + sleep(0) + return print("Added password.") + end + else + sleep(0) + return print("Expected a new password...") + end +elseif tArg[1] == "keymake" then + if tArg[2] then + print("Really add to disk?") + print("Keep in mind the password has to be manually added for the keycard to work.\n[Y,N]") + local answer = choice("yn") + if answer == "n" then + sleep(0) + return print("Oh, okay.") + else + print("Please insert a disk or pocket computer.") + local _,side = os.pullEvent("disk") + local diskPassPath = fs.combine(disk.getMountPath(side),".sinepw") + table.remove(tArg,1) + addNewPassword(table.concat(tArg," "),diskPassPath) + if not disk.getLabel(side) then + disk.setLabel(side,"slkey-"..random(1,1000)) + end + sleep(0) + print("Added password.") + if not doKeyCards then + print("Key cards aren't enabled, though.") + end + return + end + else + sleep(0) + return print("Expected a password...") + end +end + +if not fs.exists(passFile) then + local progname = fs.getName(shell.getRunningProgram()) + return print("No password file found.\nRun '"..progname.." addpass ' to add a password.") +end + +setBackgroundColor(colors.black) +term.clear() + +local parafunky = { --it looks kinda funky, but it tastes funKAY! + sine, + lock, +} + +if not beWavey then table.remove(parafunky,1) end --not funky, man +local staytis, errawr +while keepLooping do + kaykaycoolcool = true + staytis, errawr = pcall(parallel.waitForAny,unpack(parafunky)) + if keepLooping == false then break else + if terminateMode == 2 then + kaykaycoolcool = false + if not isTerminable then + sillyTerminate() + else + keepLooping = false + setBackgroundColor(colors.black) + term.clear() + setTextColor(colors.white) + setCursorPos(1,1) + break + end + else + keepLooping = false + setBackgroundColor(colors.black) + term.clear() + setTextColor(colors.white) + setCursorPos(1,1) + if not staytis then + printError(errawr) + end + break + end + end +end +if runProgram and (runProgram ~= "") then + shell.run(runProgram) +end \ No newline at end of file diff --git a/trippy-scr.lua b/trippy-scr.lua new file mode 100644 index 0000000..ba62bc7 --- /dev/null +++ b/trippy-scr.lua @@ -0,0 +1,111 @@ +local tArg = {...} + +local scr_x, scr_y = term.getSize() +local mx, my = scr_x/2, scr_y/2 + +-- special modes for special people +local mouseMode = tArg[1] == "mouse" or tArg[2] == "mouse" +local fuck = tArg[1] == "fuck" or tArg[2] == "fuck" + +-- localize functions to increase speed, maybe, I think +local concat, blit = table.concat, term.blit +local sin, cos, rad, abs, sqrt, floor = math.sin, math.cos, math.rad, math.abs, math.sqrt, math.floor + +-- rainbow pattern +local palette = {"e","1","4","5","d","9","b","a","2"} + +local distance = function(x1, y1, x2, y2) + return sqrt( (x2 - x1) ^ 2 + (y2 - y1) ^ 2 ) +end + +local randCase = function(str) + local output = "" + for i = 1, #str do + output = output .. ((math.random(0,1) == 1) and str:sub(i,i):upper() or str:sub(i,i):lower()) + end + return output +end + +local render = function(iterate, xscroll1, yscroll1, xscroll2, yscroll2) + local buffer, cx, cy = {{},{},{}} + for y = 1, scr_y do + buffer[1][y] = {} + buffer[2][y] = {} + buffer[3][y] = {} + for x = 1, scr_x do + cx = 0.66 * ((x - mx) > 0 and 1 or -1) * (abs(x - mx) ^ 1.2) + cy = ((y - my) > 0 and 1 or -1) * (abs(y - my) ^ 1.2) + + buffer[1][y][x] = fuck and randCase("fuck"):sub(1+(cx%4),1+(cx%4)) or "\127" + + buffer[2][y][x] = palette[1 + floor( + iterate + distance( cx + xscroll1, cy + yscroll1, 0, 0 ) + ) % #palette] or " " + + buffer[3][y][x] = palette[1 + floor( + iterate + distance( cx + xscroll2, cy + yscroll2, 0, 0 ) + ) % #palette] or " " + end + end + + for y = 1, scr_y do + term.setCursorPos(1,y) + -- suka + blit( + concat(buffer[1][y]), + concat(buffer[2][y]), + concat(buffer[3][y]) + ) + end +end + +local main = function() + term.clear() + local wave, evt = 0 + local xscroll1, yscroll1, xscroll2, yscroll2 = 0, 0, 0, 0 + if mouseMode then + parallel.waitForAny(function() + while true do + evt = {os.pullEvent()} + if evt[1] == "mouse_click" or evt[1] == "mouse_drag" then + if evt[2] == 1 then + xscroll1 = mx - evt[3] + yscroll1 = my - evt[4] + elseif evt[2] == 2 then + xscroll2 = mx - evt[3] + yscroll2 = my - evt[4] + end + end + end + end, + function() + while true do + render(wave, xscroll1, yscroll1, xscroll2, yscroll2) + wave = (wave + 1) % (360 * 7) + sleep(0.05) + end + end) + else + while true do + xscroll1 = -sin(rad(wave * 2)) * scr_x * 0.4 + yscroll1 = -cos(rad(wave * 3.5)) * scr_y * 0.4 + xscroll2 = -xscroll1 + yscroll2 = -yscroll1 + render(wave, xscroll1, yscroll1, xscroll2, yscroll2) + wave = (wave + 1) % (360 * 7) + sleep(0.05) + end + end +end + +-- wait for keypress to exit program +local waitForInput = function() + local evt + sleep(0.25) + os.pullEvent("key") +end + +parallel.waitForAny(main, waitForInput) +term.clear() +term.setCursorPos(1,1) +sleep(0.05) \ No newline at end of file diff --git a/wpath.lua b/wpath.lua new file mode 100644 index 0000000..8b1b04f --- /dev/null +++ b/wpath.lua @@ -0,0 +1,75 @@ +-- Wavey Path +-- Makes a wavey path to the right + +local wpath = {} + +wpath.cols = "e145d9ba26" +wpath.bwcols = "087f78" +wpath.waveLen = 3 +wpath.textScale = 2.5 +wpath.delay = 0.05 + +local rbow,bbow +local sizePath = "size.lua" + +if not peripheral.find("monitor") then + return +end + +local reset = function() + rbow,bbow = "","" + for a = 1,#wpath.cols do + rbow = rbow..wpath.cols:sub(a,a):rep(wpath.waveLen) + end + for a = 1,#wpath.bwcols do + bbow = bbow..wpath.bwcols:sub(a,a):rep(wpath.waveLen) + end +end +reset() + +local mons = {peripheral.find("monitor")} +local setscales = function() + for a = 1, #mons do + mons[a].setTextScale(wpath.textScale) + end +end + +local wrap = function(txt,amnt) + local output = {} + for a = 0, #txt-1 do + output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1) + end + return table.concat(output) +end + +local render = function(shift,mon) + local line + if not mon.getSize then return end + local scr_x,scr_y = mon.getSize() + scr_y = scr_y + (scr_y % 2) + bow = mon.isColor() and rbow or bbow + for y = 1, scr_y do + mon.setCursorPos(1,y) + line = bow:rep(scr_x):sub(1,scr_x) + local text = ("#"):rep(scr_x) + local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1) + local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift) + mon.blit(text,txcol,bgcol) + end +end + +local DOITNOW = function(YOUFUCKINGTWAT) + local shift = 0 + while true do + shift = (shift + 1) + mons = {peripheral.find("monitor")} + setscales() + for a = 1, #mons do + render(shift,mons[a]) + end + sleep(wpath.delay) + end +end + +--parallel.waitForAny(checkForReset,DOITNOW) +DOITNOW() \ No newline at end of file