summaryrefslogtreecommitdiff
path: root/shop2/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'shop2/main.lua')
-rw-r--r--shop2/main.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/shop2/main.lua b/shop2/main.lua
index a79ab6f..8abe943 100644
--- a/shop2/main.lua
+++ b/shop2/main.lua
@@ -36,6 +36,14 @@ local function parsemeta(m)
return out
end
+local function divisible(a,b)
+ -- returns whether a is divisible by b
+ -- because % doesn't work on nonintegers for some reason
+ if b == 0 then return false end
+ local x = a/b
+ return x == math.floor(x)
+end
+
local function proctrans(tr)
if tr.to ~= our_addr then return end
if tr.type ~= "transfer" then return end
@@ -63,8 +71,7 @@ local function proctrans(tr)
return
end
- local remainder = tr.value % idesc.price
- if remainder ~= 0 then
+ if not divisible(tr.value,idesc.price) then
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