Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.38 KB | None | 0 0
  1. local pkg = {
  2.   money = "serverid = 0!@#&side = \"left\"!@#&!@#&local account1Name!@#&local account1Pass!@#&local account2Name!@#&local amt!@#&!@#&!@#&function getTransferInfo()!@#& term.clear()!@#&    term.setCursorPos(1,1)!@#&  !@#&    print(\"Account 1 will give the money.\")!@#&   print(\"Account 2 will take the money.\")!@#&   print(\"Both Accounts must provide an account name.\")!@#&  print(\"Account 1 must provide account password. Account 2 does not.\")!@#& print(\"Account 1 name:\")!@#&  account1Name = read()!@#&   print(\"Account 1 Pass\")!@#&   account1Pass = read(\"*\")!@#&  print(\"Account 2 Name\")!@#&   account2Name = read()!@#&   print(\"Amount:\")!@#&  amt = read()!@#&    sendTransferRequest()!@#&end!@#&!@#&function sendTransferRequest()!@#&  getPrefs()!@#&  term.clear()!@#&    term.setCursorPos(1,1)!@#&  rednet.open(side)!@#&   local newemail = \"$SERVERMONEY$MONEY$TRANSFER\"!@#&                 ..\"-\"..account1Name!@#&               ..\"-\"..account1Pass!@#&               ..\"-\"..account2Name!@#&               ..\"-\"..amt!@#&  rednet.send(serverid, newemail)!@#&  rednet.close(side)!@#&  printMenu()!@#&end!@#&!@#&function getPrefs()!@#&  local file = io.open(\"/pref\")!@#&  if not file then!@#&    print(\"pref file not found! Make sure you have run the register program.\")!@#&    return false!@#&  end!@#&  local sidl = file:read()!@#&  sidl = string.gsub(sidl, \"routerid=\", \"\")!@#&  print(sidl)!@#&  sidl = tonumber(sidl)!@#&  if sidl==0 then!@#&    print(\"Client prefs not initialized- check readme for detals.\")!@#&    return false!@#&  end!@#&  serverid = sidl!@#&  sidl = file:read()!@#&  sidl = string.gsub(sidl, \"side=\", \"\")!@#&  side = sidl!@#&  return true!@#&end!@#&getPrefs()!@#&!@#&function getNewAccountInfo()!@#&    term.clear()!@#&    term.setCursorPos(1,1)!@#&  !@#&    print(\"Your account requires a personal name and password.\")!@#&  print(\"Your starting funds will be 0\")!@#&    print(\"To get money, get a job\")!@#&  print(\"Account Name:\")!@#&    account1Name = read()!@#&   print(\"Account Password\")!@#& account1Pass = read()!@#&   sendNewAccountRequest()!@#&end!@#&!@#&function sendNewAccountRequest()!@#&  getPrefs()!@#&  term.clear()!@#&    term.setCursorPos(1,1)!@#&  rednet.open(side)!@#&   local newemail = \"$SERVERMONEY$MONEY$NEWACCOUNT\"!@#&               ..\"-\"..account1Name!@#&               ..\"-\"..account1Pass!@#&  rednet.send(serverid, newemail)!@#&  rednet.close(side)!@#&  printMenu()!@#&end!@#&!@#&function getAccountBalanceInfo()!@#& term.clear()!@#&    term.setCursorPos(1,1)!@#&  !@#&    print(\"Please enter Account Name\")!@#&    account1Name = read()!@#&   sendAccountBalanceRequest()!@#&end!@#&!@#&function sendAccountBalanceRequest()!@#&  getPrefs()!@#&  term.clear()!@#&    term.setCursorPos(1,1)!@#&  rednet.open(side)!@#&   local newemail = \"$SERVERMONEY$MONEY$GETBALANCE\"!@#&               ..\"-\"..account1Name!@#&               ..\"-\"..os.getComputerID()!@#&  rednet.send(serverid, newemail)!@#&   while true do!@#&       event, id, text = os.pullEvent()!@#&        if event == \"rednet_message\" then!@#&         print(\"Current Balance: \"..text..\". Hit Enter at anytime to continue.\")!@#&         read()!@#&          break;!@#&      end!@#& end!@#&  rednet.close(side)!@#&  printMenu()!@#&end!@#&!@#&function printMenu()!@#& term.clear()!@#&    term.setCursorPos(1,1)!@#&  !@#&    print(\"Please select an option...\")!@#&   print(\"1. Transfer funds\")!@#&    print(\"2. Open an account\")!@#&   print(\"3. Get Account Balance\")!@#&   print(\"4. Exit\")!@#&  local cmd = read()!@#&  if cmd == \"1\" then!@#&        getTransferInfo()!@#&   elseif cmd == \"2\" then!@#&        getNewAccountInfo()!@#& elseif cmd == \"3\" then!@#&        getAccountBalanceInfo()!@#& elseif cmd == \"4\" then!@#&        exit()!@#&  else!@#&        printMenu()!@#& end!@#&end!@#&!@#&printMenu()",
  3.   register = "!@#&print(\"Which side is your moden on? left, top, front etc.\")!@#&side = io.read()!@#&rednet.open(side)!@#&!@#&print(\"Attempting to access the intranet. Please wait...\")!@#&rednet.broadcast(\"$HELLO\")!@#&!@#&local id, message !@#&while true do!@#&  id, message = rednet.receive(5)!@#&  if not message then!@#&    error(\"No network routers nearby. Can't connect to intranet.\")!@#&   return!@#&  end!@#&  if message==\"$HELLO\" then break end!@#&end!@#&print(\"A network has been located!\")!@#&rednet.send(id, \"$ADDME\")!@#&while true do!@#&  id, message = rednet.receive(5)!@#&  if not message then!@#&  -- This may be by choice later on down the track, filtering certain ids etc.!@#&    error(\"Initialization failed... network did not accept your computer.\")!@#&    return!@#&  end!@#&  if message==\"$ACK\" then break end!@#&end!@#&!@#&print(\"Successfully online. Updating your preferences...\")!@#&local file = io.open(\"pref\", \"w\")!@#&if file then!@#&  file:write(\"routerid=\"..id..\"\\nside=\"..side)!@#&  file:close()!@#&end!@#&!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&!@#&print(\"A preference file has been created in the root directly. Do not delete this file!\")!@#&print(\"You have successfully been admitted to the network.\")",
  4. } local function makeFile(_path, _content) local file = fs.open(_path, "w") _content = _content:gsub("!@".."#&", "%\n") _content = textutils.unserialize(_content) file.write(_content) file.close() end local function makeFolder(_path, _content) fs.makeDir(_path) for k,v in pairs(_content) do if type(v) == "table" then makeFolder(_path .. "/" .. k, v) else makeFile(_path .. "/" .. k, v) end end end local sDest = shell.resolve( "clientmoney" ) or "/" if sDest == "root" then sDest = "/" end local tPackage = pkg makeFolder(sDest, tPackage) print("Package Extracted to '" .. sDest .. "'!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement