multiMiner tweak

This commit is contained in:
kepler155c@gmail.com
2019-01-28 22:04:39 -05:00
parent e264d98739
commit 9de52daa11
3 changed files with 11 additions and 3 deletions

View File

@@ -340,10 +340,10 @@ context.page = page
function context:setStatus(status) function context:setStatus(status)
page.menuBar.infoBar.values = status page.menuBar.infoBar.values = status
if page.menuBar.infoBar.enabled then --if page.menuBar.infoBar.enabled then
page.menuBar.infoBar:draw() page.menuBar.infoBar:draw()
page:sync() page:sync()
end --end
end end
local function processMessages(s) local function processMessages(s)

View File

@@ -155,7 +155,9 @@ local function run(member, point)
local slot = turtle.getSlot(index) local slot = turtle.getSlot(index)
if slot.count > 0 then if slot.count > 0 then
blockTypes[pt.key] = slot.key blockTypes[pt.key] = slot.key
blockTypes[slot.key] = true if slot.key ~= pt.key then
blockTypes[slot.key] = true
end
end end
end end
end end

View File

@@ -51,6 +51,9 @@ local function getItemDetails(item)
end end
end end
local function logTransaction(transaction, details)
end
local function handleTransaction(transaction) local function handleTransaction(transaction)
local from = transaction.from local from = transaction.from
local to = transaction.to local to = transaction.to
@@ -68,11 +71,13 @@ local function handleTransaction(transaction)
local function refundTransaction(amount, reason) local function refundTransaction(amount, reason)
print("Refunding to ", recipient) print("Refunding to ", recipient)
await(k.makeTransaction, privatekey, recipient, amount, reason) await(k.makeTransaction, privatekey, recipient, amount, reason)
logTransaction(transaction, { refund = amount, reason = reason })
end end
local itemId, price = getItemDetails(metadata.name) local itemId, price = getItemDetails(metadata.name)
if not itemId or not price then if not itemId or not price then
print('invalid item') print('invalid item')
logTransaction(transaction, { reason = 'invalid item' })
--return refundTransaction(value, "error=Item specified is not valid") --return refundTransaction(value, "error=Item specified is not valid")
return -- there could be multiple stores... return -- there could be multiple stores...
end end
@@ -96,6 +101,7 @@ local function handleTransaction(transaction)
elseif e == 'shop_provided' and p1 == uid then elseif e == 'shop_provided' and p1 == uid then
local extra = value - (price * p2) local extra = value - (price * p2)
logTransaction(transaction, { purchased = p2 })
if extra > 0 then if extra > 0 then
print('extra: ' .. extra) print('extra: ' .. extra)
refundTransaction(extra, "message=Here's your change!") refundTransaction(extra, "message=Here's your change!")