milo: storefront wip

This commit is contained in:
kepler155c@gmail.com
2019-01-11 03:11:17 -05:00
parent 21b7c7c3af
commit 42e72cf3c8
2 changed files with 8 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ local UI = require('ui')
local os = _G.os
local config = Config.load('store')
local config = Config.load('shop')
local storeTab = UI.Window {
tabTitle = 'Store',
@@ -47,14 +47,14 @@ function storeTab:eventHandler(event)
if event.type == 'clear' then
self.form:setValues({ })
config[self.item.key] = nil
Config.update('store', config)
Config.update('shop', config)
os.queueEvent('store_refresh')
self.form:draw()
elseif event.type == 'update' then
if self.form:save() then
config[self.item.key] = self.form.values
Config.update('store', config)
Config.update('shop', config)
os.queueEvent('store_refresh')
self:emit({ type = 'success_message', message = 'Updated' })
end

View File

@@ -128,9 +128,11 @@ 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)
for k, v in pairs(config) do
if v.name == item then
count = Milo:eject(itemDB:splitKey(k), quantity)
break
end
end
os.queueEvent('store_provided', item, count)
end)