Author Topic: Music volume  (Read 1948 times)

Ataosama

  • Cherry Eater
  • Posts: 60
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Firefox 40.0 Firefox 40.0
    • View Profile
  • Playstyle: Keyboard
Music volume
« on: August 23, 2015, 06:38:10 AM »
Hello, when I want to lower the volume of a music I use this code : sound_volume(music, number).

The problem is that when I restart, the volume doesn't go back to 1 (100%), so how could I do that ? (I use the yuuutu engine, if that matters)

Derf

  • Guest
Re: Music volume
« Reply #1 on: August 23, 2015, 07:04:42 AM »
You have to use a global variable instead that is saved and loaded in the save and load scripts.

Looking in the respective scripts for how they handle said variables and it should be as easy as copy and pasting over the code and adjusting it slightly. Remember to initialise the variable at the start of the game at the default volume before the game loads the variables though.

Incidentally I used Yuuutu for a previous project and it is by far my least favourite engine, pointless bloated and over-complicated. Most of my time was spent rewriting the saving/music systems etc.

Ataosama

  • Cherry Eater
  • Posts: 60
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Firefox 40.0 Firefox 40.0
    • View Profile
  • Playstyle: Keyboard
Re: Music volume
« Reply #2 on: August 23, 2015, 09:49:19 AM »
I started to program something like 2/3 weeks ago so sorry if I didn't understand what you mean but isn't that suppose to save the volume ?

My problem is that I don't know how to put the volume back at 100% when I press R/F2.

 I guess I could put "sound_volume(music, 1)" in the press R/F2 event for literally all my musics but there is probably a better way to do that.

Then sorry if what you said would solve my problem, like I said I'm new in programming :p

Derf

  • Guest
Re: Music volume
« Reply #3 on: August 23, 2015, 10:17:15 AM »
It's fine, everyone starts somewhere :~)

Here's what I would do:

I would initialise a variable in the script called "SetGlobalOption" called "global.vol" and set it to 100.

Then in the save and load scripts I'd copy over a chunk that's already written for you where it saves a variable already and change the part where it says "tem = room" to "tem = global.vol". I'm not on a computer with Yuutu right now so I can't copy and paste it but you should be able to find it easily enough. And if you do that correctly the game will save and load this variable.

The only other thing you need to do is make sure that every time it's changed/loaded you set the volume to that number. So your code for volume change would now be something like:

Code: [Select]
global.vol -= 1;
sound_volume(music,global.vol);

And the you'd probably have to add "sound_volume(music,global.vol);" to the loadGame script too.

Ataosama

  • Cherry Eater
  • Posts: 60
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Firefox 40.0 Firefox 40.0
    • View Profile
  • Playstyle: Keyboard
Re: Music volume
« Reply #4 on: August 25, 2015, 07:48:22 AM »
Well, I tried what you said and a lot of other things and I keep breaking my game so I'm just gonna give up and try to edit the song, or I'm gonna work on that when I have more experience otherwise I'm gonna kill someone. Thanks anyway for your help :p