DoomRL > Modding
sound.lua
GrimmC:
Hi, still having some trouble with the syntax. I put the 'dofile' at the end of sound.lua and pared it down to just one entry:
--- Code: --- Sound.knife = {
attack = "newsounds/dsknfhit.wav",
pickup = "wav/dswpnup.wav",
}
--- End code ---
Error response is:
--- Code: ---ELuaException : help.lua:4: attempt to index global 'Sound' (a nil value)
--- End code ---
The other file, the full one, looks like this up to the error:
--- Code: --- Sound.knife = {
attack = "newsounds/dsknfhit.wav",
pickup = "wav/dswpnup.wav",
},
-- Pistol
Sound.pistol = {
--- End code ---
The error is:
--- Code: ---ELuaException : newsounds.lua:8: unexpected symbol near '='
--- End code ---
Advice for either one?
tehtmi:
Alright. I actually tested this for myself.
For the first question, that should work fine; probably 'dofile' is in the wrong place. There are two good places to put it:
1) In config.lua. Put it right after the sound.lua part:
--- Code: ----- ... stuff above here
dofile "sound.lua"
dofile "newsounds.lua"
-- ... stuff below here
--- End code ---
2) At the very end of sound.lua, as in
--- Code: ----- ... stuff in sound.lua
powerup = "wav/dsgetpow.wav",
}
dofile("newsounds.lua")
--- End code ---
For your second question, you're getting that error because of the comma after the Sound.knife binding: drop it.
--- Code: ---Sound.knife = {
attack = "newsounds/dsknfhit.wav",
pickup = "wav/dswpnup.wav",
}
-- Pistol
Sound.pistol = {
-- pistol bindings
}
--- End code ---
Also, if you just want to change one knife binding, it may be nicer to do it as
--- Code: ---Sound.knife.attack = "newsounds/dsknfhit.wav"
--- End code ---
Just remember: in newsounds.lua, entries at the outer level should not be separated by commas.
If this is all horribly confusing, you could try reading up about lua.
GrimmC:
I think I have a handle on it, where could I learn more about lua though? For future reference.
Malek Deneith:
Note - you don't need to use "sound.<id>.<action>" . Just "<id>.<action>" should be enough, that's what is used for default sound.lua anyway.
GrimmC:
I tried this:
--- Code: --- pistol.reload = "newsounds/dsglkin.wav"
--- End code ---
and got this:
--- Code: ---attempt to index global value 'pistol'
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version