Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: sound entity dont want play  (Read 6245 times)

0 Members and 1 Guest are viewing this topic.

Rocco

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • View Profile
    • Virtual-Illusion
sound entity dont want play
« on: November 26, 2005, 02:34:32 PM »

i tried the "normal" way of implementing a sound entity but it dont work.
I made a free sound entity, and it works perfect in scene edit (right path and all).
then i wrote
Code: [Select]
  var fire = Scene.GetNode("firesound");
  fire.PlaySound();

nothing happens, no error no sound.

if i do it with:
Code: [Select]
Game.PlaySound("sounds\feuerknistern-02.ogg",true);
or
Code: [Select]
var firedummy = Scene.CreateEntity();
firedummy.PlaySound("sounds\feuerknistern-02.ogg");

it works. any suggestion what the problem is with the free sound entity???
« Last Edit: November 27, 2005, 10:03:18 AM by Rocco »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: sound entity dont want play
« Reply #1 on: November 27, 2005, 01:06:53 PM »

Oops, it's a bug introduced in one of the latest versions. It will be fixed in the next release. Thanks for finding it.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Rocco

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • View Profile
    • Virtual-Illusion
Re: sound entity dont want play
« Reply #2 on: November 27, 2005, 02:33:06 PM »

ok, thx for answering.
i have the following problem now:

the firesound should be playing in a loop, while the fire burns.
this works very good the first time, i enter the scene.
but if i go to another scene and come back i get an error:

Runtime error. Script 'scenes\raum1\scr\scene_init.script', line 57
16:20:   Call to undefined method 'PlaySound'. Ignored.

scene init script:
Code: [Select]
global feuer;

// used for determine which scene is active
Scene.name = "Raum1";

// default values
if(Stateraum1==null)
{

  Stateraum1.Visited = false;

 
  Scene.CreateEntity("knistern");
  feuer.brennt = true;

  // add scene states here

}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables
  if(feuer.brennt)
  {
   var firedummy = Scene.GetNode("knistern");
   firedummy.PlaySound("sounds\feuerknistern-02.ogg",true); // this line only works the first time??
   }



////////////////////////////////////////////////////////////////////////////////
if(!Stateraum1.Visited)
{

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

what can i do to call this entity again, turn it on and off from this and other scripts??
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: sound entity dont want play
« Reply #3 on: November 27, 2005, 04:13:49 PM »

If you use Scene.CreateEntity(), the entity only "lives" until you leave the scene, then it's detroyed. So, you'd have to use either Game.CreateEntity() or create the scene entity everytime you enter the scene.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Rocco

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • View Profile
    • Virtual-Illusion
Re: sound entity dont want play
« Reply #4 on: November 27, 2005, 04:16:28 PM »

great thanks :-)
Logged

Rocco

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • View Profile
    • Virtual-Illusion
Re: sound entity dont want play
« Reply #5 on: November 27, 2005, 04:40:08 PM »

next problem,
i want to stop all sounds, when the player goes to the menu screen.
but i dont know how to manage these.

i tried
Game.StopSound();

and

var sound = Game.IsSoundPlaying();
sound.StopSound();

but didnt work
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: sound entity dont want play
« Reply #6 on: November 27, 2005, 04:54:25 PM »

next problem,
i want to stop all sounds, when the player goes to the menu screen.
but i dont know how to manage these.

i tried
Game.StopSound();

and

var sound = Game.IsSoundPlaying();
sound.StopSound();

but didnt work

Hi,

this can't work because IsSoundPlaying() returns only true or false.

Your supposed way would have been (providing you use the Game.CreateEntity)


var sound = Game.CreateEntity(); // proper place where you get the entity pointer

... // Some code here where you play the sound etc.etc.

if (sound.IsSoundPlaying()) // let's test if the sound didn't finish in the meantime
{
  sound.StopSound(); // Stop the sound.
}

It's untested but should work.

Edit: I've read it more carefully, so this is only partial answer to your question.

I am dealing with the very same issue using one simple daemon, which stores all sound pointers into an array and then
through a simple loop stops them so you can try something like the following pseudo code

for (var l1 =0; l1<Number_of_Sounds;l1 = l1+1)
{
 sound = sound_array[l1];
  if (sound.IsSoundPlaying()) // let's test if the sound didn't finish in the meantime
  {
    sound.StopSound(); // Stop the sound.
  }
}

It depends on your sound organization though.

Hope that helps.
« Last Edit: November 27, 2005, 04:59:21 PM by metamorphium »
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: sound entity dont want play
« Reply #7 on: November 27, 2005, 04:59:13 PM »

Anyway, if you display the menu window in exclusive mode (window.GoExclusive()) it should automatically freeze all sounds.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: sound entity dont want play
« Reply #8 on: November 27, 2005, 05:00:10 PM »

Anyway, if you display the menu window in exclusive mode (window.GoExclusive()) it should automatically freeze all sounds.

True, but I have separate scene for Menu Screen.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Rocco

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • View Profile
    • Virtual-Illusion
Re: sound entity dont want play
« Reply #9 on: November 27, 2005, 05:26:05 PM »

k, thanks, i use also a separate menu scene.
so my hope was for a command like StopAllSounds or similar.
Logged
 

Page created in 0.217 seconds with 24 queries.