Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Jose on February 13, 2011, 04:57:12 PM

Title: PlaySoundEvent in scene_init
Post by: Jose on February 13, 2011, 04:57:12 PM
Hi,

I've trying to use the PlaySoundEvent method in an scene_init.script but it seems that the event never rises. I've tried with this.PlaySoundEvent() and also creating an entity and executing the PlaySoundEvent from the entity but the event had been never rised.

If I execute the PlaySoundEvent from a script attached to a scene region entity then the event rises fine.

Anyone can help me?

Thanks in advance.
Title: Re: PlaySoundEvent in scene_init
Post by: Mnemonic on February 13, 2011, 06:09:51 PM
How exactly are you using the function? The event is triggered in the object that's used to play sound. So if you use "this.PlaySoundEvent()" in scene_init.script, "this" is a scene, so the event is triggered in scripts attached to a scene.

Code: WME Script
  1. this.PlaySoundEvent("sound.ogg", "SomeEvent");
  2.  
  3. on "SomeEvent"
  4. {
  5.   Game.Msg("blah");
  6. }
  7.  

This should work.
Title: Re: PlaySoundEvent in scene_init
Post by: Jose on February 13, 2011, 06:19:02 PM
Hi Mnemonic I've a scene_init.script like that

Code: [Select]

#include "scripts\base.inc"

// here comes the stuff which initializes the scene

this.PlaySoundEvent("music\intro\intro.ogg", "soundOver");

////////////////////////////////////////////////////////////////////////////////
on "soundOver"
{
    Game.Msg("On event");
}

////////////////////////////////////////////////////////////////////////////////
// scene state
global Stateintro;


// default values
if(Stateintro==null)
{
  Stateintro.Visited = false;
  // add scene states here
}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables



////////////////////////////////////////////////////////////////////////////////
if(!Stateintro.Visited)
{
  Stateintro.Visited = true;

  // this is our first visit in this scene...
}


but when the game run, on that scene I can hear the sound but I can't see the message. Even if I set a breakpoint on the Game.Msg line the game doesn't stop on it.
Title: Re: PlaySoundEvent in scene_init
Post by: Mnemonic on February 13, 2011, 06:23:11 PM
Well, if this doesn't work, it's a bug, I'm afraid.
Title: Re: PlaySoundEvent in scene_init
Post by: Jose on February 13, 2011, 06:29:50 PM
OK, I'll try to find a workaround  ;)

Thanx!
Title: Re: PlaySoundEvent in scene_init
Post by: Mnemonic on February 13, 2011, 06:42:16 PM
It does seem to work for entities, only scene has a problem.
Title: Re: PlaySoundEvent in scene_init
Post by: Jose on February 13, 2011, 07:15:30 PM
Yes, but only for entities created in Scene Editor. If you create it dynamically, for example in scene_init.script, it does neither work I think...
Title: Re: PlaySoundEvent in scene_init
Post by: eborr on February 13, 2011, 10:11:22 PM
maybe I am missing something really obvious, whynot just

Scene.PlaySoundEvent()
Title: Re: PlaySoundEvent in scene_init
Post by: Jose on February 13, 2011, 11:44:10 PM
I'm afraid it doesn't work either eborr...