Page 1 of 3

adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:17 am
by IronMaiden
Hi, Lets just start by saying I'm an old burnout that is just a script dummy.

However i love this game and i am working on making my own dungeon. I have a basic layout so far and in one room i put alcoves with nice loot and many secrets in order to open it. In this room on a floor tile I added the dungeon secret and i put over top of that the lua script to have it play a sound.
I keep getting errors. The wav file i want to play is in the mod_asset sound folder. I get the error in the editor : attempt to call global 'defineSound' (a nil value)
What is this dummy doing wrong?

here is the script i use

defineSound{
name = "Invader",
filename = "mod_assets/sounds/Invader.wav",
loop = false,
volume = 0.5,
minDistance = 30,
maxDistance = 32,

}

function playsound()
playSound("Invader")

end

Re: adding custome sound to a secret

Posted: Sun Oct 21, 2012 1:30 am
by Neikun
I don't know if this will do it but try

Code: Select all

function playInvader()
playSound("Invader")

end
I think I recall reading about something where if the function is named the same as the function it tries to do, it doesn't work.

EDIT: Also try renaming the sound from "Invader" to "invader" both in the definition and script.

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:41 am
by IronMaiden
Just tried that and get same error

I put all lower case i in all invader, still no go


Is there a limit on the length of a sound file? maybe thats what is wrong since i put a whole song in there?

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:50 am
by Neikun
No, that shouldn't be the problem.

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:53 am
by Komag
I think the whole part with your defineSound needs to be in one of the script files in your mod_assets folder, not in a script entity within dungeon itself. The only part there would be the function

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:56 am
by IronMaiden
Komag wrote:I think the whole part with your defineSound needs to be in one of the script files in your mod_assets folder, not in a script entity within dungeon itself. The only part there would be the function
You mean in the script folder within the mod_assets folder? and if so do i just rename the text file to .lua?

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 1:59 am
by Neikun
IronMaiden wrote:
Komag wrote:I think the whole part with your defineSound needs to be in one of the script files in your mod_assets folder, not in a script entity within dungeon itself. The only part there would be the function
You mean in the script folder within the mod_assets folder? and if so do i just rename the text file to .lua?
Oh is it not in the scripts folder? That would be the problem, yes.

Add your definition in sounds.lua


EDIT: I did not realize that a sounds.lua gets generated by the dungeon editor :oops:
I'm sleepy and still slightly inebriated, don't make fun D:

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 2:12 am
by Komag
There is a selection of default lua files already there, you just add that section to it.

So go into mod_assets/scripts and open up sounds.lua and add your lines and save the file
(make sure it remains a .lua file FOR SURE and don't let windows rename it to "sounds.lua.txt" secretly; if you have "hide extensions for known file types" on within your folder options it can sometimes do this without your knowing)

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 2:31 am
by IronMaiden
Thanks Komag, this shows how much of a no good scripter i am hehe.

I now have it in my sounds.lua file and the function in the dungeon script. but now when i add a connector to a pressure plate to trigger the sound script i get a crash in the editor with error Stack overflow beside the function playSound("Invader")

Re: adding custom sound to a secret

Posted: Sun Oct 21, 2012 2:58 am
by Neikun
I want to help you but can't think clearly. I'm sorry.