Advertisement
Frekvens1

CC Demo Game by Frekvens1

Nov 24th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.87 KB | None | 0 0
  1. -- Adventure Time
  2. -- This Game Demo is made by Frekvens1
  3. -- Do not claim this as your own!
  4.  
  5. local oldPull = os.pullEvent;
  6. os.pullEvent = os.pullEventRaw;
  7.  
  8. -- pastebin get JPx07uRB startup
  9.  
  10. local DebugMode = false
  11.  
  12. local ShowCords = true
  13. local ShowStepsReboot = true
  14.  
  15. local showMainMenu = false
  16.  
  17. local menuPos = 2
  18. local messagePos = 9
  19. local mapStartPos = 2
  20.  
  21. local screenfixX = 14
  22. local screenfixY = 8
  23.  
  24. local MainMenuY = -1
  25.  
  26. local W = 17
  27. local S = 31
  28. local A = 30
  29. local D = 32
  30. local Enter = 28
  31. local M = 50
  32.  
  33. local Map1X = 0
  34. local Map1Y = 0
  35.  
  36. local Map2X = 0
  37. local Map2Y = 0
  38.  
  39. local House1X = 0
  40. local House1Y = 0
  41.  
  42. local Username = "Gamer"
  43. local HP = 0
  44. local Money = 0
  45.  
  46. local Walks = "0"
  47. local WalksRemaining = ""
  48. local Remaining = ""
  49.  
  50. local deathSide = ""
  51.  
  52. local selectedMap = "Map1"
  53.  
  54. local integer
  55. local maxInteger = 42
  56. -- 166
  57. -- 163
  58. -- 160
  59. -- 153
  60.  
  61. function checkIfDebuging()
  62.    if DebugMode == true then
  63.        ShowCords = true
  64.        ShowStepsReboot = true
  65.    else
  66.        ShowCords = false
  67.        ShowStepsReboot = false  
  68.    end
  69. end
  70.  
  71. function GetSteps()
  72.    local junk = 41 - maxInteger
  73.    WalksRemaining = (junk * 3) + 140
  74. end
  75.  
  76. local House1falseX = {12,11,10, 9, 8, 7, 6, 5, 5,-10,-9,-11,-11,-10,-9}
  77. local House1falseY = {-4,-4,-4,-4,-4,-4,-4,-4,-5, -5,-5, -5, -3, -3,-3}
  78.  
  79. local Map1falseX = {1 , 2, 3, 4, 5,-1,-2,-3,-4,-5,-5,-6,-5, 5, 6, 5, 0, 1, 2, 3, 4, 5, 6,-1,-2,-3,-4,-5,-6, 6,-6,-6,-7,-6, 6, 6, 7, 0,14,13,13}
  80. local Map1falseY = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-3,-4,-2,-3,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-1,-2,-3,-4,-1,-2,-3,-2, 1, 2, 0}
  81.  
  82. local Map2falseX = {-3,-2,-4,-14,-13,-13,7,6,8,14,13,13,0,1,2,3,4, 5,6,7,8,9,10,10,10,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,-1, 0, 0}
  83. local Map2falseY = {-7,-6,-6,  1,  0,  2,7,6,6, 1, 0, 2,0,0,0,0,0,-1,0,0,0,0, 0,-1,-2,-3,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-2,-1}
  84.  
  85. local Map2maxX = {13,-13}
  86. local Map2maxY = {6,-6}
  87.  
  88. local Map1maxX = {13,-13}
  89. local Map1maxY = {6,-6}
  90.  
  91. local House1maxX = {13,-13}
  92. local House1maxY = {-1, -6}
  93.    --("-------------------------")
  94.    --("------_____________------")
  95.    --("-----/_____________\\-----")
  96.    --("------|    ___    |------")
  97.    --("------|____|_|____|------")
  98.    --("------------o------------")
  99.    --("-------------------------")
  100.    --("-------------------------")
  101.    --("-------------------------")
  102.    --("-------------------------")
  103.  
  104. local KeyPressed = ""
  105.  
  106. function loadWithCords()
  107.   if DebugMode == true then
  108.    if ShowCords == true then
  109.       menuPos = 2
  110.       messagePos = 9
  111.       mapStartPos = 2
  112.  
  113.       screenfixX = 14
  114.       screenfixY = 8
  115.    else
  116.       menuPos = 1
  117.       messagePos = 8
  118.       mapStartPos = 1
  119.  
  120.       screenfixX = 14
  121.       screenfixY = 7      
  122.    end
  123.   else
  124.       ShowStepsReboot = false
  125.       ShowCords = false
  126.      
  127.       menuPos = 1
  128.       messagePos = 8
  129.       mapStartPos = 1
  130.  
  131.       screenfixX = 14
  132.       screenfixY = 7  
  133.   end
  134. end
  135.  
  136. function StartUp()
  137.    Presser()
  138.    integer = 1
  139.    NoPermWalking()
  140.    ChangeMap()
  141.    CurrentMap()
  142.    term.setCursorPos(1,1)
  143.    if ShowCords == true then
  144.       if selectedMap == "Map1" then
  145.          print("Cords: X: ",Map1X," Y: ",Map1Y)
  146.       elseif selectedMap == "Map2" then
  147.          print("Cords: X: ",Map2X," Y: ",Map2Y)
  148.       elseif selectedMap == "House1" then
  149.          print("Cords: X: ",House1X," Y: ",House1Y)
  150.       else
  151.          print("Cords: X: ",Map1X," Y: ",Map1Y)
  152.       end
  153.    end
  154.    giveMessage()
  155.    if ShowStepsReboot == true then
  156.       term.setCursorPos(1,18)
  157.       print(Remaining," steps remaining until reboot")
  158.    end
  159.    term.setCursorPos(1,19)
  160.    if showMainMenu == true then
  161.       mainMenu()
  162.    else
  163.       if HP == 0 then
  164.          deathMessage()
  165.       else
  166.          StartUp()
  167.       end
  168.    end
  169. end
  170.  
  171. function mainMenu()
  172.    term.clear()
  173.    if Remaining == 0 then
  174.       os.reboot()
  175.    end
  176.    if ShowStepsReboot == true then
  177.       term.setCursorPos(1,18)
  178.       print(Remaining," steps remaining until reboot")
  179.    end
  180.    if ShowCords == true then
  181.       term.setCursorPos(1,1)
  182.       print("Cords: Y: ",MainMenuY)
  183.    end
  184.    if MainMenuY == -1 then
  185.       term.setCursorPos(1,menuPos)
  186.       print("[-------------------------------------------------]")
  187.       print("[-                   Main Menu                   -]")
  188.       print("[-------------------------------------------------]")
  189.       print("[-    [Resume Game]    Bag     Save and Quit     -]")
  190.       print("[-------------------------------------------------]")
  191.    elseif MainMenuY == 0 then
  192.       term.setCursorPos(1,menuPos)
  193.       print("[-------------------------------------------------]")
  194.       print("[-                   Main Menu                   -]")
  195.       print("[-------------------------------------------------]")
  196.       print("[-     Resume Game    [Bag]    Save and Quit     -]")
  197.       print("[-------------------------------------------------]")
  198.    elseif MainMenuY == 1 then
  199.       term.setCursorPos(1,menuPos)
  200.       print("[-------------------------------------------------]")
  201.       print("[-                   Main Menu                   -]")
  202.       print("[-------------------------------------------------]")
  203.       print("[-     Resume Game     Bag    [Save and Quit]    -]")
  204.       print("[-------------------------------------------------]")
  205.    else
  206.       MainMenuY = -1
  207.       print("[-------------------------------------------------]")
  208.       print("[-                   Main Menu                   -]")
  209.       print("[-------------------------------------------------]")
  210.       print("[-    [Resume Game]    Bag     Save and Quit     -]")
  211.       print("[-------------------------------------------------]")  
  212.    end
  213.    
  214.     local evt, key = os.pullEvent("key")
  215.     Remaining = Remaining - 1
  216.    
  217.    if key == M then
  218.       showMainMenu = false
  219.       MainMenuY = -1
  220.       showCurrentMap()
  221.    elseif key == Enter then
  222.       if MainMenuY == -1 then
  223.          showMainMenu = false
  224.          MainMenuY = -1
  225.          SaveSteps()
  226.          showCurrentMap()
  227.       elseif MainMenuY == 0 then
  228.          SaveSteps()
  229.          mainMenu()
  230.       elseif MainMenuY == 1 then
  231.          SaveSteps()
  232.          os.shutdown()
  233.       else
  234.          showMainMenu = false
  235.          MainMenuY = -1
  236.          SaveSteps()
  237.       end
  238.    elseif key == A then
  239.       if MainMenuY == -1 then
  240.       SaveSteps()
  241.       mainMenu()
  242.       else
  243.          MainMenuY = MainMenuY - 1
  244.          SaveSteps()
  245.          mainMenu()
  246.       end
  247.    elseif key == D then
  248.       if MainMenuY == 1 then
  249.       SaveSteps()
  250.       mainMenu()
  251.       else
  252.          MainMenuY = MainMenuY + 1
  253.          SaveSteps()
  254.          mainMenu()
  255.       end
  256.    else
  257.       mainMenu()
  258.       SaveSteps()
  259.    end
  260.    SaveSteps()
  261. end
  262.  
  263. function showCurrentMap()
  264.    os.reboot()
  265. end
  266.  
  267. function deathMessage()
  268.    if Remaining == 0 then
  269.       os.reboot()
  270.    end
  271.    term.clear()
  272.       if ShowStepsReboot == true then
  273.          term.setCursorPos(1,18)
  274.          print(Remaining," steps remaining until reboot")
  275.       end
  276.       if ShowCords == true then
  277.       term.setCursorPos(1,1)
  278.          if deathSide == D then
  279.             print("Cords: Right")
  280.          else
  281.             print("Cords: Left")
  282.          end
  283.       end
  284.    term.setCursorPos(1,menuPos)
  285.    if deathSide == D then
  286.        print("[-------------------------------------------------]")
  287.        print("[-   Oh No! You died! Do you wish to continue?   -]")
  288.        print("[-------------------------------------------------]")
  289.        print("[-              YES             [NO]             -]")
  290.        print("[-------------------------------------------------]")
  291.    elseif deathSide == A then
  292.        print("[-------------------------------------------------]")
  293.        print("[-   Oh No! You died! Do you wish to continue?   -]")
  294.        print("[-------------------------------------------------]")
  295.        print("[-             [YES]             NO              -]")
  296.        print("[-------------------------------------------------]")
  297.    else
  298.        deathSide = A
  299.        print("[-------------------------------------------------]")
  300.        print("[-   Oh No! You died! Do you wish to continue?   -]")
  301.        print("[-------------------------------------------------]")
  302.        print("[-             [YES]             NO              -]")
  303.        print("[-------------------------------------------------]")
  304.    end
  305.  
  306.    local evt, key = os.pullEvent("key")
  307.    Remaining = Remaining - 1
  308.    if key == Enter then
  309.        if deathSide == A then
  310.            HP = 100
  311.            selectedMap = "House1"
  312.            House1X = -10
  313.            House1Y = -4
  314.            SaveSteps()
  315.            os.reboot()
  316.        else
  317.           SaveSteps()
  318.           os.shutdown()
  319.        end
  320.    else
  321.       deathSide = key
  322.       deathMessage()
  323.    end
  324. end
  325.  
  326. function giveMessage()
  327.    if selectedMap == "Map1" then
  328.       if Map1X == -3 and Map1Y == 0 then
  329.          term.setCursorPos(29,messagePos)
  330.          print("[---------------------]")
  331.          term.setCursorPos(29,messagePos + 1)
  332.          print("[-        Sign       -]")
  333.          term.setCursorPos(29,messagePos + 2)
  334.          print("[---------------------]")
  335.          term.setCursorPos(29,messagePos + 3)
  336.          print("[- ", Username,"'s House")
  337.          term.setCursorPos(50,messagePos + 3)
  338.          print("-]")
  339.          term.setCursorPos(29,messagePos + 4)
  340.          print("[---------------------]")
  341.       elseif Map1X == 12 and Map1Y == 1 then
  342.          term.setCursorPos(29,messagePos)
  343.          print("[---------------------]")
  344.          term.setCursorPos(29,messagePos + 1)
  345.          print("[-        Sign       -]")
  346.          term.setCursorPos(29,messagePos + 2)
  347.          print("[---------------------]")
  348.          term.setCursorPos(29,messagePos + 3)
  349.          print("[-  Main road ahead  -]")
  350.          term.setCursorPos(29,messagePos + 4)
  351.          print("[-       ---->       -]")
  352.          term.setCursorPos(29,messagePos + 5)
  353.          print("[---------------------]")
  354.       end
  355.    elseif selectedMap == "Map2" then
  356.       if Map2X == -12 and Map2Y == 1 then
  357.          term.setCursorPos(29,messagePos)
  358.          print("[---------------------]")
  359.          term.setCursorPos(29,messagePos + 1)
  360.          print("[-        Sign       -]")
  361.          term.setCursorPos(29,messagePos + 2)
  362.          print("[---------------------]")
  363.          term.setCursorPos(29,messagePos + 3)
  364.          print("[- ", Username,"'s House")
  365.          term.setCursorPos(50,messagePos + 3)
  366.          print("-]")
  367.          term.setCursorPos(29,messagePos + 4)
  368.          print("[-       <----       -]")
  369.          term.setCursorPos(29,messagePos + 5)
  370.          print("[---------------------]")
  371.       elseif Map2X == 2 and Map2Y == 1 then
  372.          term.setCursorPos(29,messagePos)
  373.          print("[---------------------]")
  374.          term.setCursorPos(29,messagePos + 1)
  375.          print("[-       Store       -]")
  376.          term.setCursorPos(29,messagePos + 2)
  377.          print("[---------------------]")
  378.          term.setCursorPos(29,messagePos + 3)
  379.          print("[-   Come and buy!   -]")
  380.          term.setCursorPos(29,messagePos + 4)
  381.          print("[---------------------]")
  382.       end
  383.    elseif selectedMap == "House1" then
  384.        if House1X == -10 and House1Y == -4 then
  385.           term.setCursorPos(29,messagePos)
  386.           print("[---------------------]")
  387.           term.setCursorPos(29,messagePos + 1)
  388.           print("[-        Bed        -]")
  389.           term.setCursorPos(29,messagePos + 2)
  390.           print("[---------------------]")
  391.           term.setCursorPos(29,messagePos + 3)
  392.           print("[-  Its Comfortable  -]")
  393.           term.setCursorPos(29,messagePos + 4)
  394.           print("[---------------------]")
  395.        elseif House1X == 8 and House1Y == -3 then
  396.           term.setCursorPos(29,messagePos)
  397.           print("[---------------------]")
  398.           term.setCursorPos(29,messagePos + 1)
  399.           print("[-        Oven       -]")
  400.           term.setCursorPos(29,messagePos + 2)
  401.           print("[---------------------]")
  402.           term.setCursorPos(29,messagePos + 3)
  403.           print("[-   Cook your food  -]")
  404.           term.setCursorPos(29,messagePos + 4)
  405.           print("[---------------------]")
  406.         elseif House1X == 10 and House1Y == -3 then
  407.           term.setCursorPos(29,messagePos)
  408.           print("[---------------------]")
  409.           term.setCursorPos(29,messagePos + 1)
  410.           print("[-        Sink       -]")
  411.           term.setCursorPos(29,messagePos + 2)
  412.           print("[---------------------]")
  413.           term.setCursorPos(29,messagePos + 3)
  414.           print("[-    Fresh Water    -]")
  415.           term.setCursorPos(29,messagePos + 4)
  416.           print("[---------------------]")
  417.         elseif House1X == 12 and House1Y == -3 then
  418.           term.setCursorPos(29,messagePos)
  419.           print("[---------------------]")
  420.           term.setCursorPos(29,messagePos + 1)
  421.           print("[-       Fridge      -]")
  422.           term.setCursorPos(29,messagePos + 2)
  423.           print("[---------------------]")
  424.           term.setCursorPos(29,messagePos + 3)
  425.           print("[- It can store food -]")
  426.           term.setCursorPos(29,messagePos + 4)
  427.           print("[---------------------]")
  428.       end
  429.    end
  430. end
  431.  
  432. function ChangeMap()
  433.    if selectedMap == "Map1" then
  434.       if Map1X == 0 and Map1Y == -1 then
  435.          selectedMap = "House1"
  436.          Map1X = 0
  437.          Map1Y = 0
  438.          House1X = 0
  439.          House1Y = -2
  440.       elseif Map1X == 13 and Map1Y == 1 then
  441.          selectedMap = "Map2"
  442.          Map1X = 12
  443.          Map1Y = 1
  444.          Map2X = -12
  445.          Map2Y = 1
  446.       end
  447.    elseif Map2X == -13 and Map2Y == 1 then
  448.          selectedMap = "Map1"
  449.          Map1X = 12
  450.          Map1Y = 1
  451.          Map2X = -12
  452.          Map2Y = 1
  453.    elseif selectedMap == "House1" then
  454.       if House1X == 0 and House1Y == -1 then
  455.          selectedMap = "Map1"
  456.          Map1X = 0
  457.          Map1Y = 0
  458.          House1X = 0
  459.          House1Y = -2
  460.       end
  461.    end
  462. end
  463.  
  464. function House1()
  465.    local posX = House1X + screenfixX
  466.    local posY = House1Y + screenfixY
  467.    term.setCursorPos(1,mapStartPos)
  468.    print("___________________________")
  469.    print("| /-\\             | |x|u|F|")
  470.    print("| |?|             --------|")
  471.    print("| |-|                ? ? ?|")
  472.    print("|                         |")
  473.    print("|-----------|_|-----------|")
  474.    term.setCursorPos(posX,posY)
  475.    print("o")
  476. end
  477.  
  478. function Map1()
  479.    local posX = Map1X + screenfixX
  480.    local posY = Map1Y + screenfixY
  481.    term.setCursorPos(1,mapStartPos)
  482.    print("___________________________")
  483.    print("|                         |")
  484.    print("|      _____________      |")
  485.    print("|     /_____________\\     |")
  486.    print("|      |    ___    |      |")
  487.    print("|      |__s_|_|____|      |")
  488.    print("|         ? | |___________|")
  489.    print("|           |            s]")
  490.    print("|           --------------|")
  491.    print("|                         |")
  492.    print("|                         |")
  493.    print("|                         |")
  494.    print("---------------------------")
  495.    term.setCursorPos(posX,posY)
  496.    print("o")
  497. end
  498.  
  499. function Map2()
  500.    local posX = Map2X + screenfixX
  501.    local posY = Map2Y + screenfixY
  502.    term.setCursorPos(1,mapStartPos)
  503.    print("__________-________________")
  504.    print("|        |s|              |")
  505.    print("|        | | ___________  |")
  506.    print("|        | |/___________\\ |")
  507.    print("|        | | |_       _|  |")
  508.    print("|        | | |_| ___ |_|  |")
  509.    print("|________| |_|_s_|_|___|__|")
  510.    print("[s                       s]")
  511.    print("|------------------| |----|")
  512.    print("|                  | |    |")
  513.    print("|                  | |    |")
  514.    print("|                  |s|    |")
  515.    print("--------------------_------")
  516.    term.setCursorPos(posX,posY)
  517.    print("o")
  518. end
  519.  
  520. function OldMap1()
  521.    local posX = Map1X + 14
  522.    local posY = Map1Y + 8
  523.    print("Cords: X: ",Map1X," Y: ",Map1Y)
  524.    print("___________________________")
  525.    print("|-------------------------|")
  526.    print("|------_____________------|")
  527.    print("|-----/_____________\\-----|")
  528.    print("|------|    ___    |------|")
  529.    print("|------|____|_|____|------|")
  530.    print("|-------------------------|")
  531.    print("|-------------------------)")
  532.    print("|-------------------------|")
  533.    print("|-------------------------|")
  534.    print("|-------------------------|")
  535.    print("---------------------------")
  536.    term.setCursorPos(posX,posY)
  537.    print("o")
  538.    term.setCursorPos(1,14)
  539.    print(Remaining," steps remaining until reboot")
  540.    term.setCursorPos(1,15)
  541. end
  542.  
  543. function CurrentMap()
  544.    term.clear()
  545.    term.setCursorPos(1,1)
  546.    Remaining = WalksRemaining - Walks
  547.    if selectedMap == "Map1" then
  548.       Map1()
  549.    elseif selectedMap == "House1" then
  550.       House1()
  551.    elseif selectedMap == "Map2" then
  552.       Map2()
  553.    else
  554.       selectedMap = "Map1"
  555.       Map1()
  556.    end
  557.    menu()
  558.    SaveSteps()
  559.    Walks = Walks + 1
  560. end
  561.  
  562. function menu()
  563.    term.setCursorPos(29,menuPos)
  564.    print("[---------------------]")
  565.    term.setCursorPos(29,menuPos + 1)
  566.    print("[- ",Username)
  567.    term.setCursorPos(50,menuPos + 1)
  568.    print("-]")
  569.    term.setCursorPos(29,menuPos + 2)
  570.    print("[---------------------]")
  571.    term.setCursorPos(29,menuPos + 3)
  572.    print("[- HP: ",HP)
  573.    term.setCursorPos(50,menuPos + 3)
  574.    print("-]")
  575.    term.setCursorPos(29,menuPos + 4)
  576.    print("[- Money: ", Money)
  577.    term.setCursorPos(50,menuPos + 4)
  578.    print("-]")
  579.    term.setCursorPos(29,menuPos + 5)
  580.    print("[---------------------]")
  581. end
  582.  
  583. function NoPermWalking2()
  584.    NoPermWalking()
  585. end
  586.  
  587. function NoPermWalking()
  588.  if maxInteger == integer then
  589.  else
  590.     if KeyPressed == W then
  591.         if Map1X == Map1falseX[integer] and Map1Y == Map1falseY[integer] then
  592.            Map1Y = Map1Y + 1
  593.         elseif House1X == House1falseX[integer] and House1Y == House1falseY[integer] then
  594.            House1Y = House1Y + 1
  595.         elseif Map2X == Map2falseX[integer] and Map2Y == Map2falseY[integer] then
  596.            Map2Y = Map2Y + 1
  597.         end
  598.     end
  599.     if KeyPressed == S then
  600.         if Map1X == Map1falseX[integer] and Map1Y == Map1falseY[integer] then
  601.            Map1Y = Map1Y - 1
  602.         elseif House1X == House1falseX[integer] and House1Y == House1falseY[integer] then
  603.            House1Y = House1Y - 1
  604.         elseif Map2X == Map2falseX[integer] and Map2Y == Map2falseY[integer] then
  605.            Map2Y = Map2Y - 1
  606.         end
  607.    end
  608.    if KeyPressed == A then
  609.         if Map1X == Map1falseX[integer] and Map1Y == Map1falseY[integer] then
  610.            Map1X = Map1X + 1
  611.         elseif House1X == House1falseX[integer] and House1Y == House1falseY[integer] then
  612.               House1X = House1X + 1
  613.         elseif Map2X == Map2falseX[integer] and Map2Y == Map2falseY[integer] then
  614.            Map2X = Map2X + 1
  615.         end
  616.    end
  617.    if KeyPressed == D then
  618.         if Map1X == Map1falseX[integer] and Map1Y == Map1falseY[integer] then
  619.            Map1X = Map1X - 1
  620.         elseif House1X == House1falseX[integer] and House1Y == House1falseY[integer] then
  621.               House1X = House1X - 1
  622.         elseif Map2X == Map2falseX[integer] and Map2Y == Map2falseY[integer] then
  623.            Map2X = Map2X - 1
  624.         end
  625.    end
  626.    integer = integer + 1
  627.    NoPermWalking2()
  628.  end
  629. end
  630.  
  631. function Presser()
  632.    local evt, key = os.pullEvent("key")
  633.    KeyPressed = key
  634.    if key == W then
  635.       if selectedMap == "Map1" then
  636.         if Map1maxY[2] == Map1Y - 1 then
  637.         else
  638.             Map1Y = Map1Y - 1
  639.         end
  640.       elseif selectedMap == "House1" then
  641.          if House1maxY[2] == House1Y - 1 then
  642.          else
  643.             House1Y = House1Y - 1
  644.          end
  645.        elseif selectedMap == "Map2" then
  646.          if Map2maxY[2] == Map2Y - 1 then
  647.             if Map2X == -3 and Map2Y == -5 then
  648.                Map2Y = Map2Y - 1
  649.             end
  650.          else
  651.             Map2Y = Map2Y - 1
  652.          end
  653.       else
  654.          selectedMap = "Map1"
  655.          if Map1maxY[2] == Map1Y - 1 then
  656.          else
  657.             Map1Y = Map1Y - 1
  658.          end
  659.       end
  660.    end
  661.    if key == M then
  662.       showMainMenu = true
  663.       MainMenuY = -1
  664.       Remaining = Remaining - 1
  665.    end
  666.    if key == S then
  667.       if selectedMap == "Map1" then
  668.          if Map1maxY[1] == Map1Y + 1 then
  669.          else
  670.             Map1Y = Map1Y + 1
  671.          end
  672.       elseif selectedMap == "House1" then
  673.          if House1maxY[1] == House1Y + 1 then
  674.             if House1X == 0 and House1Y == -2 then
  675.             House1Y = House1Y + 1
  676.             end
  677.          else
  678.             House1Y = House1Y + 1
  679.          end
  680.       elseif selectedMap == "Map2" then
  681.          if Map2maxY[1] == Map2Y + 1 then
  682.             if Map2X == 7 and Map2Y == 5 then
  683.                Map2Y = Map2Y + 1
  684.             end
  685.          else
  686.             Map2Y = Map2Y + 1
  687.          end
  688.       else
  689.          selectedMap = "Map1"
  690.          if Map1maxY[1] == Map1Y + 1 then
  691.          else
  692.             Map1Y = Map1Y + 1
  693.          end
  694.       end
  695.    end
  696.    if key == A then
  697.       if selectedMap == "Map1" then
  698.          if Map1maxX[2] == Map1X - 1 then
  699.          else
  700.             Map1X = Map1X - 1
  701.          end
  702.       elseif selectedMap == "House1" then
  703.          if House1X == -8 and House1Y == -4 then
  704.               House1X = House1X - 2
  705.          elseif House1X == -10 and House1Y == -4 then
  706.               House1X = House1X - 2
  707.          else
  708.              if House1maxX[2] == House1X - 1 then
  709.              else
  710.                 House1X = House1X - 1
  711.              end
  712.            end
  713.       elseif selectedMap == "Map2" then
  714.          if Map2maxX[2] == Map2X - 1 then
  715.             if Map2X == -12 and Map2Y == 1 then
  716.                Map2X = Map2X - 1
  717.             end
  718.          else
  719.             Map2X = Map2X - 1
  720.          end
  721.       else
  722.          selectedMap = "Map1"
  723.          if Map1maxX[2] == Map1X - 1 then
  724.          else
  725.             Map1X = Map1X - 1
  726.          end
  727.       end
  728.    end
  729.    if key == D then
  730.       if selectedMap == "Map1" then
  731.          if Map1maxX[1] == Map1X + 1 then
  732.             if Map1X == 12 and Map1Y == 1 then
  733.                Map1X = Map1X + 1
  734.             end
  735.          else
  736.             Map1X = Map1X + 1
  737.          end
  738.       elseif selectedMap == "House1" then
  739.            if House1X == -12 and House1Y == -4 then
  740.               House1X = House1X + 2
  741.            elseif House1X == -10 and House1Y == -4 then
  742.               House1X = House1X + 2
  743.            else
  744.               if House1maxX[1] == House1X + 1 then
  745.               else
  746.                  House1X = House1X + 1
  747.               end
  748.            end
  749.       elseif selectedMap == "Map2" then
  750.          if Map2maxX[1] == Map2X + 1 then
  751.             if Map2X == 12 and Map2Y == 1 then
  752.                Map2X = Map2X + 1
  753.             end
  754.          else
  755.             Map2X = Map2X + 1
  756.          end
  757.       else
  758.          selectedMap = "Map1"
  759.          if Map1maxX[1] == Map1X + 1 then
  760.          else
  761.             Map1X = Map1X + 1
  762.          end
  763.       end
  764.    end
  765. end
  766.  
  767. function LoadSteps()
  768.     if fs.exists("Map1X") then
  769.        file = io.open("Map1X", "r")
  770.        Map1X = tonumber(file:read())
  771.        file:close()
  772.     end
  773.    
  774.     if fs.exists("Map1Y") then
  775.        file = io.open("Map1Y", "r")
  776.        Map1Y = tonumber(file:read())
  777.        file:close()
  778.     end
  779.    
  780.     if fs.exists("House1X") then
  781.        file = io.open("House1X", "r")
  782.        House1X = tonumber(file:read())
  783.        file:close()
  784.     end
  785.    
  786.     if fs.exists("House1Y") then
  787.        file = io.open("House1Y", "r")
  788.        House1Y = tonumber(file:read())
  789.        file:close()
  790.     end
  791.    
  792.     if fs.exists("selectedMap") then
  793.        file = io.open("selectedMap", "r")
  794.        selectedMap = file:read()
  795.        file:close()
  796.     end
  797.    
  798.     if fs.exists("Money") then
  799.        file = io.open("Money", "r")
  800.        Money = tonumber(file:read())
  801.        file:close()
  802.     end
  803.    
  804.     if fs.exists("Username") then
  805.        file = io.open("Username", "r")
  806.        Username = file:read()
  807.        file:close()
  808.     end
  809.    
  810.     if fs.exists("HP") then
  811.        file = io.open("HP", "r")
  812.        HP = tonumber(file:read())
  813.        file:close()
  814.     end
  815.    
  816.     if fs.exists("Map2X") then
  817.        file = io.open("Map2X", "r")
  818.        Map2X = tonumber(file:read())
  819.        file:close()
  820.     end
  821.    
  822.     if fs.exists("Map2Y") then
  823.        file = io.open("Map2Y", "r")
  824.        Map2Y = tonumber(file:read())
  825.        file:close()
  826.     end
  827.    
  828.     if fs.exists("MainMenuY") then
  829.        file = io.open("MainMenuY", "r")
  830.        MainMenuY = tonumber(file:read())
  831.        file:close()
  832.     end
  833.    
  834.     if fs.exists("showMainMenu") then
  835.        file = io.open("showMainMenu", "r")
  836.        showMainMenu = file:read()
  837.        file:close()
  838.     end
  839.    
  840. end
  841.  
  842. function SaveSteps()
  843.        file = io.open("Map1X", "w")
  844.        file:write(tostring(Map1X))
  845.        file:close()
  846.    
  847.        file = io.open("Map1Y", "w")
  848.        file:write(tostring(Map1Y))
  849.        file:close()
  850.        
  851.        file = io.open("Map2X", "w")
  852.        file:write(tostring(Map2X))
  853.        file:close()
  854.    
  855.        file = io.open("Map2Y", "w")
  856.        file:write(tostring(Map2Y))
  857.        file:close()
  858.  
  859.        file = io.open("House1X", "w")
  860.        file:write(tostring(House1X))
  861.        file:close()
  862.    
  863.        file = io.open("House1Y", "w")
  864.        file:write(tostring(House1Y))
  865.        file:close()
  866.  
  867.     file = io.open("selectedMap", "w")
  868.     file:write(selectedMap)
  869.     file:close()
  870.    
  871.     file = io.open("Money", "w")
  872.     file:write(tostring(Money))
  873.     file:close()
  874.    
  875.     file = io.open("HP", "w")
  876.     file:write(tostring(HP))
  877.     file:close()
  878.    
  879.     file = io.open("MainMenuY", "w")
  880.     file:write(tostring(MainMenuY))
  881.     file:close()
  882.    
  883.     file = io.open("showMainMenu", "w")
  884.     file:write(showMainMenu)
  885.     file:close()
  886.    
  887.    if Remaining == 0 then
  888.    -- os.reboot() -- Laggy, but never crashes
  889.    os.reboot()
  890.    end
  891. end
  892.  
  893. loadWithCords()
  894. LoadSteps()
  895. GetSteps()
  896. CurrentMap()
  897. giveMessage()
  898.    term.setCursorPos(1,1)
  899.    if ShowCords == true then
  900.       if selectedMap == "Map1" then
  901.          print("Cords: X: ",Map1X," Y: ",Map1Y)
  902.       elseif selectedMap == "Map2" then
  903.          print("Cords: X: ",Map2X," Y: ",Map2Y)
  904.       elseif selectedMap == "House1" then
  905.          print("Cords: X: ",House1X," Y: ",House1Y)
  906.       else
  907.          print("Cords: X: ",Map1X," Y: ",Map1Y)
  908.       end
  909.    end
  910.    if ShowStepsReboot == true then
  911.       term.setCursorPos(1,18)
  912.       print(Remaining," steps remaining until reboot")
  913.    end
  914.    term.setCursorPos(1,19)
  915. if showMainMenu == "true" then
  916.       mainMenu()
  917.    else
  918.       if HP == 0 then
  919.          deathMessage()
  920.       else
  921.          StartUp()
  922.       end
  923.    end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement