Advertisement
Doug4347

ecoAppInstaller

Aug 13th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1. itemsArr = { "ecoMobile"}
  2. pricesArr = { 100}
  3. shopOwnerAcc = "Doug"
  4. drive = peripheral.wrap("right")
  5. serverID = 0
  6.  
  7. peripherals = peripheral.getNames()
  8. periph = true
  9. index = 1
  10. while periph do
  11.     periph = peripherals[index]
  12.     if periph then
  13.         periphType = peripheral.getType(periph)
  14.         if periphType == "modem" then
  15.             rednet.open(periph)
  16.         end
  17.     end
  18.     index = index + 1
  19. end
  20.  
  21. info = { ... }
  22.  
  23. while true do
  24.     shell.run("clear")
  25.     print("Please enter the name of the app you wish to buy.")
  26.     print("You may also used \"Apps\" instead for a list of items for sale here.")
  27.     option = read()
  28.     if option == "Apps" then
  29.         itemList = true
  30.         index = 0
  31.         shell.run("clear")
  32.         while itemList do
  33.             index = index + 1
  34.             itemList = itemsArr[index]
  35.             if itemList then
  36.                 print(itemList)
  37.                 os.sleep(1)
  38.             end
  39.         end
  40.         os.sleep(10)
  41.     else
  42.         itemList = true
  43.         index = 0
  44.         shell.run("clear")
  45.         while itemList do
  46.             index = index + 1
  47.             itemList = itemsArr[index]
  48.             if itemList == option then
  49.                 myItem = itemsArr[index]
  50.                 myPrice = pricesArr[index]
  51.                 itemList = false
  52.             end
  53.         end
  54.         print("Item : ".. myItem)
  55.         print("Price: ".. myPrice)
  56.         print("")
  57.        
  58.         print("Would you like to continue? (y/n)")
  59.         continue = read()
  60.         if continue == "y" then
  61.             info[1] = "Shop"
  62.             shell.run("clear")
  63.             print("Please enter your username.")
  64.             info[2] = read()
  65.             if info[2] then
  66.                 print("Please enter your password.")
  67.                 info[3] = read('*')
  68.                 if info[3] then
  69.                     rednet.send(serverID, info, "login")
  70.                     id, servInfo, servProtocol = rednet.receive()
  71.                     if servProtocol == "success" then
  72.                         print("Login successful, transfering money now...")
  73.                         info[4] = shopOwnerAcc
  74.                         info[5] = myPrice
  75.                         rednet.send(serverID, info, "transfer")
  76.                         id, servInfo, servProtocol = rednet.receive()
  77.                         if servProtocol == "failure" then
  78.                             print("Failed to send funds. Reason:")
  79.                             print(servInfo[1])
  80.                             os.sleep(5)
  81.                         else
  82.                             print("Successfully transfered all funds, please insert your pocket PC into the disk drive to the right now.")
  83.                             while not disk.isPresent("right") do
  84.                                 sleep(0.1)
  85.                             end
  86.                             shell.run("clear")
  87.                             print("Installing app now...")
  88.                             path = disk.getMountPath("right")
  89.                             shell.run("copy ".. option.. " ".. path.. "/".. option)
  90.                         end
  91.                     else
  92.                         print("Unable to complete transaction. Reason:")
  93.                         print(servInfo)
  94.                     end
  95.                 else
  96.                     print("Please try again and enter a vaild password")
  97.                 end
  98.             else
  99.                 print("Please try again and enter a vaild username.")
  100.                 os.sleep(5)
  101.             end
  102.         else
  103.             print("Action Canceled.")
  104.             os.sleep(5)
  105.         end
  106.        
  107.     end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement