Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: brankomaster on July 06, 2014, 12:00:16 AM

Title: music restarts
Post by: brankomaster on July 06, 2014, 12:00:16 AM
i've used next method to examine objects in inventory (e.g. read a book):
(in items/book script)
/on "LookAt"/
{
  Game.ChangeScene("scenes\bookopen\bookopen.scene");

   Game.DropItem("book");

}

/and added next script for the bookopen scene init script/

on "LeftClick"
{


    Game.ChangeScene(Game.PrevSceneFilename);
   //
    Game.TakeItem("book");
  var EntBook = Scene.GetNode("book");
  EntBook.Active = false;
   //
}

 and its working perfect, problem is because game change to prev scene but music is also reloaded, is it possible to add script to avoid music playback interruption , i use this script to attach music for scene ( scene init script)

Game.PlayMusicChannel(0,"sounds\Salex1d.ogg",true);
  Game.SetMusicChannelVolume(0,70);

Title: Re: music restarts
Post by: Azrael on July 06, 2014, 07:02:29 AM
It's restarting because you make it restart everytime the scene is loaded :)
Before making the music start you should check if a music is playing and if it's the right music. Something like that should work:

Code: WME Script
  1. if (Game.IsMusicPlaying() && Game.GetMusic() != "sounds\Salex1d.ogg")
  2.         {
  3.         Game.PlayMusicChannel(0, "sounds\Salex1d.ogg", true);
  4.         Game.SetMusicChannelVolume(0,70);
  5.         }
  6. else if (!Game.IsMusicPlaying())
  7.         {
  8.         Game.PlayMusicChannel(0, "sounds\Salex1d.ogg", true);
  9.         Game.SetMusicChannelVolume(0,70);
  10.         }
  11.  
Title: Re: music restarts
Post by: brankomaster on July 06, 2014, 12:34:43 PM
Thank you very much!! just one more question with my script for zooming inventory items , to avoid user to click again on the book inventory icon while zoomed scene is already opened i've used /Game.DropItem("book");/ and its working ok user cant interact with book item, but on command you can see book appearing on the screen for a fraction of the second and i dont like it. Can you help me to write script to avoid user to click on the book inventory icon while bookopen.scene is active (add command to bookopen.scene init script??), something do disable any interaction with it or to hide it from the inventory and then when executing
on  "LeftClick"
{


    Game.ChangeScene(Game.PrevSceneFilename);
   //
    Game.TakeItem("book");
  var EntBook = Scene.GetNode("book");
  EntBook.Active = false;
   //
},

to show/enable it again.
in short i need some elegant solution.
Title: Re: music restarts
Post by: Azrael on July 06, 2014, 03:25:36 PM
I don't like too much the idea of dropping the item and then take it again:)
You should look to documentation, when i was developing our game i found very useful "wme.chm" the is located on the folder in which you have installed wme.

In the left column if you click on "Scripting in WME" and then on "Script language reference" you can find reference of quite everything you could need.
For example under "Item object" i see some attributes like "Active" or also maybe better "Interactive" than could be perfect for what you need.

Possible solution are many ;)
Title: Re: music restarts
Post by: Azrael on July 06, 2014, 03:30:02 PM
Oh and please 2 things :)

First please open a new post if you need help for something different than the main post subjects, so is easier for other people to find it. Maybe other could be have the same problem ;)
Second please use the "WME script" code when you post some of your code, is easier to read. You have simply to select the code and then select "WME script" from the Code menu when you write a post (it's on the same line of font size and color).

Thanks ;)