summaryrefslogtreecommitdiff
path: root/shop.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-12-29 23:07:14 +0000
committerubq323 <ubq323@ubq323.website>2022-12-29 23:07:14 +0000
commit7d96a1d9475813aa3cce88432a149aed0e87e728 (patch)
tree49ac7955e30b54e4f28138b9f5b4692035d95479 /shop.lua
parentf5231599a68102402e0fbf939bc5d944e8c241fc (diff)
shop
Diffstat (limited to 'shop.lua')
-rw-r--r--shop.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/shop.lua b/shop.lua
index c3c22b2..3f55971 100644
--- a/shop.lua
+++ b/shop.lua
@@ -43,6 +43,21 @@ function stock_amt()
return out
end
+function give(amt)
+ amt = amt or 1
+ -- assumes that we have at least amt in stock already
+ for i=1,16 do
+ local x = turtle.getItemDetail(i)
+ if x and x.name == ITEM then
+ local a = math.min(amt,x.count)
+ turtle.select(i)
+ turtle.drop(a)
+ amt = amt - a
+ if amt <= 0 then break end
+ end
+ end
+end
+
function proctrans(tr)
if tr.to ~= our_addr then return end
if tr.type ~= "transfer" then return end
@@ -57,7 +72,7 @@ function proctrans(tr)
tell(tostring(amt))
if amt>0 then
- turtle.drop()
+ give(1)
tell("thank you!!! :3")
end