Advertisement
Guest User

package

a guest
Jun 18th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.93 KB | None | 0 0
  1. local c="{\
  2.  MBC = \"os.loadAPI(\\\"gui\\\")\\\
  3. \\\
  4. commandComputer = 32\\\
  5. modemSide = \\\"top\\\"\\\
  6. \\\
  7. rednet.open(modemSide)\\\
  8. \\\
  9. gui.clear()\\\
  10. print(\\\"LOG IN (THIS WILL BE BETTER LATER)\\\")\\\
  11. print()\\\
  12. term.write(\\\"Username: \\\")\\\
  13. username = read()\\\
  14. term.write(\\\"Password: \\\")\\\
  15. password = read(\\\"*\\\")\\\
  16. \\\
  17. rednet.send(commandComputer,{\\\"log_in\\\",username,password})\\\
  18. id,msg,d = rednet.receive(1)\\\
  19. \\\
  20. if id ~= commandComputer or msg == nil then\\\
  21.  gui.clear()\\\
  22.  print(\\\"LOG IN FAILED\\\")\\\
  23.  return\\\
  24. end\\\
  25. \\\
  26. currentUser = msg\\\
  27. \\\
  28. while true do\\\
  29.  term.setBackgroundColor(colors.lightGray)\\\
  30.  term.setTextColor(colors.black)\\\
  31.  gui.clear()\\\
  32.  print(\\\"Welcome \\\"..currentUser[1]..\\\": $\\\"..currentUser[2])\\\
  33.  \\\
  34.  term.setBackgroundColor(colors.gray)\\\
  35.  beds = gui.newButton(2,3,6,3,\\\"beds\\\",colors.gray)\\\
  36.  term.setCursorPos(3,4)\\\
  37.  term.write(\\\"Beds\\\")\\\
  38.  \\\
  39.  doors = gui.newButton(2,7,7,3,\\\"doors\\\",colors.gray)\\\
  40.  term.setCursorPos(3,8)\\\
  41.  term.write(\\\"Doors\\\")\\\
  42.  \\\
  43.  upgrades = gui.newButton(2,11,10,3,\\\"upgrades\\\",colors.gray)\\\
  44.  term.setCursorPos(3,12)\\\
  45.  term.write(\\\"Upgrades\\\")\\\
  46.  \\\
  47.  security = gui.newButton(2,15,10,3,\\\"infiltrate\\\",colors.gray)\\\
  48.  term.setCursorPos(3,16)\\\
  49.  term.write(\\\"Security\\\")\\\
  50.  \\\
  51.  logOut = gui.newButton(12,3,9,3,\\\"log_out\\\",colors.gray)\\\
  52.  term.setCursorPos(13,4)\\\
  53.  term.write(\\\"Log Out\\\")\\\
  54.  \\\
  55.  choice = gui.waitForButtons(logOut,security,beds, doors, upgrades)\\\
  56.  if choice == \\\"beds\\\" then\\\
  57.    while true do\\\
  58.      rednet.send(commandComputer, {currentUser,{\\\"get_beds\\\"}})\\\
  59.      id,msg,d = rednet.receive(.5)\\\
  60.      if id == commandComputer then\\\
  61.        printArray = {}\\\
  62.    \\\
  63.        table.insert(printArray,\\\"BACK\\\")\\\
  64.        for i,v in ipairs(msg) do\\\
  65.          table.insert(printArray,v[1]..\\\":\\\"..tostring(v[2]))\\\
  66.        end\\\
  67.        \\\
  68.        term.setBackgroundColor(colors.lightGray)\\\
  69.        gui.clear()\\\
  70.        print(\\\"Beds: Click to change state\\\")\\\
  71.        \\\
  72.        term.setBackgroundColor(colors.gray)\\\
  73.        choice = gui.drawArray(printArray)\\\
  74.        \\\
  75.        if choice ~= 1 and choice ~= nil then\\\
  76.          rednet.send(commandComputer,{currentUser,{\\\"change_bed\\\",msg[choice-1][1]}})\\\
  77.          sleep(.2)\\\
  78.        elseif choice ~= nil then\\\
  79.          break\\\
  80.        end\\\
  81.      else\\\
  82.        break\\\
  83.      end\\\
  84.    end\\\
  85.  elseif choice == \\\"log_out\\\" then\\\
  86.    currentUser = {}\\\
  87.    term.setBackgroundColor(colors.black)\\\
  88.    gui.clear()\\\
  89.    break\\\
  90.  elseif choice == \\\"doors\\\" then\\\
  91.    while true do\\\
  92.      sleep(.2)\\\
  93.      rednet.send(commandComputer,{currentUser,{\\\"get_doors\\\"}})\\\
  94.      id,msg,d = rednet.receive(.3)\\\
  95.      if id == commandComputer then\\\
  96.        printArray = {}\\\
  97.        \\\
  98.        table.insert(printArray,\\\"BACK\\\")\\\
  99.        for i,v in ipairs(msg) do\\\
  100.          table.insert(printArray,v[3]..\\\":\\\"..v[2])\\\
  101.        end\\\
  102.        \\\
  103.        term.setBackgroundColor(colors.lightGray)\\\
  104.        gui.clear()\\\
  105.        print(\\\"Doors: click to change state\\\")\\\
  106.        \\\
  107.        term.setBackgroundColor(colors.gray)\\\
  108.        choice = gui.drawArray(printArray)\\\
  109.        \\\
  110.        if choice ~= 1 and choice ~= nil then\\\
  111.          rednet.send(commandComputer,{currentUser,{\\\"change_door\\\",msg[choice-1][3]}})\\\
  112.          sleep(.2)\\\
  113.        elseif choice ~= nil then\\\
  114.          break\\\
  115.        end\\\
  116.      else\\\
  117.        break\\\
  118.      end\\\
  119.    end\\\
  120.  elseif choice == \\\"upgrades\\\" then\\\
  121.    while true do\\\
  122.      rednet.send(commandComputer,{currentUser,{\\\"get_upgrades\\\"}})\\\
  123.      id,msg,d = rednet.receive(.3)\\\
  124.      if id == commandComputer then\\\
  125.        printArray = {}\\\
  126.        \\\
  127.        table.insert(printArray,\\\"BACK\\\")\\\
  128.        for i,v in ipairs(msg) do\\\
  129.          table.insert(printArray,v[1]..\\\": $\\\"..v[2])\\\
  130.        end\\\
  131.        \\\
  132.        term.setBackgroundColor(colors.lightGray)\\\
  133.        gui.clear()\\\
  134.        print(\\\"Available Upgrades: Click to buy\\\")\\\
  135.        print(\\\"You have $\\\"..currentUser[2])\\\
  136.        \\\
  137.        term.setBackgroundColor(colors.gray)\\\
  138.        choice = gui.drawArray(printArray)\\\
  139.        \\\
  140.        if choice ~= nil and choice ~= 1 then\\\
  141.          if currency >= msg[choice-1][2] then\\\
  142.            currency = currency-msg[choice-1][2]\\\
  143.            rednet.send(commandComputer,{currentUser,{\\\"buy_upgrade\\\",msg[choice-1][1]}})\\\
  144.          end\\\
  145.        elseif choice ~= nil then\\\
  146.          break\\\
  147.        end\\\
  148.      else\\\
  149.        break\\\
  150.      end\\\
  151.    end\\\
  152.  elseif choice == \\\"infiltrate\\\" then\\\
  153.    term.setBackgroundColor(colors.lightGray)\\\
  154.    rednet.send(commandComputer,{currentUser,{\\\"infiltrate_request\\\"}})\\\
  155.    id,msg,d = rednet.receive(.3)\\\
  156.    if msg ~= nil and id == commandComputer then\\\
  157.      while true do\\\
  158.        gui.clear()\\\
  159.        textutils.slowPrint(\\\"RUNNING MALICIOUS CODE....\\\")\\\
  160.        print(\\\"SERVER INFILTRATED\\\")\\\
  161.        print(\\\"LOG IN TO REPLACE CONTROLLER\\\")\\\
  162.        print()\\\
  163.        term.write(\\\"Username: \\\")\\\
  164.        username = read()\\\
  165.        term.write(\\\"Password: \\\")\\\
  166.        password = read(\\\"*\\\")\\\
  167.        gui.clear()\\\
  168.        hackID = \\\"\\\"\\\
  169.        print(\\\"ENTER ATTACK DISK\\\")\\\
  170.        while true do\\\
  171.          e,p1 = os.pullEvent()\\\
  172.          if e == \\\"disk\\\" then\\\
  173.            if fs.exists(\\\"disk/hackID\\\") then\\\
  174.              file = fs.open(\\\"disk/hackID\\\",\\\"r\\\")\\\
  175.              hackID = file.readAll()\\\
  176.              file.close()\\\
  177.              break\\\
  178.            end\\\
  179.          end\\\
  180.        end\\\
  181.        rednet.send(commandComputer,{currentUser,{\\\"infiltrate\\\",username,password,hackID}})\\\
  182.        id,msg,d = rednet.receive(1)\\\
  183.        if msg ~= nil and msg then\\\
  184.          print()\\\
  185.          textutils.slowPrint(\\\"SUCCESS...\\\")\\\
  186.          textutils.slowPrint(\\\"YOU ARE NOW IN CONTROL OF THIS FORT\\\")\\\
  187.          print()\\\
  188.          sleep(1)\\\
  189.          os.reboot()\\\
  190.        else\\\
  191.          print()\\\
  192.          print(\\\"HACK FAILED\\\")\\\
  193.          print(\\\"PRESS ENTER\\\")\\\
  194.          read()\\\
  195.          break\\\
  196.        end\\\
  197.      end\\\
  198.    else\\\
  199.      gui.clear()\\\
  200.      print(\\\"Server secure\\\")\\\
  201.      print(\\\"Press enter\\\")\\\
  202.      read()\\\
  203.    end\\\
  204.  end\\\
  205. end\",\
  206.  gui = \"--finds the click area of a new button\\\
  207. local function findClickArea(x,y,w,h)\\\
  208.  xs = {}\\\
  209.  ys = {}\\\
  210. \\\
  211.  i = 0\\\
  212.  while i < w do\\\
  213.    table.insert(xs, x + i)\\\
  214.    i = i + 1\\\
  215.  end\\\
  216.  \\\
  217.  i = 0\\\
  218.  while i < h do\\\
  219.    table.insert(ys, y + i)\\\
  220.    i = i + 1\\\
  221.  end\\\
  222. \\\
  223.  return {xs, ys}\\\
  224. end\\\
  225. \\\
  226. --clears the display\\\
  227. function clear(display)\\\
  228.  if display == nil then\\\
  229.    term.clear()\\\
  230.    term.setCursorPos(1,1)\\\
  231.  else\\\
  232.    screen = {}\\\
  233.    screen = display\\\
  234.    screen.clear()\\\
  235.    screen.setCursorPos(1,1)\\\
  236.  end\\\
  237. end\\\
  238. \\\
  239. --this is an advanced read function\\\
  240. function inputField(x,y,text,maxL,bgColor,character)\\\
  241.  prevBGColor = term.getBackgroundColor()\\\
  242.  term.setCursorBlink(true)\\\
  243.  term.setBackgroundColor(bgColor)\\\
  244.  \\\
  245.  pText = \\\"\\\"\\\
  246. \\\
  247.  while true do\\\
  248.    if string.len(text) > maxL then\\\
  249.      pText = string.sub(text,-maxL)\\\
  250.    else\\\
  251.      pText = text\\\
  252.    end\\\
  253.    \\\
  254.    term.setCursorPos(x,y)\\\
  255.    i = 0\\\
  256.    while i < maxL do\\\
  257.      term.write(\\\" \\\")\\\
  258.      i = i + 1\\\
  259.    end\\\
  260.    term.setCursorPos(x,y)\\\
  261.    if character == nil then\\\
  262.         term.write(pText)\\\
  263.     else\\\
  264.         i = 0\\\
  265.         while i < string.len(pText) do\\\
  266.             term.write(character)\\\
  267.             i= i+1\\\
  268.         end\\\
  269.     end\\\
  270.    \\\
  271.    e, p1 = os.pullEvent()\\\
  272.    \\\
  273.    if e == \\\"char\\\" then\\\
  274.      text = text..p1\\\
  275.    elseif e == \\\"key\\\" then\\\
  276.      if p1 == 14 then\\\
  277.        text = string.sub(text,1,-2)\\\
  278.      elseif p1 == 28 then\\\
  279.        break\\\
  280.      end\\\
  281.    elseif e == \\\"mouse_click\\\" then\\\
  282.      break\\\
  283.    end\\\
  284.  end\\\
  285.  \\\
  286.  term.setCursorBlink(false)\\\
  287.  term.setBackgroundColor(prevBGColor)\\\
  288.  return text\\\
  289. end\\\
  290. \\\
  291. --creates and draws a button object on the screen\\\
  292. function newButton(x,y,w,h,title,color,display)\\\
  293. \\\
  294.  prevBGColor = term.getBackgroundColor()\\\
  295. \\\
  296.  if display == nil then\\\
  297.    screen = term\\\
  298.  else\\\
  299.    screen = {}\\\
  300.    screen = display\\\
  301.  end\\\
  302. \\\
  303.  if color ~= nil then\\\
  304.       screen.setBackgroundColor(color)\\\
  305.  end\\\
  306. \\\
  307.  i = 0\\\
  308.  while i < w do\\\
  309.    i2 = 0\\\
  310.    while i2 < h do\\\
  311.      screen.setCursorPos(x + i, y + i2)\\\
  312.      screen.write(\\\" \\\")\\\
  313.      i2 = i2 + 1\\\
  314.    end\\\
  315.    i = i + 1\\\
  316.  end\\\
  317. \\\
  318.  term.setBackgroundColor(prevBGColor)\\\
  319.  return {findClickArea(x,y,w,h), title}\\\
  320. end\\\
  321. \\\
  322. --changes state of clickBox\\\
  323. function changeClickBoxState(clickBox)\\\
  324.  state = clickBox[3]\\\
  325.  state = not state\\\
  326.  clickBox[3] = state\\\
  327.  term.setCursorPos(clickBox[4][1],clickBox[4][2])\\\
  328.  prevColor = term.getTextColor()\\\
  329.  prevBGColor = term.getBackgroundColor()\\\
  330.  term.setBackgroundColor(clickBox[5])\\\
  331.  term.setTextColor(colors.red)\\\
  332.  if state then\\\
  333.    term.write(\\\"O\\\")\\\
  334.  else\\\
  335.    term.write(\\\" \\\")\\\
  336.  end\\\
  337.  term.setBackgroundColor(prevBGColor)\\\
  338.  term.setTextColor(prevColor)\\\
  339. end\\\
  340. \\\
  341. --returns the value of a clickBox\\\
  342. function getClickBoxState(clickBox)\\\
  343.  return clickBox[3]\\\
  344. end\\\
  345. \\\
  346. --creates a click box that is like a toggle button\\\
  347. function createClickBox(x,y,color,defaultState,display)\\\
  348.  box = newButton(x,y,1,1,\\\"!check_box!\\\",color,display)\\\
  349.  prevColor = term.getTextColor()\\\
  350.  prevBGColor = term.getBackgroundColor()\\\
  351.  term.setTextColor(colors.red)\\\
  352.  if defaultState then\\\
  353.    term.setCursorPos(x,y)\\\
  354.    term.write(\\\"O\\\")\\\
  355.  end\\\
  356.  term.setTextColor(prevColor)\\\
  357.  term.setBackgroundColor(prevBGColor)\\\
  358.  table.insert(box,defaultState)\\\
  359.  table.insert(box, {x,y})\\\
  360.  table.insert(box, color)\\\
  361.  \\\
  362.  \\\
  363.  return box\\\
  364. end\\\
  365. \\\
  366. --waits for button events\\\
  367. function waitForButtons(...)\\\
  368.     local buttons = {}\\\
  369.     buttons = {...}\\\
  370. \\\
  371.     while true do\\\
  372.         e,p1,p2,p3 = os.pullEvent()\\\
  373. \\\
  374.         if e == \\\"mouse_click\\\" then\\\
  375.             for i,v in ipairs(buttons) do\\\
  376.                 if checkIn2DArray(p2,p3,v[1]) then\\\
  377.     if v[2] == \\\"!check_box!\\\" then\\\
  378.       changeClickBoxState(v)\\\
  379.     end\\\
  380.             return v[2]\\\
  381.                 end\\\
  382.             end\\\
  383. \\\
  384.             return \\\"NO_BUTTON\\\"\\\
  385.         end\\\
  386.     end\\\
  387. end\\\
  388. \\\
  389. --checks for an object in an array\\\
  390. function checkInArray(x,a)\\\
  391.  for i,v in ipairs(a) do\\\
  392.    if v == x then\\\
  393.      return v\\\
  394.    end\\\
  395.  end\\\
  396. \\\
  397.  return nil\\\
  398. end\\\
  399. \\\
  400. --checks for objects in a 2 dimensional array\\\
  401. function checkIn2DArray(x,y,a)\\\
  402.  area = {}\\\
  403.  area = a\\\
  404.  \\\
  405.  xFound = false\\\
  406.  yFound = false\\\
  407.  \\\
  408.  if checkInArray(x,area[1]) == nil then\\\
  409.    return false\\\
  410.  end\\\
  411.  \\\
  412.  if checkInArray(y,area[2]) == nil then\\\
  413.    return false\\\
  414.  end\\\
  415.  \\\
  416.  return true\\\
  417. end\\\
  418. \\\
  419. --draws an array of buttons with the text in the array a and waits for user input\\\
  420. function drawArray(a,startY,fixedW)\\\
  421.  --prevColor = term.getTextColor()\\\
  422.  --prevBGColor = term.getBackgroundColor()\\\
  423.  if a == nil then\\\
  424.     error(\\\"The array is nil\\\")\\\
  425.  end\\\
  426.  \\\
  427.  tab = {}\\\
  428.  tab = a\\\
  429. \\\
  430.  pages = 1\\\
  431. \\\
  432.  curPage = 1\\\
  433. \\\
  434.  bPoint = 1\\\
  435. \\\
  436.  if fixedW == nil then\\\
  437.    w,h = term.getSize()\\\
  438.  else\\\
  439.    _,h = term.getSize()\\\
  440.    w = fixedW\\\
  441.  end\\\
  442.  \\\
  443.  if tab[1] ~= nil then\\\
  444.  \\\
  445.    --term.setBackgroundColor(colors.white)\\\
  446.    --term.setTextColor(colors.black)\\\
  447. \\\
  448.  \\\
  449.    x = 3\\\
  450.    if startY == nil then\\\
  451.      y = 3\\\
  452.    else\\\
  453.      y = startY\\\
  454.    end\\\
  455.  \\\
  456.    areas = {}\\\
  457.    items = {}\\\
  458.  \\\
  459.    for i,v in ipairs(tab) do\\\
  460.      if v == \\\".DS_Store\\\" then\\\
  461.        table.remove(tab, i)\\\
  462.      end\\\
  463.    end\\\
  464.  \\\
  465.    for i,v in ipairs(tab) do\\\
  466.      if x + string.len(v) + 2 > 49 then\\\
  467.        x = 3\\\
  468.        y = y + 2\\\
  469.      end\\\
  470.      \\\
  471.      newButton(x,y,string.len(v) + 2, 1, colors.white)\\\
  472.      term.setCursorPos(x+1, y)\\\
  473.      --term.setBackgroundColor(colors.white)\\\
  474.      --term.setTextColor(colors.black)\\\
  475.      term.write(v)\\\
  476.      \\\
  477.      table.insert(areas, findClickArea(x,y,string.len(v) + 2, 1))\\\
  478.    \\\
  479.      if x > w-2 then\\\
  480.        x = 3\\\
  481.        y = y + 2\\\
  482.      else\\\
  483.        x = x + string.len(v) + 3\\\
  484.      end\\\
  485.    \\\
  486.    end\\\
  487.  \\\
  488.    for i,v in ipairs(tab) do\\\
  489.      table.insert(items, {v, areas[i]})\\\
  490.    end\\\
  491.    \\\
  492.    --term.setTextColor(prevColor)\\\
  493.    \\\
  494.    --term.setBackgroundColor(prevBGColor)\\\
  495. \\\
  496.    while true do\\\
  497.      e,p1,p2,p3 = os.pullEvent()\\\
  498. \\\
  499.      if e == \\\"mouse_click\\\" and p1 == 1 then\\\
  500.        for i,v in ipairs(items) do\\\
  501.          if checkIn2DArray(p2,p3,v[2]) then\\\
  502.            return i\\\
  503.          end\\\
  504.        end\\\
  505.        return\\\
  506.      end\\\
  507.    end\\\
  508.    \\\
  509.  end\\\
  510. end\",\
  511. }"function makeDir(table,dir) if not fs.exists(dir) then fs.makeDir(dir) end for k, v in pairs(table) do if type(v)=='table' then makeDir(v,dir..'/'..k) else local fileH=fs.open(dir..'/'..k,'w') fileH.write(v) fileH.close() end end end tArgs={...} if #tArgs<1 then print('Usage: unpackager <destination>') else makeDir(textutils.unserialize(c),shell.resolve(tArgs[1])) print('Succ: Successfully extracted package') end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement