diff --git a/games/SoundPlayer.lua b/games/SoundPlayer.lua new file mode 100644 index 0000000..4e9f092 --- /dev/null +++ b/games/SoundPlayer.lua @@ -0,0 +1,64 @@ +local Sound = require('sound') + +local UI = require('ui') +local Util = require('util') + +local peripheral = _G.peripheral + +if not peripheral.find('speaker') then + error('No speaker attached') +end + +local rawSounds = Util.readLines('packages/games/etc/sounds.txt') or error('Unable to read sounds file') +local sounds = { } +for _, s in pairs(rawSounds) do + table.insert(sounds, { name = s }) +end + +UI:configure('SoundPlayer', ...) + +local page = UI.Page { + labelText = UI.Text { + x = 3, y = 2, + value = 'Search', + }, + filter = UI.TextEntry { + x = 10, y = 2, ex = -3, + limit = 32, + }, + grid = UI.ScrollingGrid { + y = 4, + columns = { + { heading = 'Name', key = 'name' }, + }, + values = sounds, + }, +} + +function page:eventHandler(event) + if event.type == 'grid_select' then + Sound.play(event.selected.name) + + elseif event.type == 'text_change' then + if #event.text == 0 then + self.grid.values = sounds + else + self.grid.values = { } + for _,f in pairs(sounds) do + if string.find(f.name, event.text) then + table.insert(self.grid.values, f) + end + end + end + self.grid:update() + self.grid:setIndex(1) + self.grid:draw() + + else + return UI.Page.eventHandler(self, event) + end + return true +end + +UI:setPage(page) +UI:pullEvents() diff --git a/games/ccTunes.lua b/games/ccTunes.lua index 8688dc1..6b8551a 100644 --- a/games/ccTunes.lua +++ b/games/ccTunes.lua @@ -3,21 +3,25 @@ local Sound = require('sound') local os = _G.os local tunes = { - 'record.11', - 'record.13', - 'record.blocks', - 'record.cat', - 'record.chirp', - 'record.far', - 'record.mall', - 'record.mellohi', - 'record.stal', - 'record.strad', - 'record.wait', - 'record.ward', + { sound = 'record.11', length = '1:11' }, + { sound = 'record.13', length = '2:58' }, + { sound = 'record.blocks', length = '5:45' }, + { sound = 'record.cat', length = '3:05' }, + { sound = 'record.chirp', length = '3:05' }, + { sound = 'record.far', length = '2:54' }, + { sound = 'record.mall', length = '3:17' }, + { sound = 'record.mellohi', length = '1:36' }, + { sound = 'record.stal', length = '2:30' }, + { sound = 'record.strad', length = '3:08' }, + { sound = 'record.wait', length = '3:58' }, + { sound = 'record.ward', length = '4:11' }, } while true do - Sound.play(tunes[math.random(1, #tunes)]) - os.sleep(120) + local song = tunes[math.random(1, #tunes)] + Sound.play(song.sound) + local min, sec = song.length:match('(%d+):(%d+)') + local length = tonumber(min)*60 + tonumber(sec) + print(string.format('Playing %s (%s)', song.sound, song.length)) + os.sleep(length + 3) end diff --git a/games/etc/apps.db b/games/etc/apps.db index 91ce470..e1eebd9 100644 --- a/games/etc/apps.db +++ b/games/etc/apps.db @@ -14,4 +14,9 @@ category = "Games", run = "https://pastebin.com/raw/skcs9x1s", }, + [ "soundPlayer" ] = { + title = "Sounds", + category = "System", + run = "SoundPlayer", + }, } diff --git a/games/etc/sounds.txt b/games/etc/sounds.txt new file mode 100644 index 0000000..0498653 --- /dev/null +++ b/games/etc/sounds.txt @@ -0,0 +1,498 @@ +block.anvil.break +block.anvil.destroy +block.anvil.fall +block.anvil.hit +block.anvil.land +block.anvil.place +block.anvil.step +block.anvil.use +block.boat.place +entity.boat.paddle_land +entity.boat.paddle_water +block.brewing_stand.brew +block.chest.close +block.chest.locked +block.chest.open +block.cloth.break +block.cloth.fall +block.cloth.hit +block.cloth.place +block.cloth.step +block.comparator.click +block.dispenser.dispense +block.dispenser.fail +block.dispenser.launch +block.enchantment_table.use +block.end_gateway.spawn +block.end_portal.spawn +block.end_portal_frame.fill +block.enderchest.close +block.enderchest.open +block.fence_gate.close +block.fence_gate.open +block.fire.ambient +block.fire.extinguish +block.furnace.fire_crackle +block.glass.break +block.glass.fall +block.glass.hit +block.glass.place +block.glass.step +block.grass.break +block.grass.fall +block.grass.hit +block.grass.place +block.grass.step +block.gravel.break +block.gravel.fall +block.gravel.hit +block.gravel.place +block.gravel.step +block.iron_door.close +block.iron_door.open +block.ladder.break +block.ladder.fall +block.ladder.hit +block.ladder.place +block.ladder.step +block.lava.ambient +block.lava.extinguish +block.lava.pop +block.lever.click +block.metal.break +block.metal.fall +block.metal.hit +block.metal.place +block.metal.step +block.metal_pressureplate.click_off +block.metal_pressureplate.click_on +block.note.basedrum +block.note.bass +block.note.bell +block.note.chime +block.note.flute +block.note.guitar +block.note.harp +block.note.hat +block.note.pling +block.note.snare +block.note.xylophone +block.piston.contract +block.piston.extend +block.portal.ambient +block.portal.travel +block.portal.trigger +block.redstone_torch.burnout +block.sand.break +block.sand.fall +block.sand.hit +block.sand.place +block.sand.step +block.shulker_box.close +block.shulker_box.open +block.slime.break +block.slime.fall +block.slime.hit +block.slime.place +block.slime.step +block.snow.break +block.snow.fall +block.snow.hit +block.snow.place +block.snow.step +block.stone.break +block.stone.fall +block.stone.hit +block.stone.place +block.stone.step +block.stone_button.click_off +block.stone_button.click_on +block.stone_pressureplate.click_off +block.stone_pressureplate.click_on +block.wooden_trapdoor.close +block.wooden_trapdoor.open +block.iron_trapdoor.close +block.iron_trapdoor.open +block.tripwire.attach +block.tripwire.click_off +block.tripwire.click_on +block.tripwire.detach +block.water.ambient +block.waterlily.place +block.wood.break +block.wood.fall +block.wood.hit +block.wood.place +block.wood.step +block.wood_button.click_off +block.wood_button.click_on +block.wood_pressureplate.click_off +block.wood_pressureplate.click_on +block.wooden_door.close +block.wooden_door.open +entity.arrow.hit +entity.arrow.shoot +entity.arrow.successful_hit +entity.bat.ambient +entity.armorstand.break +entity.armorstand.fall +entity.armorstand.hit +entity.armorstand.place +entity.bat.death +entity.bat.hurt +entity.bat.takeoff +entity.blaze.ambient +entity.blaze.burn +entity.blaze.death +entity.blaze.hurt +entity.blaze.shoot +entity.bobber.splash +entity.bobber.throw +entity.bobber.retrieve +entity.cat.ambient +entity.cat.death +entity.cat.hiss +entity.cat.hurt +entity.cat.purr +entity.cat.purreow +entity.chicken.ambient +entity.chicken.death +entity.chicken.egg +entity.chicken.hurt +entity.chicken.step +entity.cow.ambient +entity.cow.death +entity.cow.hurt +entity.cow.milk +entity.cow.step +entity.creeper.death +entity.creeper.hurt +entity.creeper.primed +entity.donkey.ambient +entity.donkey.angry +entity.donkey.chest +entity.donkey.death +entity.donkey.hurt +entity.egg.throw +entity.elder_guardian.ambient +entity.elder_guardian.ambient_land +entity.elder_guardian.curse +entity.elder_guardian.death +entity.elder_guardian.death_land +entity.elder_guardian.hurt +entity.elder_guardian.hurt_land +entity.enderdragon.ambient +entity.enderdragon.death +entity.enderdragon.flap +entity.enderdragon.growl +entity.enderdragon.hurt +entity.enderdragon.shoot +entity.enderdragon_fireball.explode +entity.endereye.launch +entity.endereye.death +entity.endermen.death +entity.endermen.hurt +entity.endermen.scream +entity.endermen.stare +entity.endermen.teleport +entity.endermite.ambient +entity.endermite.death +entity.endermite.hurt +entity.endermite.step +entity.enderpearl.throw +entity.evokation_illager.ambient +entity.evokation_illager.hurt +entity.evokation_illager.death +entity.evokation_illager.cast_spell +entity.evokation_illager.prepare_attack +entity.evokation_illager.prepare_summon +entity.evokation_illager.cast_spell +entity.evokation_fangs.attack +entity.experience_bottle.throw +entity.experience_orb.pickup +entity.firework.blast +entity.firework.blast_far +entity.firework.large_blast +entity.firework.large_blast_far +entity.firework.launch +entity.firework.shoot +entity.firework.twinkle +entity.firework.twinkle_far +entity.generic.big_fall +entity.generic.burn +entity.generic.death +entity.generic.drink +entity.generic.eat +entity.generic.explode +entity.generic.extinguish_fire +entity.generic.hurt +entity.generic.small_fall +entity.generic.splash +entity.generic.swim +entity.ghast.ambient +entity.ghast.death +entity.ghast.hurt +entity.ghast.shoot +entity.ghast.warn +entity.guardian.ambient +entity.guardian.ambient_land +entity.guardian.attack +entity.guardian.death +entity.guardian.death_land +entity.guardian.flop +entity.guardian.hurt +entity.guardian.hurt_land +entity.horse.ambient +entity.horse.angry +entity.horse.armor +entity.horse.breathe +entity.horse.death +entity.horse.eat +entity.horse.gallop +entity.horse.hurt +entity.horse.jump +entity.horse.land +entity.horse.saddle +entity.horse.step +entity.horse.step_wood +entity.hostile.big_fall +entity.hostile.death +entity.hostile.hurt +entity.hostile.hurt +entity.hostile.splash +entity.hostile.swim +entity.husk.ambient +entity.husk.death +entity.husk.hurt +entity.husk.step +entity.illusion_illager.ambient +entity.illusion_illager.cast_spell +entity.illusion_illager.death +entity.illusion_illager.hurt +entity.illusion_illager.mirror_moveentity.illusion_illager.prepare_blindness +entity.illusion_illager.prepare_mirror +entity.irongolem.attack +entity.irongolem.death +entity.irongolem.hurt +entity.irongolem.step +entity.item.break +entity.item.pickup +entity.itemframe.add_item +entity.itemframe.break +entity.itemframe.place +entity.itemframe.remove_item +entity.itemframe.rotate_item +entity.llama.ambient +entity.llama.angry +entity.llama.death +entity.llama.eat +entity.llama.hurt +entity.llama.spit +entity.llama.step +entity.llama.swag +entity.leashknot.break +entity.leashknot.place +entity.lightning.impact +entity.lightning.thunder +entity.lingeringpotion.throw +entity.magmacube.death +entity.magmacube.hurt +entity.magmacube.jump +entity.magmacube.squish +entity.minecart.inside +entity.minecart.riding +entity.mooshroom.shear +entity.mule.ambient +entity.mule.death +entity.mule.hurt +entity.painting.break +entity.painting.place +entity.parrot.ambient +entity.parrot.death +entity.parrot.eat +entity.parrot.fly +entity.parrot.hurt +entity.parrot.step +entity.pig.ambient +entity.pig.death +entity.pig.hurt +entity.pig.saddle +entity.pig.step +entity.player.attack.crit +entity.player.attack.knockback +entity.player.attack.nodamage +entity.player.attack.strong +entity.player.attack.sweep +entity.player.attack.weak +entity.player.big_fall +entity.player.burp +entity.player.death +entity.player.hurt +entity.player.levelup +entity.player.small_fall +entity.player.splash +entity.player.swim +entity.polar_bear.ambient +entity.polar_bear.baby_ambient +entity.polar_bear.death +entity.polar_bear.hurt +entity.polar_bear.step +entity.polar_bear.warning +entity.rabbit.attack +entity.rabbit.ambient +entity.rabbit.death +entity.rabbit.hurt +entity.rabbit.jump +entity.sheep.death +entity.sheep.hurt +entity.sheep.shear +entity.sheep.step +entity.shield.break +entity.shield.block +entity.shulker.ambient +entity.shulker_bullet.hit +entity.shulker_bullet.hurt +entity.shulker.death +entity.shulker.close +entity.shulker.hit +entity.shulker.hurt +entity.shulker.hurt_closed +entity.shulker.shoot +entity.shulker.teleport +entity.silverfish.ambient +entity.silverfish.death +entity.silverfish.hurt +entity.silverfish.step +entity.skeleton.ambient +entity.skeleton.death +entity.skeleton.hurt +entity.skeleton.shoot +entity.skeleton.step +entity.skeleton_horse.ambient +entity.skeleton_horse.death +entity.skeleton_horse.hurt +entity.slime.attack +entity.slime.death +entity.slime.hurt +entity.slime.jump +entity.slime.squish +entity.small_magmacube.death +entity.small_magmacube.hurt +entity.small_magmacube.squish +entity.small_slime.death +entity.small_slime.hurt +entity.small_slime.squish +entity.snowball.throw +entity.snowman.ambient +entity.snowman.death +entity.snowman.hurt +entity.snowman.shoot +entity.spider.ambient +entity.spider.death +entity.spider.hurt +entity.spider.step +entity.splash_potion.break +entity.splash_potion.throw +entity.squid.ambient +entity.squid.death +entity.squid.hurt +entity.stray.ambient +entity.stray.death +entity.stray.hurt +entity.stray.step +entity.tnt.primed +entity.vex.ambient +entity.vex.charge +entity.vex.hurt +entity.vex.death +entity.vindication_illager.ambient +entity.vindication_illager.hurt +entity.vindication_illager.death +entity.villager.ambient +entity.villager.death +entity.villager.hurt +entity.villager.no +entity.villager.trading +entity.villager.yes +entity.witch.ambient +entity.witch.death +entity.witch.drink +entity.witch.hurt +entity.witch.throw +entity.wither.ambient +entity.wither.break_block +entity.wither.death +entity.wither.hurt +entity.wither.shoot +entity.wither.spawn +entity.wither_skeleton.ambient +entity.wither_skeleton.death +entity.wither_skeleton.hurt +entity.wither_skeleton.step +entity.wolf.ambient +entity.wolf.death +entity.wolf.growl +entity.wolf.hurt +entity.wolf.pant +entity.wolf.shake +entity.wolf.step +entity.wolf.whine +entity.zombie.ambient +entity.zombie.attack_door_wood +entity.zombie.attack_iron_door +entity.zombie.break_door_wood +entity.zombie.cure +entity.zombie.death +entity.zombie.hurt +entity.zombie.step +entity.zombie_horse.ambient +entity.zombie_horse.death +entity.zombie_horse.hurt +entity.zombie.infect +entity.zombie_pig.ambient +entity.zombie_pig.angry +entity.zombie_pig.death +entity.zombie_pig.hurt +enchant.thorns.hit +music.creative +music.credits +music.dragon +music.end +music.game +music.menu +music.nether +record.11 +record.13 +record.blocks +record.cat +record.chirp +record.far +record.mall +record.mellohi +record.stal +record.strad +record.wait +record.ward +item.armor.equip_chain +item.armor.equip_diamond +item.armor.equip_generic +item.armor.equip_gold +item.armor.equip_iron +item.armor.equip_leather +item.bottle.fill +item.bottle.fill_dragonbreath +item.bucket.empty +item.bucket.empty_lava +item.bucket.fill +item.bucket.fill_lava +item.chorus_fruit.teleport +item.elytra.flying +item.firecharge.use +item.flintandsteel.use +item.hoe.till +item.shovel.flatten +item.totem.use +weather.rain +weather.rain.above +ambient.cave +ui.button.click \ No newline at end of file diff --git a/milo/apis/milo.lua b/milo/apis/milo.lua index e993e61..d007ef4 100644 --- a/milo/apis/milo.lua +++ b/milo/apis/milo.lua @@ -217,7 +217,7 @@ end function Milo:eject(item, count) count = self.context.storage:export(self.context.turtleInventory, nil, count, item) - Sound.play('ui.button.click') + Sound.play('entity.experience_bottle.throw') turtle.emptyInventory() return count end diff --git a/milo/plugins/craftTask.lua b/milo/plugins/craftTask.lua index 5763fc5..09dd3d2 100644 --- a/milo/plugins/craftTask.lua +++ b/milo/plugins/craftTask.lua @@ -46,7 +46,7 @@ function craftTask:cycle() if recipe then if not item.notified then - Sound.play('entity.experience_orb.pickup') + Sound.play('block.end_portal_frame.fill') item.notified = true end diff --git a/swshop/shopView.lua b/swshop/shopView.lua index 075bc6c..33760ce 100644 --- a/swshop/shopView.lua +++ b/swshop/shopView.lua @@ -195,7 +195,7 @@ Event.on('shop_provide', function(_, item, quantity, uid) Milo:queueRequest({ }, function() local count = Milo:eject(itemDB:splitKey(item), quantity) os.queueEvent('shop_provided', uid, count) - Sound.play('entity.villager.yes') + Sound.play('entity.player.levelup') end) end)