summaryrefslogtreecommitdiff
path: root/shop2
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-07 05:24:25 +0000
committerubq323 <ubq323@ubq323.website>2023-01-07 05:24:25 +0000
commitccd7438702f15d94edf091aea178b83785a44e08 (patch)
tree2de7be85b52a40e4d1710b5ab10843be3e89f6a7 /shop2
parentc514aa627300c62ea1c7736de1e7bac3c95398aa (diff)
shop2
Diffstat (limited to 'shop2')
-rw-r--r--shop2/disp.lua9
-rw-r--r--shop2/items.lua9
-rw-r--r--shop2/main.lua14
3 files changed, 18 insertions, 14 deletions
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