Sound script

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Sound script

Post by LordGarth »

Hello I need help in what to put exactly in for a sound to play.

How do I exactly define the sound in the folder and I am using a pressure plate connected to a script entity. I have tried many ways and the farthest I got was "warning no sample" was shown on the preview screen when i walked over the pressure plate.

Please advise on exact scripting needed in each area.

I have the sound wave file in the sound folder as well.

My script in the sound folder is this.

defineSound{

name = "scream1",

filename = "scream1.wav",

loop = "false",

volume = "0.5",

minDistance = "30",

maxDistance = "32",
}

script entity is
function playsound()
playSound("SCREAM1")

end
Thx,

LordGarth
Dungeon Master and DOOM will live forever.
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Sound script

Post by antti »

I can spot two issues:
The filename parameter needs the folders too, like so:

Code: Select all

filename = "mod_assets/sounds/scream1.wav",
And the script entity's name does not match the sample definition since it should be case sensitive. So just switch "SCREAM1" to "scream1" in the script entity. Let us know how it goes.
Steven Seagal of gaming industry
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Sound script

Post by LordGarth »

still shows no sample

sound script

defineSound = {
name = "scream1",
filename = "mod_assets\sounds\scream1.wav",
loop = "false",
volume = "0.5",
minDistance = "30",
maxDistance = "32",
}

entityscript

function playsound()
playSound("scream1")

end

I tried caps and regular and tried both slash types in the filepath

LordGarth
Dungeon Master and DOOM will live forever.
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Sound script

Post by antti »

Oh, I spotted an issue. You need to remove the quotation marks around loop, volume, minDistance and maxDistance values. Quotation marks indicate a string (a piece of text) but the datatypes we need in these fields are numbers and a boolean (true/false). This is a little programmerly but what this essentially means is that we were trying to pass of a text that literally read "32" when the engine was expecting a number with the value of 32.

And yeah, forward slashes ( / ) should be used in the folders.

Let's hope it works this time :)
Steven Seagal of gaming industry
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: Sound script

Post by LordGarth »

nope still says no sample

is the entity script correct

function playsound()
playSound("scream1")

end
Dungeon Master and DOOM will live forever.
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Sound script

Post by antti »

I'm not completely sure if it affects this but there's an unnecessary equals-to sign after defineSound. Try to remove it.
So, this should be what you have in your sounds.lua:

Code: Select all

defineSound{
name = "scream1",
filename = "mod_assets/sounds/scream1.wav",
loop = false,
volume = 0.5,
minDistance = 30,
maxDistance = 32,
}
The script entity looks good to me. You can see if it works by trying to play an existing sound like playSound("level_up")

Oh, and I forgot probably the most significant thing when testing this :(... The .lua files in your mod_assets folder will be loaded only when loading the project. So any time you modify something there, reopen the project in dungeon editor to refresh the changes in the lua files.

I'll have to check if I remembered to mention this in the modding documents, it's rather essential :P

Edit: I'll have to get some more sleep now, I'll check this thread out in the morning.
Steven Seagal of gaming industry
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Sound script

Post by Xzalander »

Hi, I thought it would be better to keep related issues in the same thread. Just wondering why I'm getting an error here as I have no experience at all with LUA. i'm just going by the scripting tutorials you've provided.

Code: Select all

function pullLever()
	if combinationLever1:getLeverState() == "activated" and
	combinationLever2:getLeverState() == "activated" then
		combinationDoor:open()
		playSound(secret)
	else
		combinationDoor:close()
	end
end
It is my understanding that the Predefined sounds, don't need any clarification other than the keyword, but I get the error "Bad argument #1 to 'playSound' (string expected, got nil)".

Any help would be great.
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Sound script

Post by antti »

Ah, that's simple. You need quotation marks in playSound("secret") since a string is expected there.
Steven Seagal of gaming industry
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Sound script

Post by petri »

playSound expects a string parameter so you have to quote the sound name -> playSound("secret")
EDIT: oops, Antti beat me :lol:
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Sound script

Post by Xzalander »

Oh well that is deflating :p Haha. Does that pply for other pre-defineds as well then, such as the particle systems?
Post Reply