summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shop2.dat2
-rw-r--r--shop2/disp.lua9
-rw-r--r--shop2/items.lua9
-rw-r--r--shop2/main.lua14
4 files changed, 19 insertions, 15 deletions
diff --git a/shop2.dat b/shop2.dat
index e2961f4..9a47450 100644
--- a/shop2.dat
+++ b/shop2.dat
@@ -1 +1 @@
-file shop2/disp.lua shop2/main.lua shop2/stock.lua
+file shop2/disp.lua shop2/main.lua shop2/stock.lua shop2/items.lua
diff --git a/shop2/disp.lua b/shop2/disp.lua
index 55df99f..65aebc5 100644
--- a/shop2/disp.lua
+++ b/shop2/disp.lua
@@ -79,9 +79,14 @@ local function disp_shopscreen(items)
{1,h-1}, colors.blue, centre("/pay <adr>@"..ourname.." <amount>",w)
}
-
+end
-
+local items = require"shop2.items"
+local function run()
+ while true do
+ disp_shopscreen(items)
+ os.sleep(2)
+ end
end
disp_shopscreen()
diff --git a/shop2/items.lua b/shop2/items.lua
new file mode 100644
index 0000000..20e8a93
--- /dev/null
+++ b/shop2/items.lua
@@ -0,0 +1,9 @@
+local items = {}
+local function i(adr,itname,hname,price)
+ items[adr]={itname=itname,hname=hname,price=price,adr=adr}
+end
+i("dmn","minecraft:diamond","Diamond",5)
+i("blz","minecraft:blaze_rod","Blaze Rod",10)
+i("ely","minecraft:elytra","Elytra",200)
+
+return items
diff --git a/shop2/main.lua b/shop2/main.lua
index 322d76c..67d3dba 100644
--- a/shop2/main.lua
+++ b/shop2/main.lua
@@ -3,18 +3,10 @@ package.path = "/?;/?.lua;"..package.path
local key=assert(settings.get"krist.pkey","please set private key")
local stock=require"shop2.stock"
-
+local items = require"shop2.items"
-- ac.kst
local OURNAME = "ac"
-local ITEMS = {}
-local function i(adr,itname,hname,price)
- ITEMS[adr]={itname=itname,hname=hname,price=price,adr=adr}
-end
-i("dmn","minecraft:diamond","Diamond",5)
-i("blz","minecraft:blaze_rod","Blaze Rod",10)
-i("ely","minecraft:elytra","Elytra",200)
-
local sres =textutils.unserializeJSON( http.post("https://krist.dev/ws/start","privatekey="..key).readAll())
assert(sres.ok,"not ok")
@@ -53,7 +45,7 @@ local function proctrans(tr)
local function refund() if meta['return'] then sendws { type="make_transaction", to=meta['return'], amount=tr.value } end end
local mtn = tr.sent_metaname
- local idesc = ITEMS[mtn]
+ local idesc = items[mtn]
if not idesc then
-- some other metaname that has nothing to do with us
-- presumably some other service @ac.kst. so just ignore it
@@ -85,10 +77,8 @@ local function proctrans(tr)
end
local function run_shop()
- print("RUNSHOP")
while true do
local msgtxt = assert(ws.receive(),"ws error")
- print(msgtxt)
local msg = textutils.unserializeJSON(msgtxt)
if msg.type == "response" and msg.responding_to_type == "me" then
our_addr = msg.address.address