Postado Junho 20, 2015 9 anos Olá, pessoal, seguinte, consegui fazer funcionar os soms, tanto com ações quanto com posições, porém, se eu adicionar mais de 1 posição para tocar música, ele buga e não toca nenhuma das duas, ou então fica repetindo a ultima sempre apenas o primeiro segundo. Poderiam me ajudar?? Segue: SOUNDS = {--area sounds {fromPos = {x = 94, y = 55, z = 8}, toPos = {x = 159, y = 76, z = 8}, sound = "caverna01.ogg"}, } Se eu fizer isso: SOUNDS = {--area sounds {fromPos = {x = 94, y = 55, z = 8}, toPos = {x = 159, y = 76, z = 8}, sound = "caverna01.ogg"}, {fromPos = {x = 157, y = 42, z = 7}, toPos = {x = 168, y = 56, z = 7}, sound = "startup.ogg"}, } Ocorre o erro que descrevi. Obrigado a quem puder me ajduar xBlackWolf THX @Storm Night Best Avatar Ever
Postado Junho 20, 2015 9 anos Tenta pegar essa base aqui: SOUNDS_CONFIG = { soundChannel = SoundChannels.Music, checkInterval = 500, folder = 'music/', noSound = 'No sound file for this area.', } SOUNDS = { -- Lavender town {fromPos = {x=1177, y=1037, z=8}, toPos = {x=1206, y=1047, z=8}, priority = 1, sound="lavender.ogg"}, {fromPos = {x=1192, y=1038, z=7}, toPos = {x=1252, y=1085, z=7}, priority = 1, sound="lavender.ogg"}, -- Cp -- Cerulean {fromPos = {x=1054, y=898, z=7}, toPos = {x=1067, y=908, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, {fromPos = {x=1057, y=892, z=7}, toPos = {x=1062, y=897, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, -- Pewter {fromPos = {x=712, y=845, z=7}, toPos = {x=728, y=852, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, {fromPos = {x=712, y=845, z=7}, toPos = {x=728, y=852, z=6}, priority = 1, sound="Centro Pokemon.ogg"}, -- Viridian {fromPos = {x=699, y=1084, z=7}, toPos = {x=714, y=1091, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, -- Saffron {fromPos = {x=1047, y=1041, z=7}, toPos = {x=1061, y=1052, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, {fromPos = {x=1062, y=1044, z=7}, toPos = {x=1075, y=1048, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, {fromPos = {x=1064, y=1049, z=7}, toPos = {x=1075, y=1062, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, {fromPos = {x=1047, y=1040, z=6}, toPos = {x=1061, y=1052, z=6}, priority = 1, sound="Centro Pokemon.ogg"}, -- Vermilion {fromPos = {x=1066, y=1231, z=7}, toPos = {x=1081, y=1246, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, -- Fuchsia {fromPos = {x=1208, y=1319, z=7}, toPos = {x=1220, y=1328, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, -- Cinnabar {fromPos = {x=843, y=1394, z=7}, toPos = {x=854, y=1407, z=7}, priority = 1, sound="Centro Pokemon.ogg"}, -- Celadon {fromPos = {x=858, y=1093, z=6}, toPos = {x=866, y=1104, z=6}, priority = 1, sound="Centro Pokemon.ogg"}, -- Snow {fromPos = {x=1399, y=1540, z=7}, toPos = {x=1485, y=1639, z=7}, priority = 1, sound="Snow City.ogg"}, {fromPos = {x=1420, y=1588, z=7}, toPos = {x=1452, y=1612, z=7}, priority = 1, sound="Snow City.ogg"}, } ---------- -- Sound local rcSoundChannel local showPosEvent local playingSound -- Design soundWindow = nil soundButton = nil function toggle() if soundButton:isOn() then soundWindow:close() soundButton:setOn(false) else soundWindow:open() soundButton:setOn(true) end end function onMiniWindowClose() soundButton:setOn(false) end function init() for i = 1, #SOUNDS do SOUNDS.sound = SOUNDS_CONFIG.folder .. SOUNDS.sound end connect(g_game, { onGameStart = onGameStart, onGameEnd = onGameEnd }) rcSoundChannel = g_sounds.getChannel(SOUNDS_CONFIG.soundChannel) -- rcSoundChannel:setGain(value/COUNDS_CONFIG.volume) --soundButton = modules.client_topmenu.addRightGameToggleButton('soundButton', tr('Sound Info') .. '', '/images/audio', toggle) --soundButton:setOn(true) soundWindow = g_ui.loadUI('rcsound', modules.game_interface.getRightPanel()) soundWindow:disableResize() soundWindow:setup() if(g_game.isOnline()) then onGameStart() end end function terminate() disconnect(g_game, { onGameStart = onGameStart, onGameEnd = onGameEnd }) onGameEnd() soundWindow:destroy() soundButton:destroy() end function onGameStart() stopSound() toggleSoundEvent = addEvent(toggleSound, SOUNDS_CONFIG.checkInterval) end function onGameEnd() stopSound() removeEvent(toggleSoundEvent) end function isInPos(pos, fromPos, toPos) return pos.x>=fromPos.x and pos.y>=fromPos.y and pos.z>=fromPos.z and pos.x<=toPos.x and pos.y<=toPos.y and pos.z<=toPos.z end function toggleSound() local player = g_game.getLocalPlayer() if not player then return end local pos = player:getPosition() local toPlay = nil for i = 1, #SOUNDS do if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then if(toPlay) then toPlay.priority = toPlay.priority or 0 if((toPlay.sound~=SOUNDS.sound) and (SOUNDS.priority>toPlay.priority)) then toPlay = SOUNDS end else toPlay = SOUNDS end end end playingSound = playingSound or {sound='', priority=0} if(toPlay~=nil and playingSound.sound~=toPlay.sound) then g_logger.info("RC Sounds: New sound area detected:") g_logger.info(" Position: {x=" .. pos.x .. ", y=" .. pos.y .. ", z=" .. pos.z .. "}") g_logger.info(" Music: " .. toPlay.sound) stopSound() playSound(toPlay.sound) playingSound = toPlay elseif(toPlay==nil) and (playingSound.sound~='') then g_logger.info("RC Sounds: New sound area detected:") g_logger.info(" Left music area.") stopSound() end toggleSoundEvent = scheduleEvent(toggleSound, SOUNDS_CONFIG.checkInterval) end function playSound(sound) rcSoundChannel:enqueue(sound, 0) setLabel(clearName(sound)) end function clearName(soundName) local explode = string.explode(soundName, "/") soundName = explode[#explode] explode = string.explode(soundName, ".ogg") soundName = '' for i = 1, #explode-1 do soundName = soundName .. explode end return soundName end function stopSound() setLabel(SOUNDS_CONFIG.noSound) rcSoundChannel:stop() playingSound = nil end function setLabel(str) soundWindow:recursiveGetChildById('currentSound'):getChildById('value'):setText(str) end - Axo que esta faltando por isso na tabela Sounds: priority = 1, (Prioridade 1 ou 2 ou 3......) - Ficando assim: SOUNDS = {--area sounds {fromPos = {x = 94, y = 55, z = 8}, toPos = {x = 159, y = 76, z = 8}, priority = 1,sound = "caverna01.ogg"}, {fromPos = {x = 157, y = 42, z = 7}, toPos = {x = 168, y = 56, z = 7},priority = 1, sound = "startup.ogg"}, } Editado Junho 20, 2015 9 anos por Nextbr (veja o histórico de edições)
Postado Junho 20, 2015 9 anos Autor Não adiantou... no caso a segunda musica buga, e fica repetindo pra sempre apenas o 1 segundo, e a outra nem toca. xBlackWolf THX @Storm Night Best Avatar Ever
Postado Junho 20, 2015 9 anos Não adiantou... no caso a segunda musica buga, e fica repetindo pra sempre apenas o 1 segundo, e a outra nem toca. Posta seu rcsound.lua pra eu ver
Postado Junho 20, 2015 9 anos Autor Eu utilizo o Advanced Sound: Portanto, arquivo Adsound.lua require('advsound') require('ex') SOUNDS_CONFIG = { folder = 'mods/Advanced Sound/audio/', loop=false, start_paused=false, checkInterval = 500, } local UPDATESOUND_OPCODE = 85 local PAUSESOUND_OPCODE = 81 SOUNDS = {--area sounds {fromPos = {x = 157, y = 42, z = 7}, toPos = {x = 168, y = 56, z = 7}, priority = 1, sound = "startup.ogg"}, } local toggleSoundEvent local e local audio = nil local window = nil local volume = 100 local str function init() connect(g_game, { onGameEnd = terminate }) window = modules.client_options.audioPanel str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":") volume = tonumber(str[2]) ProtocolGame.registerExtendedOpcode(UPDATESOUND_OPCODE, getSound) ProtocolGame.registerExtendedOpcode(PAUSESOUND_OPCODE, pauseSound) e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval) end function iniciar() if (g_game.isOnline()) then removeEvent(e) toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval) end end local m function startAsound() local player = g_game.getLocalPlayer() if not player then return end local pos = player:getPosition() for i = 1, #SOUNDS do if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then if audio == nil then m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS[i].sound, true, SOUNDS_CONFIG.start_paused) str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":") volume = tonumber(str[2]) advsound.setVolume(m, volume/100) audio = true end else audio = nil advsound.setPaused(m, true) removeEvent(toggleSoundEvent) end end toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval) end local music function getSound(protocol, opcode, buffer) local cof = string.explode(buffer, "|") local conff = { ["true"] = true, ["false"] = false, } music = advsound.playMusic(SOUNDS_CONFIG.folder..cof[1], conff[cof[2]], SOUNDS_CONFIG.start_paused) str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":") volume = tonumber(str[2]) advsound.setVolume(music, volume/100) end function pauseSound(protocol, opcode, buffer) if opcode == 81 then advsound.pauseAll() end end function terminate() disconnect(g_game, { onGameEnd = terminate }) e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval) audio = nil advsound.pauseAll() end function isInPos(pos, fromPos, toPos) return pos.x>=fromPos.x and pos.y>=fromPos.y and pos.z>=fromPos.z and pos.x<=toPos.x and pos.y<=toPos.y and pos.z<=toPos.z end xBlackWolf THX @Storm Night Best Avatar Ever
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.