Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c="{\
- MBC = \"os.loadAPI(\\\"gui\\\")\\\
- \\\
- commandComputer = 32\\\
- modemSide = \\\"top\\\"\\\
- \\\
- rednet.open(modemSide)\\\
- \\\
- gui.clear()\\\
- print(\\\"LOG IN (THIS WILL BE BETTER LATER)\\\")\\\
- print()\\\
- term.write(\\\"Username: \\\")\\\
- username = read()\\\
- term.write(\\\"Password: \\\")\\\
- password = read(\\\"*\\\")\\\
- \\\
- rednet.send(commandComputer,{\\\"log_in\\\",username,password})\\\
- id,msg,d = rednet.receive(1)\\\
- \\\
- if id ~= commandComputer or msg == nil then\\\
- gui.clear()\\\
- print(\\\"LOG IN FAILED\\\")\\\
- return\\\
- end\\\
- \\\
- currentUser = msg\\\
- \\\
- while true do\\\
- term.setBackgroundColor(colors.lightGray)\\\
- term.setTextColor(colors.black)\\\
- gui.clear()\\\
- print(\\\"Welcome \\\"..currentUser[1]..\\\": $\\\"..currentUser[2])\\\
- \\\
- term.setBackgroundColor(colors.gray)\\\
- beds = gui.newButton(2,3,6,3,\\\"beds\\\",colors.gray)\\\
- term.setCursorPos(3,4)\\\
- term.write(\\\"Beds\\\")\\\
- \\\
- doors = gui.newButton(2,7,7,3,\\\"doors\\\",colors.gray)\\\
- term.setCursorPos(3,8)\\\
- term.write(\\\"Doors\\\")\\\
- \\\
- upgrades = gui.newButton(2,11,10,3,\\\"upgrades\\\",colors.gray)\\\
- term.setCursorPos(3,12)\\\
- term.write(\\\"Upgrades\\\")\\\
- \\\
- security = gui.newButton(2,15,10,3,\\\"infiltrate\\\",colors.gray)\\\
- term.setCursorPos(3,16)\\\
- term.write(\\\"Security\\\")\\\
- \\\
- logOut = gui.newButton(12,3,9,3,\\\"log_out\\\",colors.gray)\\\
- term.setCursorPos(13,4)\\\
- term.write(\\\"Log Out\\\")\\\
- \\\
- choice = gui.waitForButtons(logOut,security,beds, doors, upgrades)\\\
- if choice == \\\"beds\\\" then\\\
- while true do\\\
- rednet.send(commandComputer, {currentUser,{\\\"get_beds\\\"}})\\\
- id,msg,d = rednet.receive(.5)\\\
- if id == commandComputer then\\\
- printArray = {}\\\
- \\\
- table.insert(printArray,\\\"BACK\\\")\\\
- for i,v in ipairs(msg) do\\\
- table.insert(printArray,v[1]..\\\":\\\"..tostring(v[2]))\\\
- end\\\
- \\\
- term.setBackgroundColor(colors.lightGray)\\\
- gui.clear()\\\
- print(\\\"Beds: Click to change state\\\")\\\
- \\\
- term.setBackgroundColor(colors.gray)\\\
- choice = gui.drawArray(printArray)\\\
- \\\
- if choice ~= 1 and choice ~= nil then\\\
- rednet.send(commandComputer,{currentUser,{\\\"change_bed\\\",msg[choice-1][1]}})\\\
- sleep(.2)\\\
- elseif choice ~= nil then\\\
- break\\\
- end\\\
- else\\\
- break\\\
- end\\\
- end\\\
- elseif choice == \\\"log_out\\\" then\\\
- currentUser = {}\\\
- term.setBackgroundColor(colors.black)\\\
- gui.clear()\\\
- break\\\
- elseif choice == \\\"doors\\\" then\\\
- while true do\\\
- sleep(.2)\\\
- rednet.send(commandComputer,{currentUser,{\\\"get_doors\\\"}})\\\
- id,msg,d = rednet.receive(.3)\\\
- if id == commandComputer then\\\
- printArray = {}\\\
- \\\
- table.insert(printArray,\\\"BACK\\\")\\\
- for i,v in ipairs(msg) do\\\
- table.insert(printArray,v[3]..\\\":\\\"..v[2])\\\
- end\\\
- \\\
- term.setBackgroundColor(colors.lightGray)\\\
- gui.clear()\\\
- print(\\\"Doors: click to change state\\\")\\\
- \\\
- term.setBackgroundColor(colors.gray)\\\
- choice = gui.drawArray(printArray)\\\
- \\\
- if choice ~= 1 and choice ~= nil then\\\
- rednet.send(commandComputer,{currentUser,{\\\"change_door\\\",msg[choice-1][3]}})\\\
- sleep(.2)\\\
- elseif choice ~= nil then\\\
- break\\\
- end\\\
- else\\\
- break\\\
- end\\\
- end\\\
- elseif choice == \\\"upgrades\\\" then\\\
- while true do\\\
- rednet.send(commandComputer,{currentUser,{\\\"get_upgrades\\\"}})\\\
- id,msg,d = rednet.receive(.3)\\\
- if id == commandComputer then\\\
- printArray = {}\\\
- \\\
- table.insert(printArray,\\\"BACK\\\")\\\
- for i,v in ipairs(msg) do\\\
- table.insert(printArray,v[1]..\\\": $\\\"..v[2])\\\
- end\\\
- \\\
- term.setBackgroundColor(colors.lightGray)\\\
- gui.clear()\\\
- print(\\\"Available Upgrades: Click to buy\\\")\\\
- print(\\\"You have $\\\"..currentUser[2])\\\
- \\\
- term.setBackgroundColor(colors.gray)\\\
- choice = gui.drawArray(printArray)\\\
- \\\
- if choice ~= nil and choice ~= 1 then\\\
- if currency >= msg[choice-1][2] then\\\
- currency = currency-msg[choice-1][2]\\\
- rednet.send(commandComputer,{currentUser,{\\\"buy_upgrade\\\",msg[choice-1][1]}})\\\
- end\\\
- elseif choice ~= nil then\\\
- break\\\
- end\\\
- else\\\
- break\\\
- end\\\
- end\\\
- elseif choice == \\\"infiltrate\\\" then\\\
- term.setBackgroundColor(colors.lightGray)\\\
- rednet.send(commandComputer,{currentUser,{\\\"infiltrate_request\\\"}})\\\
- id,msg,d = rednet.receive(.3)\\\
- if msg ~= nil and id == commandComputer then\\\
- while true do\\\
- gui.clear()\\\
- textutils.slowPrint(\\\"RUNNING MALICIOUS CODE....\\\")\\\
- print(\\\"SERVER INFILTRATED\\\")\\\
- print(\\\"LOG IN TO REPLACE CONTROLLER\\\")\\\
- print()\\\
- term.write(\\\"Username: \\\")\\\
- username = read()\\\
- term.write(\\\"Password: \\\")\\\
- password = read(\\\"*\\\")\\\
- gui.clear()\\\
- hackID = \\\"\\\"\\\
- print(\\\"ENTER ATTACK DISK\\\")\\\
- while true do\\\
- e,p1 = os.pullEvent()\\\
- if e == \\\"disk\\\" then\\\
- if fs.exists(\\\"disk/hackID\\\") then\\\
- file = fs.open(\\\"disk/hackID\\\",\\\"r\\\")\\\
- hackID = file.readAll()\\\
- file.close()\\\
- break\\\
- end\\\
- end\\\
- end\\\
- rednet.send(commandComputer,{currentUser,{\\\"infiltrate\\\",username,password,hackID}})\\\
- id,msg,d = rednet.receive(1)\\\
- if msg ~= nil and msg then\\\
- print()\\\
- textutils.slowPrint(\\\"SUCCESS...\\\")\\\
- textutils.slowPrint(\\\"YOU ARE NOW IN CONTROL OF THIS FORT\\\")\\\
- print()\\\
- sleep(1)\\\
- os.reboot()\\\
- else\\\
- print()\\\
- print(\\\"HACK FAILED\\\")\\\
- print(\\\"PRESS ENTER\\\")\\\
- read()\\\
- break\\\
- end\\\
- end\\\
- else\\\
- gui.clear()\\\
- print(\\\"Server secure\\\")\\\
- print(\\\"Press enter\\\")\\\
- read()\\\
- end\\\
- end\\\
- end\",\
- gui = \"--finds the click area of a new button\\\
- local function findClickArea(x,y,w,h)\\\
- xs = {}\\\
- ys = {}\\\
- \\\
- i = 0\\\
- while i < w do\\\
- table.insert(xs, x + i)\\\
- i = i + 1\\\
- end\\\
- \\\
- i = 0\\\
- while i < h do\\\
- table.insert(ys, y + i)\\\
- i = i + 1\\\
- end\\\
- \\\
- return {xs, ys}\\\
- end\\\
- \\\
- --clears the display\\\
- function clear(display)\\\
- if display == nil then\\\
- term.clear()\\\
- term.setCursorPos(1,1)\\\
- else\\\
- screen = {}\\\
- screen = display\\\
- screen.clear()\\\
- screen.setCursorPos(1,1)\\\
- end\\\
- end\\\
- \\\
- --this is an advanced read function\\\
- function inputField(x,y,text,maxL,bgColor,character)\\\
- prevBGColor = term.getBackgroundColor()\\\
- term.setCursorBlink(true)\\\
- term.setBackgroundColor(bgColor)\\\
- \\\
- pText = \\\"\\\"\\\
- \\\
- while true do\\\
- if string.len(text) > maxL then\\\
- pText = string.sub(text,-maxL)\\\
- else\\\
- pText = text\\\
- end\\\
- \\\
- term.setCursorPos(x,y)\\\
- i = 0\\\
- while i < maxL do\\\
- term.write(\\\" \\\")\\\
- i = i + 1\\\
- end\\\
- term.setCursorPos(x,y)\\\
- if character == nil then\\\
- term.write(pText)\\\
- else\\\
- i = 0\\\
- while i < string.len(pText) do\\\
- term.write(character)\\\
- i= i+1\\\
- end\\\
- end\\\
- \\\
- e, p1 = os.pullEvent()\\\
- \\\
- if e == \\\"char\\\" then\\\
- text = text..p1\\\
- elseif e == \\\"key\\\" then\\\
- if p1 == 14 then\\\
- text = string.sub(text,1,-2)\\\
- elseif p1 == 28 then\\\
- break\\\
- end\\\
- elseif e == \\\"mouse_click\\\" then\\\
- break\\\
- end\\\
- end\\\
- \\\
- term.setCursorBlink(false)\\\
- term.setBackgroundColor(prevBGColor)\\\
- return text\\\
- end\\\
- \\\
- --creates and draws a button object on the screen\\\
- function newButton(x,y,w,h,title,color,display)\\\
- \\\
- prevBGColor = term.getBackgroundColor()\\\
- \\\
- if display == nil then\\\
- screen = term\\\
- else\\\
- screen = {}\\\
- screen = display\\\
- end\\\
- \\\
- if color ~= nil then\\\
- screen.setBackgroundColor(color)\\\
- end\\\
- \\\
- i = 0\\\
- while i < w do\\\
- i2 = 0\\\
- while i2 < h do\\\
- screen.setCursorPos(x + i, y + i2)\\\
- screen.write(\\\" \\\")\\\
- i2 = i2 + 1\\\
- end\\\
- i = i + 1\\\
- end\\\
- \\\
- term.setBackgroundColor(prevBGColor)\\\
- return {findClickArea(x,y,w,h), title}\\\
- end\\\
- \\\
- --changes state of clickBox\\\
- function changeClickBoxState(clickBox)\\\
- state = clickBox[3]\\\
- state = not state\\\
- clickBox[3] = state\\\
- term.setCursorPos(clickBox[4][1],clickBox[4][2])\\\
- prevColor = term.getTextColor()\\\
- prevBGColor = term.getBackgroundColor()\\\
- term.setBackgroundColor(clickBox[5])\\\
- term.setTextColor(colors.red)\\\
- if state then\\\
- term.write(\\\"O\\\")\\\
- else\\\
- term.write(\\\" \\\")\\\
- end\\\
- term.setBackgroundColor(prevBGColor)\\\
- term.setTextColor(prevColor)\\\
- end\\\
- \\\
- --returns the value of a clickBox\\\
- function getClickBoxState(clickBox)\\\
- return clickBox[3]\\\
- end\\\
- \\\
- --creates a click box that is like a toggle button\\\
- function createClickBox(x,y,color,defaultState,display)\\\
- box = newButton(x,y,1,1,\\\"!check_box!\\\",color,display)\\\
- prevColor = term.getTextColor()\\\
- prevBGColor = term.getBackgroundColor()\\\
- term.setTextColor(colors.red)\\\
- if defaultState then\\\
- term.setCursorPos(x,y)\\\
- term.write(\\\"O\\\")\\\
- end\\\
- term.setTextColor(prevColor)\\\
- term.setBackgroundColor(prevBGColor)\\\
- table.insert(box,defaultState)\\\
- table.insert(box, {x,y})\\\
- table.insert(box, color)\\\
- \\\
- \\\
- return box\\\
- end\\\
- \\\
- --waits for button events\\\
- function waitForButtons(...)\\\
- local buttons = {}\\\
- buttons = {...}\\\
- \\\
- while true do\\\
- e,p1,p2,p3 = os.pullEvent()\\\
- \\\
- if e == \\\"mouse_click\\\" then\\\
- for i,v in ipairs(buttons) do\\\
- if checkIn2DArray(p2,p3,v[1]) then\\\
- if v[2] == \\\"!check_box!\\\" then\\\
- changeClickBoxState(v)\\\
- end\\\
- return v[2]\\\
- end\\\
- end\\\
- \\\
- return \\\"NO_BUTTON\\\"\\\
- end\\\
- end\\\
- end\\\
- \\\
- --checks for an object in an array\\\
- function checkInArray(x,a)\\\
- for i,v in ipairs(a) do\\\
- if v == x then\\\
- return v\\\
- end\\\
- end\\\
- \\\
- return nil\\\
- end\\\
- \\\
- --checks for objects in a 2 dimensional array\\\
- function checkIn2DArray(x,y,a)\\\
- area = {}\\\
- area = a\\\
- \\\
- xFound = false\\\
- yFound = false\\\
- \\\
- if checkInArray(x,area[1]) == nil then\\\
- return false\\\
- end\\\
- \\\
- if checkInArray(y,area[2]) == nil then\\\
- return false\\\
- end\\\
- \\\
- return true\\\
- end\\\
- \\\
- --draws an array of buttons with the text in the array a and waits for user input\\\
- function drawArray(a,startY,fixedW)\\\
- --prevColor = term.getTextColor()\\\
- --prevBGColor = term.getBackgroundColor()\\\
- if a == nil then\\\
- error(\\\"The array is nil\\\")\\\
- end\\\
- \\\
- tab = {}\\\
- tab = a\\\
- \\\
- pages = 1\\\
- \\\
- curPage = 1\\\
- \\\
- bPoint = 1\\\
- \\\
- if fixedW == nil then\\\
- w,h = term.getSize()\\\
- else\\\
- _,h = term.getSize()\\\
- w = fixedW\\\
- end\\\
- \\\
- if tab[1] ~= nil then\\\
- \\\
- --term.setBackgroundColor(colors.white)\\\
- --term.setTextColor(colors.black)\\\
- \\\
- \\\
- x = 3\\\
- if startY == nil then\\\
- y = 3\\\
- else\\\
- y = startY\\\
- end\\\
- \\\
- areas = {}\\\
- items = {}\\\
- \\\
- for i,v in ipairs(tab) do\\\
- if v == \\\".DS_Store\\\" then\\\
- table.remove(tab, i)\\\
- end\\\
- end\\\
- \\\
- for i,v in ipairs(tab) do\\\
- if x + string.len(v) + 2 > 49 then\\\
- x = 3\\\
- y = y + 2\\\
- end\\\
- \\\
- newButton(x,y,string.len(v) + 2, 1, colors.white)\\\
- term.setCursorPos(x+1, y)\\\
- --term.setBackgroundColor(colors.white)\\\
- --term.setTextColor(colors.black)\\\
- term.write(v)\\\
- \\\
- table.insert(areas, findClickArea(x,y,string.len(v) + 2, 1))\\\
- \\\
- if x > w-2 then\\\
- x = 3\\\
- y = y + 2\\\
- else\\\
- x = x + string.len(v) + 3\\\
- end\\\
- \\\
- end\\\
- \\\
- for i,v in ipairs(tab) do\\\
- table.insert(items, {v, areas[i]})\\\
- end\\\
- \\\
- --term.setTextColor(prevColor)\\\
- \\\
- --term.setBackgroundColor(prevBGColor)\\\
- \\\
- while true do\\\
- e,p1,p2,p3 = os.pullEvent()\\\
- \\\
- if e == \\\"mouse_click\\\" and p1 == 1 then\\\
- for i,v in ipairs(items) do\\\
- if checkIn2DArray(p2,p3,v[2]) then\\\
- return i\\\
- end\\\
- end\\\
- return\\\
- end\\\
- end\\\
- \\\
- end\\\
- end\",\
- }"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