milo: sounds
This commit is contained in:
@@ -2,6 +2,7 @@ _G.requireInjector(_ENV)
|
|||||||
|
|
||||||
local Config = require('config')
|
local Config = require('config')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
|
local Sound = require('sound')
|
||||||
local Socket = require('socket')
|
local Socket = require('socket')
|
||||||
local sync = require('sync').sync
|
local sync = require('sync').sync
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
@@ -13,8 +14,6 @@ local fs = _G.fs
|
|||||||
local os = _G.os
|
local os = _G.os
|
||||||
local socket
|
local socket
|
||||||
|
|
||||||
local speaker = device.speaker
|
|
||||||
|
|
||||||
local SHIELD_SLOT = 2
|
local SHIELD_SLOT = 2
|
||||||
local STARTUP_FILE = 'usr/autorun/miloRemote.lua'
|
local STARTUP_FILE = 'usr/autorun/miloRemote.lua'
|
||||||
|
|
||||||
@@ -163,12 +162,6 @@ local page = UI.Page {
|
|||||||
items = { },
|
items = { },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function playSound(sound, vol)
|
|
||||||
if speaker then
|
|
||||||
speaker.playSound('minecraft:' .. sound, vol or 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getPlayerName()
|
local function getPlayerName()
|
||||||
local neural = device.neuralInterface
|
local neural = device.neuralInterface
|
||||||
|
|
||||||
@@ -279,7 +272,7 @@ function page.grid:getDisplayValues(row)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page:transfer(item, count, msg)
|
function page:transfer(item, count, msg)
|
||||||
playSound('ui.button.click', .3)
|
Sound.play('ui.button.click', .3)
|
||||||
local response = self:sendRequest({ request = 'transfer', item = item, count = count }, msg)
|
local response = self:sendRequest({ request = 'transfer', item = item, count = count }, msg)
|
||||||
if response then
|
if response then
|
||||||
item.count = response.current - response.count
|
item.count = response.current - response.count
|
||||||
@@ -364,6 +357,7 @@ shell.openForegroundTab('packages/milo/MiloRemote')]])
|
|||||||
self:setFocus(self.statusBar.filter)
|
self:setFocus(self.statusBar.filter)
|
||||||
self:transfer(item, count, 'requesting ' .. count .. ' ...')
|
self:transfer(item, count, 'requesting ' .. count .. ' ...')
|
||||||
else
|
else
|
||||||
|
Sound.play('entity.villager.no')
|
||||||
self:setStatus('nope ...')
|
self:setStatus('nope ...')
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -474,7 +468,7 @@ Event.addRoutine(function()
|
|||||||
key = table.concat({ item.name, item.damage, item.nbtHash }, ':')
|
key = table.concat({ item.name, item.damage, item.nbtHash }, ':')
|
||||||
})
|
})
|
||||||
if response then
|
if response then
|
||||||
playSound('entity.item.pickup')
|
Sound.play('entity.item.pickup')
|
||||||
local ritem = page.items[response.key]
|
local ritem = page.items[response.key]
|
||||||
if ritem then
|
if ritem then
|
||||||
ritem.count = response.current + item.count
|
ritem.count = response.current + item.count
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ local Craft = require('craft2')
|
|||||||
local itemDB = require('itemDB')
|
local itemDB = require('itemDB')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
|
local Sound = require('sound')
|
||||||
local UI = require('ui')
|
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 context = Milo:getContext()
|
||||||
local displayMode = Milo:getState('displayMode') or 0
|
local displayMode = Milo:getState('displayMode') or 0
|
||||||
local peripheral = _G.peripheral
|
|
||||||
local string = _G.string
|
local string = _G.string
|
||||||
|
|
||||||
local speaker = peripheral.find('speaker')
|
|
||||||
|
|
||||||
local displayModes = {
|
local displayModes = {
|
||||||
[0] = { text = 'A', help = 'Showing all items' },
|
[0] = { text = 'A', help = 'Showing all items' },
|
||||||
[1] = { text = 'I', help = 'Showing inventory items' },
|
[1] = { text = 'I', help = 'Showing inventory items' },
|
||||||
@@ -130,12 +128,6 @@ local listingPage = UI.Page {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function playSound(sound)
|
|
||||||
if speaker then
|
|
||||||
speaker.playSound('minecraft:' .. sound)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function listingPage.statusBar:draw()
|
function listingPage.statusBar:draw()
|
||||||
return UI.Window.draw(self)
|
return UI.Window.draw(self)
|
||||||
end
|
end
|
||||||
@@ -169,7 +161,7 @@ function listingPage:eventHandler(event)
|
|||||||
elseif event.type == 'eject' or event.type == 'grid_select' then
|
elseif event.type == 'eject' or event.type == 'grid_select' then
|
||||||
local item = self.grid:getSelected()
|
local item = self.grid:getSelected()
|
||||||
if item then
|
if item then
|
||||||
playSound('ui.button.click')
|
Sound.play('ui.button.click', .3)
|
||||||
item.count = Milo:craftAndEject(item, 1)
|
item.count = Milo:craftAndEject(item, 1)
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
end
|
end
|
||||||
@@ -177,7 +169,7 @@ function listingPage:eventHandler(event)
|
|||||||
elseif event.type == 'eject_stack' then
|
elseif event.type == 'eject_stack' then
|
||||||
local item = self.grid:getSelected()
|
local item = self.grid:getSelected()
|
||||||
if item then
|
if item then
|
||||||
playSound('ui.button.click')
|
Sound.play('ui.button.click', .3)
|
||||||
item.count = Milo:craftAndEject(item, itemDB:getMaxCount(item))
|
item.count = Milo:craftAndEject(item, itemDB:getMaxCount(item))
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
end
|
end
|
||||||
@@ -185,7 +177,7 @@ function listingPage:eventHandler(event)
|
|||||||
elseif event.type == 'eject_all' then
|
elseif event.type == 'eject_all' then
|
||||||
local item = self.grid:getSelected()
|
local item = self.grid:getSelected()
|
||||||
if item then
|
if item then
|
||||||
playSound('ui.button.click')
|
Sound.play('ui.button.click', .3)
|
||||||
local updated = Milo:getItem(Milo:listItems(), item)
|
local updated = Milo:getItem(Milo:listItems(), item)
|
||||||
if updated then
|
if updated then
|
||||||
Milo:craftAndEject(item, updated.count)
|
Milo:craftAndEject(item, updated.count)
|
||||||
@@ -196,7 +188,7 @@ function listingPage:eventHandler(event)
|
|||||||
local item = self.grid:getSelected()
|
local item = self.grid:getSelected()
|
||||||
local count = tonumber(self.statusBar.amount.value)
|
local count = tonumber(self.statusBar.amount.value)
|
||||||
if item and count then
|
if item and count then
|
||||||
playSound('ui.button.click')
|
Sound.play('ui.button.click', .3)
|
||||||
self.statusBar.amount:reset()
|
self.statusBar.amount:reset()
|
||||||
self:setFocus(self.statusBar.filter)
|
self:setFocus(self.statusBar.filter)
|
||||||
Milo:craftAndEject(item, count)
|
Milo:craftAndEject(item, count)
|
||||||
@@ -238,6 +230,7 @@ function listingPage:eventHandler(event)
|
|||||||
if Craft.findRecipe(item) then -- or item.is_craftable then
|
if Craft.findRecipe(item) then -- or item.is_craftable then
|
||||||
UI:setPage('craft', self.grid:getSelected())
|
UI:setPage('craft', self.grid:getSelected())
|
||||||
else
|
else
|
||||||
|
Sound.play('entity.villager.no')
|
||||||
self.notification:error('No recipe defined')
|
self.notification:error('No recipe defined')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user