milo: storefront wip
This commit is contained in:
@@ -3,7 +3,7 @@ local UI = require('ui')
|
|||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
|
||||||
local config = Config.load('store')
|
local config = Config.load('shop')
|
||||||
|
|
||||||
local storeTab = UI.Window {
|
local storeTab = UI.Window {
|
||||||
tabTitle = 'Store',
|
tabTitle = 'Store',
|
||||||
@@ -47,14 +47,14 @@ function storeTab:eventHandler(event)
|
|||||||
if event.type == 'clear' then
|
if event.type == 'clear' then
|
||||||
self.form:setValues({ })
|
self.form:setValues({ })
|
||||||
config[self.item.key] = nil
|
config[self.item.key] = nil
|
||||||
Config.update('store', config)
|
Config.update('shop', config)
|
||||||
os.queueEvent('store_refresh')
|
os.queueEvent('store_refresh')
|
||||||
self.form:draw()
|
self.form:draw()
|
||||||
|
|
||||||
elseif event.type == 'update' then
|
elseif event.type == 'update' then
|
||||||
if self.form:save() then
|
if self.form:save() then
|
||||||
config[self.item.key] = self.form.values
|
config[self.item.key] = self.form.values
|
||||||
Config.update('store', config)
|
Config.update('shop', config)
|
||||||
os.queueEvent('store_refresh')
|
os.queueEvent('store_refresh')
|
||||||
self:emit({ type = 'success_message', message = 'Updated' })
|
self:emit({ type = 'success_message', message = 'Updated' })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -128,9 +128,11 @@ end)
|
|||||||
|
|
||||||
Event.on('store_provide', function(_, item, quantity)
|
Event.on('store_provide', function(_, item, quantity)
|
||||||
local count = 0
|
local count = 0
|
||||||
local key = Util.find(config, 'name', item)
|
for k, v in pairs(config) do
|
||||||
if key then
|
if v.name == item then
|
||||||
count = Milo:eject(itemDB:splitKey(item), quantity)
|
count = Milo:eject(itemDB:splitKey(k), quantity)
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
os.queueEvent('store_provided', item, count)
|
os.queueEvent('store_provided', item, count)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user