summaryrefslogtreecommitdiff
path: root/shop2
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-12 17:15:16 +0000
committerubq323 <ubq323@ubq323.website>2023-01-12 17:15:16 +0000
commit6f9772202e3fd11ade9937e5f3540edc444f12da (patch)
tree78429e5e1cd2386083ea080ff0479377adb2cd77 /shop2
parent278e129f9fb245a8978dcc5eae8bc55026b361b4 (diff)
shop2
Diffstat (limited to 'shop2')
-rw-r--r--shop2/items.lua12
-rw-r--r--shop2/main.lua3
-rw-r--r--shop2/stock.lua8
3 files changed, 16 insertions, 7 deletions
diff --git a/shop2/items.lua b/shop2/items.lua
index 2eb497c..82d0104 100644
--- a/shop2/items.lua
+++ b/shop2/items.lua
@@ -1,12 +1,16 @@
local items = {}
-local function i(adr,itname,hname,price,colour)
- items[adr]={itname=itname,hname=hname,price=price,adr=adr,colour=colour or colors.white}
+local function i(adr,itname,hname,price,colour,check)
+ items[adr]={itname=itname,hname=hname,price=price,adr=adr,colour=colour or colors.white,check=check}
end
i("dmn","minecraft:diamond","Diamond",2,colors.cyan)
i("blz","minecraft:blaze_rod","Blaze Rod",0.5,colors.yellow)
i("ely","minecraft:elytra","Elytra",100,colors.purple)
--- todo properly
-i("mnd","minecraft:ooo","Mending Book",10,colors.green)
+i("mnd","minecraft:enchanted_book","Mending Book",10,colors.green,function(idetail)
+ for _,ench in ipairs(idetail.enchantments or {}) do
+ if ench.name == "minecraft:mending" then return true end
+ end
+ return false
+end)
i("nth","minecraft:nether_star","Nether Star",200,colors.white)
return items
diff --git a/shop2/main.lua b/shop2/main.lua
index e4995cc..1def219 100644
--- a/shop2/main.lua
+++ b/shop2/main.lua
@@ -49,7 +49,7 @@ local function proctrans(tr)
if not idesc then
-- some other metaname that has nothing to do with us
-- presumably some other service @ac.kst. so just ignore it
- tell("(debug) i didn't recognise that metaname so no transaction occurs")
+ -- tell("(debug) i didn't recognise that metaname so no transaction occurs")
return
end
@@ -84,7 +84,6 @@ local function run_shop()
our_addr = msg.address.address
end
if msg.type == "event" and msg.event == "transaction" then
- print("proctransing...")
proctrans(msg.transaction)
end
end
diff --git a/shop2/stock.lua b/shop2/stock.lua
index 71a6844..fb7ab1b 100644
--- a/shop2/stock.lua
+++ b/shop2/stock.lua
@@ -24,7 +24,13 @@ local function item_desc_matches(idesc,itemdetail)
-- idesc is an entry from ITEMS
-- itemdetail is something returned from getItemDetail on the chest
-- if you were wondering
- return idesc.itname == itemdetail.name
+
+ if idesc.itname == itemdetail.name then
+ if idesc.check then return idesc.check(itemdetail) end
+ return true
+ end
+ return false
+
end
local function amt_of(stockinfo,idesc)