Advertisement
LDDestroier

cork game test (cc)

May 12th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.62 KB | None | 0 0
  1. local function explode(div,str)
  2.     if (div=='') then return false end
  3.     local pos,arr = 0,{}
  4.     for st,sp in function() return string.find(str,div,pos,true) end do
  5.         table.insert(arr,string.sub(str,pos,st-1))
  6.         pos = sp + 1
  7.     end
  8.     table.insert(arr,string.sub(str,pos))
  9.     return arr
  10. end
  11.  
  12. game = {
  13.     maxscore = 180,
  14.     write = function(txt)
  15.         local cx,cy = term.getCursorPos()
  16.         local text = explode(" ",txt)
  17.         for a = 1, #text do
  18.             if cx+#text[a] > scr_x then
  19.                 term.setCursorPos(1,cy+1)
  20.             end
  21.             for b = 1, #text[a] do
  22.                 term.write(text[a]:sub(b,b))
  23.             end
  24.             cx, cy = term.getCursorPos()
  25.         end
  26.     end,
  27.     print = function(txt)
  28.         return game.write(txt.."\n")
  29.     end,
  30. }
  31.  
  32. funcread = function(repchar,rHistory,doFunc,noNewLine)
  33.     local scr_x,scr_y = term.getSize()
  34.     local sx,sy = term.getCursorPos()
  35.     local cursor = 1
  36.     local rCursor = #rHistory+1
  37.     local output = ""
  38.     term.setCursorBlink(true)
  39.     while true do
  40.         local evt,key = os.pullEvent()
  41.         local cx,cy = term.getCursorPos()
  42.         if evt == "key" then
  43.             if key == keys.enter then
  44.                 if not noNewLine then
  45.                     write("\n")
  46.                 end
  47.                 term.setCursorBlink(false)
  48.                 return output
  49.             elseif key == keys.left then
  50.                 if cursor-1 >= 1 then
  51.                     cursor = cursor - 1
  52.                 end
  53.             elseif key == keys.right then
  54.                 if cursor <= #output then
  55.                     cursor = cursor + 1
  56.                 end
  57.             elseif key == keys.up then
  58.                 if rCursor > 1 then
  59.                     rCursor = rCursor - 1
  60.                     term.setCursorPos(sx,sy)
  61.                     term.write((" "):rep(#output))
  62.                     output = rHistory[rCursor] or ""
  63.                     cursor = #output+1
  64.                     pleaseDoFunc = true
  65.                 end
  66.             elseif key == keys.down then
  67.                 term.setCursorPos(sx,sy)
  68.                 term.write((" "):rep(#output))
  69.                 if rCursor < #rHistory then
  70.                     rCursor = rCursor + 1
  71.                     output = rHistory[rCursor] or ""
  72.                     cursor = #output+1
  73.                     pleaseDoFunc = true
  74.                 else
  75.                     rCursor = #rHistory+1
  76.                     output = ""
  77.                     cursor = 1
  78.                 end
  79.             elseif key == keys.backspace then
  80.                 if cursor > 1 and #output > 0 then
  81.                     output = output:sub(1,cursor-2)..output:sub(cursor)
  82.                     cursor = cursor - 1
  83.                     pleaseDoFunc = true
  84.                 end
  85.             elseif key == keys.delete then
  86.                 if #output:sub(cursor,cursor) == 1 then
  87.                     output = output:sub(1,cursor-1)..output:sub(cursor+1)
  88.                     pleaseDoFunc = true
  89.                 end
  90.             end
  91.         elseif evt == "char" or evt == "paste" then
  92.             output = output:sub(1,cursor-1)..key..output:sub(cursor+(#key-1))
  93.             cursor = cursor + #key
  94.             pleaseDoFunc = true
  95.         end
  96.         if pleaseDoFunc then
  97.             pleaseDoFunc = false
  98.             if type(doFunc) == "function" then
  99.                 doFunc(output)
  100.             end
  101.             term.setCursorPos(sx,sy)
  102.             local pOut = output
  103.             if #output >= scr_x-(sx-2) then
  104.                 pOut = output:sub((#output+(sx))-scr_x)
  105.             end
  106.             if repchar then
  107.                 term.write(repchar:sub(1,1):rep(#pOut).." ")
  108.             else
  109.                 term.write(pOut.." ")
  110.             end
  111.             local cx,cy = term.getCursorPos()
  112.         end
  113.         term.setCursorPos(sx+cursor-1,cy)
  114.     end
  115. end
  116.  
  117. gameoverflavor = {
  118.     nopoints = "I can't believe you. On account of being clinically insane, you are hereby BANNED before you can kill anyone else with a club. How'd you even figure out how to start the game??",
  119.     somepoints = "You had your chance, but you had to go and blow it. Newbie mistakes are allowed, but you're starting to become a nuisance, and I have no choice but to BAN you. Good day sir.",
  120. }
  121.  
  122. cmdAlias = {
  123.     sniff = {
  124.         "sniff",
  125.         "smell",
  126.         "snuff",
  127.         "nose",
  128.         "snort",
  129.     },
  130.     eat = {
  131.         "eat"
  132.         "consume",
  133.         "scarf",
  134.         "nom",
  135.         "bite",
  136.         "dine",
  137.         "sample",
  138.         "taste",
  139.     },
  140.     lick = {
  141.         "lick",
  142.         "tongue",
  143.     },
  144.     touch = {
  145.         "touch",
  146.         "tap",
  147.         "feel",
  148.     },
  149.     look = {
  150.         "look",
  151.         "see",
  152.         "observe",
  153.         "sight",
  154.         "lookit",
  155.         "where",
  156.     },
  157.     talk = {
  158.         "talk",
  159.         "speak",
  160.         "blather",
  161.         "blabber",
  162.         "tell",
  163.         "gab",
  164.         "drawl",
  165.     },
  166.     yell = {
  167.         "yell",
  168.         "shout",
  169.         "holler",
  170.         "screech",
  171.         "shriek",
  172.         "hoopla",
  173.         "hooplah",
  174.     },
  175.     kill = {
  176.         "kill",
  177.         "murder",
  178.         "assassinate",
  179.         "beat",
  180.         "attack",
  181.         "assault",
  182.         "hit",
  183.         "brutalize",
  184.         "killinate",
  185.     },
  186.     punch = {
  187.         "punch",
  188.         "uppercut",
  189.         "jab",
  190.         "hook",
  191.         "clobber",
  192.         "deck",
  193.         "bagoom",
  194.     },
  195.     kick = {
  196.         "kick",
  197.         "dropkick",
  198.         "roundhousekick",
  199.         "boot",
  200.         "punt",
  201.     },
  202.     cut = {
  203.         "cut",
  204.         "slash",
  205.         "slice",
  206.         "slit",
  207.         "cleave",
  208.     },
  209.     use = {
  210.         "use",
  211.         "activate",
  212.         "utilize",
  213.         "employ",
  214.         "wield",
  215.     },
  216.     take = {
  217.         "take",
  218.         "steal",
  219.         "get",
  220.         "acquire",
  221.         "obtain",
  222.         "procure",
  223.     },
  224.     burn = {
  225.         "burn",
  226.         "burninate",
  227.         "ignite",
  228.         "combust",
  229.         "inflame",
  230.         "char",
  231.         "blaze",
  232.         "scorch",
  233.     },
  234.     me = {
  235.         "me",
  236.         "I",
  237.         "myself",
  238.         "self",
  239.         "meself",
  240.         "127.0.0.1",
  241.     },
  242.     sex = {
  243.         "sex",
  244.         "fornicate",
  245.         "sodomize",
  246.         "fuck",
  247.         "do",
  248.         "smex",
  249.         "smexify",
  250.         "rape",
  251.         "grape",
  252.     },
  253.    
  254. }
  255.  
  256. player = {
  257.     points = 0,
  258.     lives = 5,
  259.     act = {
  260.         die = function(condition)
  261.             game.print(condition or "It didn't work out.")
  262.             game.print(" YOU HAVE DIED.")
  263.             game.print("Score: "..tostring(player.score).." out of a possible "..tostring(game.maxscore).." points.")
  264.             if player.lives > 0 then
  265.                 game.print("Don't worry. Everyone makes mistakes. I'll give you another shot! Don't waste it.")
  266.                 player.lives = player.lives - 1
  267.             else
  268.                 if player.points == 0 then
  269.                     game.print(gameoverflavors.nopoints)
  270.                 else
  271.                     game.print(gameoverflavors.somepoints)
  272.                 end
  273.                 stopgame()
  274.             end
  275.         end,
  276.     },
  277. }
  278.  
  279. items = {
  280.     ["flower"] = {
  281.         type = "item",
  282.         licked = false,
  283.         act = {
  284.             sniff = function()
  285.                 game.logadd("It smells like sadness, which kinda smells like brine and cry'n.")
  286.             end,
  287.             eat = function()
  288.                 game.logadd("No, don't.")
  289.             end,
  290.             look = function()
  291.                 game.logadd("A red, thorny flower taken from your mother's grave. Stealing her flowers was probably what she would have wanted you to do.")
  292.             end,
  293.             lick = function()
  294.                 if items["flower"].licked then
  295.                     game.logadd("You're a sick fuck, you know that?")
  296.                 else
  297.                     game.logadd("What do you want me to say? It tastes like rosewater?")
  298.                 end
  299.                 items["flower"].licked = true
  300.             end,
  301.             touch = function()
  302.                 game.logadd("The flower feels like a flower. That's nice.")
  303.             end
  304.             talk = function()
  305.                 game.logadd("You know, talking to plants is a sign of insanity.")
  306.             end,
  307.             yell = function()
  308.                 game.logadd("Please don't shout at the plants. It's rude.")
  309.             end,
  310.             kill = function()
  311.                 game.logadd("This plant was already picked from the ground, you bastard.")
  312.             end,
  313.             punch = function()
  314.                 game.logadd("Who the hell goes around punching flowers?")
  315.             end,
  316.             kick = function()
  317.                 game.logadd("Don't step on the plant life.")
  318.             end,
  319.             cut = function()
  320.                 game.logadd("It's amazing you managed to keep this flower for so many years without shiving everybody you meet.")
  321.             end,
  322.             take = function()
  323.                 game.logadd("You already have the flower.")
  324.             end,
  325.             burn = function()
  326.                 game.logadd("The flower sees the light. But you decide against it.")
  327.             end,
  328.             fuck = function()
  329.                 game.logadd("Hands off the flower, Oedipus.")
  330.             end,
  331.         }
  332.     },
  333. }
  334.  
  335. rooms = {
  336.     lyncks = {
  337.         desc = "You stand in a boring-as-shit command prompt that seems to be a web browser...? It has full access to javascript, PHP, HTML, CSS, and more! Unlike this game.",
  338.         exec = function() end, --executed upon entering a room
  339.         paths = {
  340.             {
  341.                 path = rooms.google,
  342.                 desc = "Right up north is Google.com.",
  343.                 look = "It shines brightly from your lowly fully-graphical shell that you totally have."
  344.             },
  345.             {
  346.                 path = rooms.spikeydeath,
  347.                 desc = "A horrible room of spikes is to your west.",
  348.                 look = "You don't even want to think about going in there.",
  349.             },
  350.         }
  351.         items = {
  352.             {
  353.                 obj = items.flower,
  354.                 desc = {
  355.                     name = "There is a flower", --there is a banana
  356.                     prepos = " on the floor.", -- in the washing machine.
  357.                 },
  358.                 cmd = { --special text when on a surface.
  359.                     look = function() game.logadd("What's the flower doing there? It has some deep sentimental value, so you must feel like an asshole leaving it on the crusty, text-based floor.") end
  360.                     eat = function() game.logadd("Stop grazing, you cow.") end
  361.                     lick = function() game.logadd("It's too far away for you to defile it.") end
  362.                 }
  363.                 reachable = true,
  364.             },
  365.         },
  366.     },
  367. }
  368.  
  369. logroom = function(room)
  370.     local msg = room.desc or "This room is an enigma."
  371.     for a = 1, #(room.items or {}) do
  372.         msg = msg.." "..(room.items[a].desc.name)..(room.items[a].desc.prepos)
  373.     end
  374.     game.logadd(msg)
  375.     if room.exec then room.exec() end
  376. end
  377.  
  378. parser = function()
  379.     while true do
  380.         term.setCursorPos(1,scr_y-1)
  381.         local message = explode(" ",read())
  382.        
  383.     end
  384. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement