Scripts / Add sound when selecting something in main menu

Author
Message
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 26th Jul 2016 16:51
Hi Guys

I have a simple question, is it possible to add a sound, when you select something in the main menu of standalone version?
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 26th Jul 2016 17:32 Edited at: 26th Jul 2016 17:34
Do you mean playing a sound when a button is clicked/hovered?
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 26th Jul 2016 17:46
yeah a sound for clicking and a sound for hovering would be cool !! Is that possible?
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 26th Jul 2016 18:37 Edited at: 26th Jul 2016 18:40
I think that is possible! I'll give you some general guidelines. I've not tested it myself so a little tweaking may be required...

First of all you'll have to open the Titlesbank\default\title.lua file (or any other, but I'll be editing this one).

Scroll down to the main section of the script. You'll see the following:

and:


The first snippet handles the hovering over a button, the second for the actual click. So we will paste the code for playing a sound here.

Second we need to actually load and play the sound, so here's how to do that (thanks to the new commands):
1) In the init part of the script we will load the sound:


2) Play the sound

With sound index being 0 for the hover sound and 1 for the click sound.

3) Place the PlaySound command in the title.lua file like so:



And that should do it... Make sure to back up your files, because they are replaced with every update. You can always make your own style by creating a new folder in the Titlesbank and replace the content of the file style.txt with the name of your new folder.


Hope this helps
PM
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 26th Jul 2016 18:44 Edited at: 26th Jul 2016 18:45
While reviewing I realize that the hover sound will keep looping when hovering a button so you'll need to create a variable that indicates if the button is already hovered. Also the command for playing the sound on hover should not be in the loop:



PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 26th Jul 2016 18:55
Thank you very much ! I will check it out as soon as I got the time.
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 26th Jul 2016 22:18
hmm.... even though you gave me very detailed instructions on how to do it, i am still having a hard time figuring out where to place some lines. Would you mind sending me your title.lua so I can check what I did wrong?
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 26th Jul 2016 22:33


This shoul be it...
Hope it works!
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 26th Jul 2016 23:00
Thank you very much !!
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jul 2016 10:53
I have tried everything.. I always get the message: "Runtime Error 3002 (title_init).

even when I use your title.lua and not my custom one..
I'm starting to get frustrated here... such a small thing and I cant seem to get it done..
Do you have an idea maybe?
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 29th Jul 2016 12:11
Are your paths formatted correctly? Can you post them here?
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jul 2016 18:56
I only have this working title.lua wich i use right now.
It adds a music to the game and disables the movement of the title "picture".
Maybe you find whats wrong...

Attachments

Login to view attachments
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jul 2016 18:56
I deleted the one I changed, sorry :/
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 29th Jul 2016 19:58 Edited at: 29th Jul 2016 19:59
And that one works?
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jul 2016 20:43
yeah it works fine.
brco900033
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 22nd Jul 2014
Location: Belgium
Posted: 30th Jul 2016 00:25
Can you make your version again so I can check it out and maybe find the problem?
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 30th Jul 2016 07:31
okay will do. Thanks for willing top help me, just give me some time
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 30th Jul 2016 08:48
Okay so I made it again. There is no Problem running the game now, but the menu music doesnt play anymore and the hover sounds and stuff dont work either..
What did I do wrong?

Attachments

Login to view attachments
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 30th Jul 2016 10:00
so.. I tried it again because I wanted to check something out, and now I got the error message Runtime Error 3002 (title_init). again.
but i did no changes to the title.lua
strange..
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 6th Aug 2016 11:31
Is there really no solution to this? Damn... that would have been so cool.
synchromesh
Forum Support
10
Years of Service
User Offline
Joined: 24th Jan 2014
Location:
Posted: 6th Aug 2016 11:39
This may be added when the Menu editor is incorporated ...
The only person ever to get all his work done by "Friday" was Robinson Crusoe..
PM
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 6th Aug 2016 18:24
okay
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 7th Aug 2016 16:15
Looking at your last script you posted, I noticed a path error in declaring your global sounds.
First thing to note is that it is best to place your sounds in the audiobank folder, in a sub folder or your choice.

The engine looks here by default for all audio files. This simplifies the pathing issue in LUA scripting greatly.

Your code:

function title_init()
--load my music/sounds
LoadGlobalSound("C:titlesbank\\default\\click.wav",0)
LoadGlobalSound("C:titlesbank\\default\\select.wav",1)
LoadGlobalSound( "C:titlesbank\\default\\title.ogg", 1 )
LoopGlobalSound ( 1 )

Your path indicates that you want to call a file on the C drive in a folder called titlebank in a folder called default under that.

If you open the file explorer and go to c: drive. Scroll down the folder side and you will see that there is not a titlebank folder there.

So under the game guru folder there is a folder called audiobank.
In file explorer create a folder called mygamemenu.
Place you audio files for the menu there.

Change the code in your script to:
LoadGlobalSound("audiobank\\mygamemenu\\click.wav",0)

See if this will play the sounds now. If not then try to remove the audiobank part. save the script. Save the map level. Build stand alone again and retest.

Once the pathing issue to the sound files is resolved then this should work.

Make sure your sounds are 22,000k mono files if you made them yourself.


Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 7th Aug 2016 19:54
Thank you very much ! I will try it now.
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 7th Aug 2016 20:16
Did I do something wrong?
I'm getting title_ init runtime error again...

Attachments

Login to view attachments
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 8th Aug 2016 03:59
I am looking at the script and running it thru some tests.

I am going to move this thread to the script board. It should get a bit more attention there.

Hard to diagnose this kind of issue for a stand alone. So it will be a lot of trial and error to I get the pathing straightened out.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 8th Aug 2016 12:32
I really apreciate it ! Thanks for helping me. Hopefully we can fix it

Login to post a reply

Server time is: 2024-05-04 02:00:59
Your offset time is: 2024-05-04 02:00:59