Merge remote-tracking branch 'origin/develop-1.8' into ui-enhancements-2.0

This commit is contained in:
kepler155c@gmail.com
2020-03-31 10:14:04 -06:00
15 changed files with 209 additions and 32 deletions

View File

@@ -1,4 +1,7 @@
{
required = {
'milo',
},
title = 'Switchcraft basic shop',
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/swshop',
description = 'Modification of the k store by Lemmmy\nRun installPlugin.lua after install',

View File

@@ -141,7 +141,7 @@ end
function page.grid:getDisplayValues(row)
row = Util.shallowCopy(row)
local x = row.recipient
row.from = x and x:match('(%w+)@') or row.from
row.from = x and x:match('(.+)@') or row.from
return row
end

25
swshop/help/swshop Normal file
View File

@@ -0,0 +1,25 @@
An item shop software using Krist as its currency.
Requirements
============
* Advanced Turtle
* Chests (any type)
* Milo system
Installation
============
> pastebin run uzghlbnc
> package install swshop
> reboot
Setup
=====
From the shell, run the 'installPlugin.lua' once to install the shop component into your Milo installation.
From Milo, open the setup page and find the monitor you wish to use in the list.
Choose the monitor's type to be 'Store Front', and configure your domain and your wallet's key.
Usage
=====
Setup prices by right-clicking on the desired item and going on the 'Shops' tab.

View File

@@ -33,8 +33,22 @@ local wizardPage = UI.WizardPage {
limit = 64,
},
[4] = UI.Chooser {
formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 5,
width = 10,
nochoice = 'Top',
choices = {
{name = 'Bottom', value = 'bottom'},
{name = 'Top', value = 'top'},
{name = 'Back', value = 'back'},
{name = 'Front', value = 'front'},
{name = 'Right', value = 'right'},
{name = 'Left', value = 'left'},
},
required = true,
},
[5] = UI.Chooser {
width = 9,
formIndex = 5,
formIndex = 6,
formLabel = 'Font Size', formKey = 'textScale',
nochoice = 'Small',
choices = {

View File

@@ -25,7 +25,7 @@ local shopTab = UI.Tab {
formLabel = 'Price', formKey = 'price',
help = 'Per item cost',
required = true,
transform = 'number',
validate = 'numeric',
},
[3] = UI.TextEntry {
limit = 64,

View File

@@ -19,7 +19,7 @@ local textutils = _G.textutils
local chat = device['plethora:chat']
local storage = Config.load('storage')
rs.setOutput('top', false)
Util.each(rs.getSides(), function(side) rs.setOutput(side, false) end)
r.init(jua)
w.init(jua)
@@ -29,9 +29,10 @@ local node = ({ ... })[1] or error('Node name is required')
local config = storage[node]
local privatekey = config.isPrivateKey and config.password or Krist.toKristWalletFormat(config.password)
local address = Krist.makev2address(privatekey)
local rsSide = config.rsSide or 'top'
jua.on("terminate", function()
rs.setOutput('top', false)
rs.setOutput(rsSide, false)
jua.stop()
_G.printError("Terminated")
end)
@@ -44,7 +45,7 @@ local function getItemDetails(item)
t = textutils.unserialize(t)
for key, v in pairs(t) do
if v.name == item then
return key, v.price
return key, tonumber(v.price)
end
end
end
@@ -144,7 +145,7 @@ local function connect()
assert(success, "Failed to get websocket URL")
print("Connected to websocket.")
rs.setOutput('top', true)
rs.setOutput(rsSide, true)
success = await(ws.subscribe, "ownTransactions", function(data)
local transaction = data.transaction
@@ -160,7 +161,7 @@ local s, m = pcall(function()
end)
end)
rs.setOutput('top', false)
rs.setOutput(rsSide, false)
if not s then
error(m, 2)
end