summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-05 05:32:22 +0000
committerubq323 <ubq323@ubq323.website>2023-01-05 05:32:22 +0000
commitbc8d921d661beb1d6b51d409266c11b4bdc9d6df (patch)
tree542a97e93dad25c17fd59b495215529b7e459f0e
parentf707f4dc34d3a48ad2ebaaa4130c777a9a219f47 (diff)
shop2
-rw-r--r--shop2.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/shop2.lua b/shop2.lua
index 3659402..f3da107 100644
--- a/shop2.lua
+++ b/shop2.lua
@@ -107,24 +107,30 @@ local function proctrans(tr)
local function refund() if meta['return'] then sendws { type="make_transaction", to=meta['return'], amount=tr.value } end end
local mtn = tr.sent_metaname
-
+ local idesc = ITEMS[mtn]
+ if not idesc then
+ -- some other metaname that has nothing to do with us
+ -- presumably some other service @ac.kst. so just ignore it
+ return
+ end
- local remainder = tr.value % PRICE
+ local remainder = tr.value % idesc.price
if remainder ~= 0 then
- tell("i can only give you a whole number of items. make sure the amount you gave me is a multiple of "..PRICE)
+ tell("i can only give you a whole number of items. make sure the amount you gave me is a multiple of "..idesc.price)
refund()
else
- local in_stock = stock_amt()
+ local si = take_stock()
+ local in_stock = stock_amt(si,idesc)
if in_stock == 0 then
tell("we are out of stock! please yell at ubq323 about this")
refund()
else
- local to_give = math.floor(tr.value / PRICE)
+ local to_give = math.floor(tr.value / idesc.price)
if to_give > in_stock then
tell("i don't have that many items in stock, sorry")
refund()
else
- give(to_give)
+ give(si,idesc,to_give)
tell("thank you!!! :3")
end
end