milo: storefront wip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user