adding custom sound to a secret

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
IronMaiden
Posts: 17
Joined: Sun Oct 21, 2012 1:08 am

adding custom sound to a secret

Post 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
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: adding custome sound to a secret

Post 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.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
IronMaiden
Posts: 17
Joined: Sun Oct 21, 2012 1:08 am

Re: adding custom sound to a secret

Post 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?
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: adding custom sound to a secret

Post by Neikun »

No, that shouldn't be the problem.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: adding custom sound to a secret

Post 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
Finished Dungeons - complete mods to play
IronMaiden
Posts: 17
Joined: Sun Oct 21, 2012 1:08 am

Re: adding custom sound to a secret

Post 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?
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: adding custom sound to a secret

Post 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:
Last edited by Neikun on Sun Oct 21, 2012 2:23 am, edited 1 time in total.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: adding custom sound to a secret

Post 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)
Finished Dungeons - complete mods to play
IronMaiden
Posts: 17
Joined: Sun Oct 21, 2012 1:08 am

Re: adding custom sound to a secret

Post 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")
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: adding custom sound to a secret

Post by Neikun »

I want to help you but can't think clearly. I'm sorry.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Post Reply