milo: storefront wip
This commit is contained in:
@@ -7,17 +7,19 @@ local config = Config.load('store')
|
|||||||
|
|
||||||
local storeTab = UI.Window {
|
local storeTab = UI.Window {
|
||||||
tabTitle = 'Store',
|
tabTitle = 'Store',
|
||||||
index = 1,
|
index = 6,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, ex = -1, ey = -1,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.TextEntry {
|
[1] = UI.TextEntry {
|
||||||
formLabel = 'Name', formKey = 'name',
|
formLabel = 'Name', formKey = 'name',
|
||||||
help = 'Unique name used when paying for an item',
|
help = 'Unique name used when paying for an item',
|
||||||
required = true,
|
required = true,
|
||||||
|
width = 16,
|
||||||
limit = 64,
|
limit = 64,
|
||||||
},
|
},
|
||||||
[2] = UI.TextEntry {
|
[2] = UI.TextEntry {
|
||||||
|
width = 6,
|
||||||
formLabel = 'Price', formKey = 'price',
|
formLabel = 'Price', formKey = 'price',
|
||||||
help = 'Per item cost',
|
help = 'Per item cost',
|
||||||
required = true,
|
required = true,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ local UI = require('ui')
|
|||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local context = Milo:getContext()
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
|
||||||
local config = Config.load('store')
|
local config = Config.load('store')
|
||||||
@@ -127,16 +126,26 @@ Event.on('store_refresh', function()
|
|||||||
config = Config.load('store')
|
config = Config.load('store')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Event.on('store_provide', function(_, item, quantity)
|
||||||
|
local count = 0
|
||||||
|
local key = Util.find(config, 'name', item)
|
||||||
|
if key then
|
||||||
|
count = Milo:eject(itemDB:splitKey(item), quantity)
|
||||||
|
end
|
||||||
|
os.queueEvent('store_provided', item, count)
|
||||||
|
end)
|
||||||
|
|
||||||
--[[ Task ]]--
|
--[[ Task ]]--
|
||||||
local StoreTask = {
|
local StoreTask = {
|
||||||
name = 'store',
|
name = 'store',
|
||||||
priority = 30,
|
priority = 30,
|
||||||
}
|
}
|
||||||
|
|
||||||
function StoreTask:cycle()
|
function StoreTask:cycle(context)
|
||||||
for node in context.storage:filterActive('store') do
|
for node in context.storage:filterActive('store') do
|
||||||
if not pages[node.name] then
|
if not pages[node.name] then
|
||||||
pages[node.name] = createPage(node)
|
pages[node.name] = createPage(node)
|
||||||
|
os.queueEvent('open_store', node.domain, node.password)
|
||||||
end
|
end
|
||||||
-- update the display
|
-- update the display
|
||||||
pages[node.name]:update()
|
pages[node.name]:update()
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
local GPS = require("gps")
|
|
||||||
local Point = require("point")
|
|
||||||
local Util = require("util")
|
|
||||||
|
|
||||||
local peripheral = _G.peripheral
|
|
||||||
local turtle = _G.turtle
|
|
||||||
|
|
||||||
local args = {...}
|
|
||||||
local block = args[1] or error("Syntax: blockMiner [item name]")
|
|
||||||
|
|
||||||
local function equip(side, item, rawName)
|
|
||||||
local equipped = Peripheral.lookup('side/' .. side)
|
|
||||||
|
|
||||||
if equipped and equipped.type == item then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if not turtle.equip(side, rawName or item) then
|
|
||||||
if not turtle.selectSlotWithQuantity(0) then
|
|
||||||
error('No slots available')
|
|
||||||
end
|
|
||||||
turtle.equip(side)
|
|
||||||
if not turtle.equip(side, item) then
|
|
||||||
error('Unable to equip ' .. item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
turtle.select(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function scan()
|
|
||||||
equip("left", "plethora:module:2")
|
|
||||||
return peripheral.call("left", "scan")
|
|
||||||
end
|
|
||||||
|
|
||||||
if turtle.isEquipped("modem") ~= "right" then
|
|
||||||
equip("right", "computercraft:advanced_modem")
|
|
||||||
end
|
|
||||||
|
|
||||||
local pt = GPS.getPoint(2) or error("GPS not found")
|
|
||||||
equip("left", "plethora:module")
|
|
||||||
local facing = peripheral.call("left", "getBlockMeta", 0, 0, 0).state.facing
|
|
||||||
pt.heading = Point.facings[facing].heading
|
|
||||||
turtle.setPoint(pt, true)
|
|
||||||
equip("left", "minecraft:diamond_pickaxe")
|
|
||||||
Reference in New Issue
Block a user