diff options
-rw-r--r-- | doc/api.md | 99 | ||||
-rw-r--r-- | init.lua | 9 |
2 files changed, 99 insertions, 9 deletions
diff --git a/doc/api.md b/doc/api.md new file mode 100644 index 0000000..012d882 --- /dev/null +++ b/doc/api.md @@ -0,0 +1,99 @@ +# Digiline interface + +## get shop status + + + +```lua +digiline_send('channel', { + type='get' + } +) +``` + +response from shop looks like this: + +```lua +{ + offer = { + { + give_count = 4, + pay_count = 3, + pay = "basenodes:cobble", + stock = 0, + give = "basenodes:dirt", + pay_price = 0 + }, + { + give_count = 25, + pay_count = 1, + pay = "currency:minegeld_10", + stock = 1, + give = "digilines:lcd", + pay_price = 0.4 + }, + { + give_count = 12, + pay_count = 3, + pay = "currency:minegeld_10", + stock = 4, + give = "digilines:lcd", + pay_price = 2.5 + }, + { + give_count = 9, + pay_count = 3, + pay = "currency:minegeld_10", + stock = 5, + give = "digilines:lcd", + pay_price = 3.3333333333333 + } + }, + inventory = { + { + meta = { + + }, + metadata = "", + count = 25, + name = "digilines:lcd", + wear = 0 + }, + [5] = { + meta = { + + }, + metadata = "", + count = 3, + name = "currency:minegeld_10", + wear = 0 + }, + [28] = { + meta = { + palette_index = "0" + }, + metadata = "", + count = 1, + name = "testnodes:mesh_colorwallmounted", + wear = 0 + } + } +} +``` + + + +## set shop offer + +following program will set third slot of offer, then this slot will receive three cobble for four dirt + +```lua +digiline_send('channel', { + type='set', + offer={ + [3] = {give="basenodes:dirt",give_count=4,pay="basenodes:cobble",pay_count=3} + } + } +) +``` + @@ -479,7 +479,6 @@ minetest.register_node("smartshop:shop", { if type(current_offer)=='table' and current_offer.give and current_offer.pay then local give_item = ItemStack(current_offer.give); local pay_item = ItemStack(current_offer.pay); - print(give_item:get_name()) if minetest.registered_items[give_item:get_name()] and minetest.registered_items[pay_item:get_name()] then if type(current_offer.give_count) == "number" then give_item:set_count(math.floor(current_offer.give_count)) @@ -494,14 +493,6 @@ minetest.register_node("smartshop:shop", { end end end - - -- if event.type == 'digiline' then - -- print(event.channel) - -- print(event.msg) - -- else - -- digiline.send('b',{type='ask'}); - - -- end end } }, |