Well, I finally decided to take my first foray into lua-scripting, but so far the results have been, well, non-existant.
What I am trying to do is modify some of the AMK scripts used in OL (this whole thing will hopefully be a new feature for the SmP mod).
Anyway, the basic idea is this: In AMK/OL there is the feature of displaying onscreen texture of the mask in accordance to the suit you're wearing. For example when wearing a suit equipped with a gasmask, the outlines of the mask are called onscreen to give the illusion of actually wearing one.
What I would like to accomplish is that a looped sound would be played when wearing a mask, to simulate breathing with a mask on. So far I've got some pointers and assistance from Barin on GSC forums how to go about to do this, but I haven't yet managed to actually get the sound to play. I'm guessing the actual script does activate, since when equipping a suit with a mask, there is a small pause just after equipping it. But the actual sound won't play at all. I've tried a few different approaches for this, but most of them only result in a CTD, or at best where I am now, which is that the script kicks in, but the sound won't play.
So, I decided to ask if anyone would care to take a look at the script and possibly point me to what I am doing wrong?
The script function is called by the amk_mod.script, pointing to an external script (called mask_sounds.script), which has the table for various suits and the sounds affiliated to them (currently just the same sound for all suits, might change this, if I actually get this working), and the functions for playing the sound. But for a reason unknown to me (this is my first "major" attempt at scripting), it just doesn't work. So, I ask, if someone will spot something obvious that I've done wrong, or find a better way of doing this.
Anyway, here is the code:
- Code: Select all
--Gas mask breathing sound script
local suit_sounds={
--hud_gaz
svoboda_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
dolg_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
neytral_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
neytral_novice_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
svoboda_heavy_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
bandit_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
--hud_exo
neytral_exo_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
svoboda_yellow_exo_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
exo_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
--hud_merc
killer_gaz_outfit_m1 = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
--hud_sci
dolg_scientific_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
ecolog_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
protection_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
scientific_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
--hud_military
military_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
militaryspec_outfit = xr_sound.get_safe_sound_object("sounds\darius\mask_breath"),
}
local snd_left = nil
local snd_right = nil
local pos_left = vector():set(-1, 0, 1)
local pos_right = vector():set(1, 0, 1)
function start_stop_sound(suit_type)
if snd_left ~= nil then
snd_left:stop()
end
if snd_right ~= nil then
snd_right:stop()
end
if suit_type and suit_sounds[suit_type] then
snd_left = suit_sounds[suit_type]
snd_left:play_at_pos(db.actor, pos_left, 0, sound_object.s2d + sound_object.looped)
snd_right = suit_sounds[suit_type]
snd_right:play_at_pos(db.actor, pos_right, 0, sound_object.s2d + sound_object.looped)
end
end
So, I've been at this for a couple of weeks, but just can't seem to make sense of whats wrong.
Any assistance would be appreciated.
Ps: Sorry for the long post...