-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkiosk.lua
More file actions
82 lines (70 loc) · 1.92 KB
/
kiosk.lua
File metadata and controls
82 lines (70 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- kiosk program
-- this may or may not abuse the payment library i wrote
local config = require("kioskconfig")
local libpayment = require("libpayment")
local menu = require("libmenu")
local component = require("component")
local payment = libpayment.new(component.get(config.payment.transposer))
payment:setPaymentFrom(config.payment.input)
payment:setPaymentTo(config.payment.output)
payment:setPaymentItem(config.payment.item, config.payment.damage)
local menuitems = {}
local map = {}
for k, v in pairs(config.products) do
menuitems[#menuitems + 1] = v.name
local tp = component.get(v.transposer)
map[v.name] = {
transfer = libpayment.new(tp)
:setPaymentFrom(v.input)
:setPaymentTo(v.output)
:setPaymentItem(k, v.damage),
item = v,
type = "product"
}
end
for k, v in pairs(config.services) do
menuitems[#menuitems + 1] = v.name
local itp = component.get(v.input.transposer)
local otp = component.get(v.output.transposer)
local input = libpayment.new(itp)
:setPaymentFrom(v.input.input)
:setPaymentTo(v.input.output)
local output = libpayment.new(otp)
:setPaymentFrom(v.output.input)
:setPaymentTo(v.input.output)
map[v.name] = {
input = input,
output = output,
data = v,
type = "service"
}
end
local function getproduct(item)
local ok, err = payment:getPayment()
end
local function getservice(item)
end
local menu = libmenu.new(menuitems)
menu.title = "Total Cost: 0"
local view = "View Purchases"
local chkt = "Check Out"
menu:addOption(view)
menu:addOption(chkt)
while not event.pull("interrupted") do
local item = menu:select()
if item == chkt then
for k, v in pairs(selected) do
local item = map[v]
if item.type == "product" then
getproduct(item)
else
getservice(item)
end
end
elseif item == view then
else
item = map[item]
total = total + item.cost
selected[#selected + 1] = item
end
end