milo: sounds

This commit is contained in:
kepler155c
2018-11-26 18:32:07 -05:00
parent 4833f7f12b
commit 6f60d91e52
2 changed files with 15 additions and 2 deletions

View File

@@ -279,7 +279,7 @@ function page.grid:getDisplayValues(row)
end
function page:transfer(item, count, msg)
playSound('block.metal.fall')
playSound('ui.button.click')
local response = self:sendRequest({ request = 'transfer', item = item, count = count }, msg)
if response then
item.count = response.current - response.count
@@ -474,7 +474,7 @@ Event.addRoutine(function()
key = table.concat({ item.name, item.damage, item.nbtHash }, ':')
})
if response then
playSound('block.lava.pop')
playSound('entity.item.pickup')
local ritem = page.items[response.key]
if ritem then
ritem.count = response.current + item.count

View File

@@ -8,8 +8,11 @@ local Util = require('util')
local colors = _G.colors
local context = Milo:getContext()
local displayMode = Milo:getState('displayMode') or 0
local peripheral = _G.peripheral
local string = _G.string
local speaker = peripheral.find('speaker')
local displayModes = {
[0] = { text = 'A', help = 'Showing all items' },
[1] = { text = 'I', help = 'Showing inventory items' },
@@ -127,6 +130,12 @@ local listingPage = UI.Page {
},
}
local function playSound(sound)
if speaker then
speaker.playSound('minecraft:' .. sound)
end
end
function listingPage.statusBar:draw()
return UI.Window.draw(self)
end
@@ -160,6 +169,7 @@ function listingPage:eventHandler(event)
elseif event.type == 'eject' or event.type == 'grid_select' then
local item = self.grid:getSelected()
if item then
playSound('ui.button.click')
item.count = Milo:craftAndEject(item, 1)
self.grid:draw()
end
@@ -167,6 +177,7 @@ function listingPage:eventHandler(event)
elseif event.type == 'eject_stack' then
local item = self.grid:getSelected()
if item then
playSound('ui.button.click')
item.count = Milo:craftAndEject(item, itemDB:getMaxCount(item))
self.grid:draw()
end
@@ -174,6 +185,7 @@ function listingPage:eventHandler(event)
elseif event.type == 'eject_all' then
local item = self.grid:getSelected()
if item then
playSound('ui.button.click')
local updated = Milo:getItem(Milo:listItems(), item)
if updated then
Milo:craftAndEject(item, updated.count)
@@ -184,6 +196,7 @@ function listingPage:eventHandler(event)
local item = self.grid:getSelected()
local count = tonumber(self.statusBar.amount.value)
if item and count then
playSound('ui.button.click')
self.statusBar.amount:reset()
self:setFocus(self.statusBar.filter)
Milo:craftAndEject(item, count)