Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local io = require('io')
- local internet = require('internet')
- --When buying now we're viewing the current sell orders? Is this correct?
- function buyNow()
- sellOrders = getCurrentSellOrders() --get current sell orders from db, last key of table should be n (number of sellOrders)
- displaySellOrders(sellOrders) --display them to user
- item = getPurchase(sellOrders) --returns the item they want to buy
- if item ~= null then --would be null if they didn't select anything (or something else went wrong)
- if purchaseOrder(sellOrders,item) then return true end
- end
- return false
- end
- function getCurrentSellOrders()
- --do stuff with internet card (send to url getCurrentOrders.php
- --do stuff with database (php script)
- end
- function displaySellOrders(sellOrders)
- --[[
- display each item (sell order) and ea price, row price etc
- random thought, we should be able to add another table containing
- all the item ids, dmg, and their associated name, will likely come in
- handy (we'd have to check regularly that they haven't changed, unless we
- work out a way to automate it (we could likely right a script that uses
- our client id maps to update it (maybe the servers if possible?(needed
- at least one more layer of brackets to make it legit))))-- now you have to check there is there right amount of brackets
- --]]
- end
- function getPurchase(sellOrders)
- --[[
- --returns item to purchase (basically the info for the wanted sell order item + amnt to purchase)
- if user selects item to buy then
- return item + amnt
- else --they don't wany to buy
- return null
- end
- --]]
- end
- function purchaseOrder(sellOrders,item)
- end
- --------
- function createBuyOrder()
- items = checkItems() --check the ender chest for available items to sell
- end
- --------
- function sellNow()
- end
- --------
- function createSellOrder()
- end
- --------
- function manageOrders()
- end
- --------
- function showMenu()
- print("Please Select an Option:")
- print("1. Buy Now")
- print("2. Create Buy Order")
- print("3. Sell Now")
- print("4. Create Sell Order")
- print("5. Manage My Orders")
- print("Q. Quit")
- end
- --could/should make each menu option part of a lib, example use in comments
- function main()
- flag = true
- while flag do
- showMenu()
- input = io.read() --this string will contain all acceptable input
- if input == '1' then
- buyNow() --clientLib.buyNow()
- elseif input == '2' then
- createBuyOrder() --clientLib.createBuyOrder()
- elseif input == '3' then
- sellNow() --clientLib.sellNow()
- elseif input == '4' then
- createSellOrder() --clientLib.createSellOrder()
- elseif input == '5' then
- manageOrders() --clientLib.manageOrders()
- elseif input == 'Q' or input == "q" then
- print("Logging out of AH, goodbye")
- flag = false
- else
- print("Incorrect input, try again")
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement