Advertisement
Guest User

testClient

a guest
Jul 2nd, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. local component = require('component')
  2. local io = require('io')
  3. local internet = require('internet')
  4.  
  5. --When buying now we're viewing the current sell orders? Is this correct?
  6. function buyNow()
  7.     sellOrders = getCurrentSellOrders() --get current sell orders from db, last key of table should be n (number of sellOrders)
  8.     displaySellOrders(sellOrders) --display them to user
  9.     item = getPurchase(sellOrders) --returns the item they want to buy
  10.     if item ~= null then --would be null if they didn't select anything (or something else went wrong)
  11.         if purchaseOrder(sellOrders,item) then return true end
  12.     end
  13.     return false
  14. end
  15.  
  16. function getCurrentSellOrders()
  17.     --do stuff with internet card (send to url getCurrentOrders.php
  18.     --do stuff with database (php script)
  19. end
  20.  
  21. function displaySellOrders(sellOrders)
  22.     --[[
  23.         display each item (sell order) and ea price, row price etc
  24.  
  25.         random thought, we should be able to add another table containing
  26.         all the item ids, dmg, and their associated name, will likely come in
  27.         handy (we'd have to check regularly that they haven't changed, unless we
  28.         work out a way to automate it (we could likely right a script that uses
  29.         our client id maps to update it (maybe the servers if possible?(needed
  30.         at least one more layer of brackets to make it legit))))-- now you have to check there is there right amount of brackets
  31.     --]]
  32. end
  33.  
  34. function getPurchase(sellOrders)
  35.     --[[
  36.     --returns item to purchase (basically the info for the wanted sell order item + amnt to purchase)
  37.     if user selects item to buy then
  38.         return item + amnt
  39.     else --they don't wany to buy
  40.         return null
  41.     end
  42.     --]]
  43. end
  44.  
  45. function purchaseOrder(sellOrders,item)
  46.    
  47. end
  48.  
  49. --------
  50.  
  51. function createBuyOrder()
  52.     items = checkItems() --check the ender chest for available items to sell
  53.  
  54. end
  55.  
  56. --------
  57.  
  58. function sellNow()
  59.  
  60. end
  61.  
  62. --------
  63.  
  64. function createSellOrder()
  65.  
  66. end
  67.  
  68. --------
  69.  
  70. function manageOrders()
  71.  
  72. end
  73.  
  74. --------
  75.  
  76. function showMenu()
  77.     print("Please Select an Option:")
  78.     print("1. Buy Now")
  79.     print("2. Create Buy Order")
  80.     print("3. Sell Now")
  81.     print("4. Create Sell Order")
  82.     print("5. Manage My Orders")
  83.     print("Q. Quit")
  84. end
  85.  
  86. --could/should make each menu option part of a lib, example use in comments
  87. function main()
  88.     flag = true
  89.     while flag do
  90.         showMenu()
  91.         input = io.read() --this string will contain all acceptable input
  92.         if input == '1' then
  93.             buyNow() --clientLib.buyNow()
  94.         elseif input == '2' then
  95.             createBuyOrder() --clientLib.createBuyOrder()
  96.         elseif input == '3' then
  97.             sellNow() --clientLib.sellNow()
  98.         elseif input == '4' then
  99.             createSellOrder() --clientLib.createSellOrder()
  100.         elseif input == '5' then
  101.             manageOrders() --clientLib.manageOrders()
  102.         elseif input == 'Q' or input == "q" then
  103.             print("Logging out of AH, goodbye")
  104.             flag = false
  105.         else
  106.             print("Incorrect input, try again")
  107.         end
  108.     end
  109. end
  110.  
  111. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement