Another poor attempt at scripting.
I'll get right into it:
So I'm trying to have a weapon choose a random firing sound from a list when it's created, and stick with that firing sound until it's destroyed.
Code:
function Create(self)
...
self.FireSounds = {(CreateAEmitter("Dispenser.rte/Fire Sound 1")) , (CreateAEmitter("Dispenser.rte/Fire Sound 2")) , etc..};
local Sound = (self.FireSounds[math.random(1,4)]);
self.SoundTimer = Timer();
...
end
Is where it should get the sounds from, and
Code:
function Update(self)
...
-- Fire Sounds:
if self:IsActivated() and self.Magazine then
if self.SoundTimer:IsPastSimMS(60000/self.ROF) then
self.SoundTimer:Reset();
Sound.Pos = self.Pos;
MovableMan:AddParticle(Sound);
end
end
...
end
uses a bit of Akblabla's script to have it add the sound particle every time the weapon fires.
My problem is that when I define 'Sound' as a local variable in Create, the Update function cannot find it. Whenever I define it as 'self.Sound' in either function, the game glitches out, plays the sound once, and crashes shortly after. If I attempt to define 'Sound' in Update, as it's a math.random, I get a different sound every time, and the occasional crash
Anyone, please ;___;