diff options
-rw-r--r-- | shop.lua | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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 |