From 6539850c0562eab3ecc8ab7a4079c9c22f58122b Mon Sep 17 00:00:00 2001 From: jingkaimori Date: Wed, 10 Nov 2021 20:40:33 +0800 Subject: document and clean-up --- doc/api.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 doc/api.md (limited to 'doc') 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} + } + } +) +``` + -- cgit v1.2.3