Sound script
Sound script
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
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.
Re: Sound script
I can spot two issues:
The filename parameter needs the folders too, like so:
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.
The filename parameter needs the folders too, like so:
Code: Select all
filename = "mod_assets/sounds/scream1.wav",
Steven Seagal of gaming industry
Re: Sound script
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
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.
Re: Sound script
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
And yeah, forward slashes ( / ) should be used in the folders.
Let's hope it works this time
Steven Seagal of gaming industry
Re: Sound script
nope still says no sample
is the entity script correct
function playsound()
playSound("scream1")
end
is the entity script correct
function playsound()
playSound("scream1")
end
Dungeon Master and DOOM will live forever.
Re: Sound script
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:
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
Edit: I'll have to get some more sleep now, I'll check this thread out in the morning.
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,
}
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
Edit: I'll have to get some more sleep now, I'll check this thread out in the morning.
Steven Seagal of gaming industry
Re: Sound script
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.
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.
Code: Select all
function pullLever()
if combinationLever1:getLeverState() == "activated" and
combinationLever2:getLeverState() == "activated" then
combinationDoor:open()
playSound(secret)
else
combinationDoor:close()
end
end
Any help would be great.
Re: Sound script
Ah, that's simple. You need quotation marks in playSound("secret") since a string is expected there.
Steven Seagal of gaming industry
Re: Sound script
playSound expects a string parameter so you have to quote the sound name -> playSound("secret")
EDIT: oops, Antti beat me
EDIT: oops, Antti beat me
Re: Sound script
Oh well that is deflating :p Haha. Does that pply for other pre-defineds as well then, such as the particle systems?