Chaosforge Forum

  • April 27, 2024, 12:55
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: sound.lua  (Read 6832 times)

GrimmC

  • Guest
sound.lua
« on: May 03, 2011, 22:47 »

Having some trouble with the aforementioned file. As per the wiki, the end of my file looks like this:
Code: [Select]
powerup = "wav/dsgetpow.wav",

#include "newsounds.lua"

}

When I have lightning fast reflexes, it says something about a global variable being assigned nil or somesuch.

However, even my previous additions straight to the file didn't work. A typical change:
Code: [Select]
reload = "newsounds/dsglkin.wav",newsounds being a folder I created in the main directory. But this also crashed. Help?
Logged

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: sound.lua
« Reply #1 on: May 03, 2011, 23:28 »

Sorry, the wiki page you are talking about is for an old version that doesn't use lua for the sound file.

I believe Skulltag Arena has custom sounds, and it's updated to 0.9.9.2.  Sound stuff is probably about the same.  So you can use that as a reference.

You shouldn't use #include anywhere, it doesn't mean anything in lua.

Are you actually trying to make a mod or just change sound bindings?

More details would be helpful. What sound are you trying to change/add?  What is the error message? Maybe attach your entire sound.lua to your post?
Logged

GrimmC

  • Guest
Re: sound.lua
« Reply #2 on: May 04, 2011, 13:06 »

I'm just changing the sound bindings. For example, importing the supershotgun reload sound from Doom 2 instead of the generic weapon pickup sound in place now.

There is also a mod I'm working on for Doom 2 which expands the enemy sound sets, among other things, so Lost Souls, Cacodemons, and others have their own pain sounds now.

EDIT: Turned out I had messed up some of the filenames, which caused DoomRL to crash. Is there some parameter I can include to make it wait for <enter> until it shuts the window. Right now I'm just hitting the pause key frantically.
Logged

GrimmC

  • Guest
Re: sound.lua
« Reply #3 on: May 04, 2011, 13:42 »

Putting
Code: [Select]
dofile "newsounds.lua" after sound.lua in the config causes DoomRL to fail loading.

Putting it at the end of sound.lua loads normally, but doesn't change anything.

Putting it at the beginning causes DoomRL to fail.

Any suggestions? I'd like to make an add-on file so I don't have to modify the original sound.lua...
Logged

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: sound.lua
« Reply #4 on: May 04, 2011, 14:06 »

Is there some parameter I can include to make it wait for <enter> until it shuts the window. Right now I'm just hitting the pause key frantically.

I've attached a replacement for doomrl.bat that will wait for you to press a key before closing the window if there was an error.  You could also just run doomrl from the command line.

Any suggestions? I'd like to make an add-on file so I don't have to modify the original sound.lua...

If you want to add or change sound bindings in a different file, then it will have to use different syntax.  To edit or add an entry, you should do something like
Code: [Select]
Sound.door.open = "soundfile.wav"
Sound.reload = "othersoundfile.wav"
Sound.newitem = {
  fire = "firesound.wav"
  reload = "blah.wav"
}
-- and so one...
(I haven't tested this, but I'm pretty sure it should work.)
As you said, make sure to run this after the usual sound.lua (either of the places you said should work).
Logged

GrimmC

  • Guest
Re: sound.lua
« Reply #5 on: May 05, 2011, 13:23 »

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: [Select]
Sound.knife = {
attack = "newsounds/dsknfhit.wav",
pickup = "wav/dswpnup.wav",
}
Error response is:
Code: [Select]
ELuaException : help.lua:4: attempt to index global 'Sound' (a nil value)
The other file, the full one, looks like this up to the error:
Code: [Select]
Sound.knife = {
attack = "newsounds/dsknfhit.wav",
pickup = "wav/dswpnup.wav",
},

-- Pistol

Sound.pistol = {

The error is:
Code: [Select]
ELuaException : newsounds.lua:8: unexpected symbol near '='
Advice for either one?
Logged

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: sound.lua
« Reply #6 on: May 05, 2011, 17:33 »

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: [Select]
-- ... stuff above here
dofile "sound.lua"
dofile "newsounds.lua"
-- ... stuff below here
2) At the very end of sound.lua, as in
Code: [Select]
-- ... stuff in sound.lua
  powerup = "wav/dsgetpow.wav",
}
dofile("newsounds.lua")

For your second question, you're getting that error because of the comma after the Sound.knife binding: drop it.
Code: [Select]
Sound.knife = {
  attack      = "newsounds/dsknfhit.wav",
  pickup      = "wav/dswpnup.wav",
}

-- Pistol

Sound.pistol = {
  -- pistol bindings
}

Also, if you just want to change one knife binding, it may be nicer to do it as
Code: [Select]
Sound.knife.attack = "newsounds/dsknfhit.wav"

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.
« Last Edit: May 05, 2011, 17:36 by tehtmi »
Logged

GrimmC

  • Guest
Re: sound.lua
« Reply #7 on: May 05, 2011, 17:37 »

I think I have a handle on it, where could I learn more about lua though? For future reference.
Logged

Malek Deneith

  • Grand Inquisitor Emeritus
  • Grand Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1256
    • View Profile
Re: sound.lua
« Reply #8 on: May 07, 2011, 12:47 »

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.
Logged
Inquisition - saving your soul, one bolter shell at a time.
Spoiler: "Hackmaster Kills" (click to show/hide)

GrimmC

  • Guest
Re: sound.lua
« Reply #9 on: May 16, 2011, 15:49 »

I tried this:
Code: [Select]
pistol.reload = "newsounds/dsglkin.wav"
and got this:
Code: [Select]
attempt to index global value 'pistol'
Logged

Malek Deneith

  • Grand Inquisitor Emeritus
  • Grand Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1256
    • View Profile
Re: sound.lua
« Reply #10 on: May 16, 2011, 16:02 »

Um. Me bad, I must've not looked carefully. You need to do something like this instead:

Code: [Select]
pistol = {
fire = "sounds/Weapons/pistol/pistol_shot_02a.wav",
pickup = "sounds/Weapons/pistol/pistol_use_01.wav",
reload = "sounds/Weapons/pistol/pistol_reload_01.wav",
},

Still no "sound." before that is required. As for tehtmi's single bind example - I'm not sure if the bracket-less syntax is still possible. If it is then perhaps *this syntax* does require prefacing it with "sound."
Logged
Inquisition - saving your soul, one bolter shell at a time.
Spoiler: "Hackmaster Kills" (click to show/hide)

GrimmC

  • Guest
Re: sound.lua
« Reply #11 on: May 16, 2011, 20:56 »

The bracketless bind requires "sound." I haven't tried your example with brackets yet, I'll let you know.
Logged

GrimmC

  • Guest
Re: sound.lua
« Reply #12 on: May 17, 2011, 10:56 »

Code: [Select]
sound.pistol.reload = "newsounds/dsglkin.wav"
results in the same error.

EDIT: It turns out "sound" has to be capitalized.
« Last Edit: May 17, 2011, 10:58 by GrimmC »
Logged
Pages: [1]