AudioTriggerSpots after loading the(last) save

#1
Hey guys!

After loading the game at the first(second and so on), it actually does not cause any problem. But, when I save the game(by Game:SaveGame node) and execute "loadLastSave" string in pure game mode,
Audio Trigger Spots just don't play. What the console says about that is(I logged the Audio Trigger Name at the first line):

Code: Select all

<09:13:31> <Lua> Play_bucket_sound_01
<09:13:31> [Warning] [Lua Error] scripts/entities/sound/audiotriggerspot.lua:71: attempt to perform arithmetic on field 'x' (a nil value)
<09:13:31> > _GenerateOffset, (scripts/entities/sound/audiotriggerspot.lua: 71)
<09:13:31> > Play, (scripts/entities/sound/audiotriggerspot.lua: 309)
<09:13:31> > (null) (scripts/entities/sound/audiotriggerspot.lua: 358)
<09:13:31> > (null) ([C]: -1)
<09:13:31> > _GenerateOffset, (scripts/entities/sound/audiotriggerspot.lua: 71)
<09:13:31> > Play, (scripts/entities/sound/audiotriggerspot.lua: 309)
<09:13:31> > (null) (scripts/entities/sound/audiotriggerspot.lua: 358)
I have got much to do with my game and plus these things,.. are just boring. Wasting time with things like this just kills me.
Any help would be appreciated!

Thanks!
Last edited by OrkhanAliyev on Tue Jan 01, 2019 9:15 am, edited 1 time in total.

Re: AudioTriggerSpots after loading the(last) save

#2
Well, till someone answer me, I'll write the method(which is not the best solution) I found myself(I write it here, so it may be helpful to someone who face with this problem).
I have removed the caller of Generate Offset function(not the generate function itself to avoid any possible problem)
Here the important parts are:
GameFolder\Scripts\Entities\Sound\AudioTriggerSpot.lua

Code: Select all

function AudioTriggerSpot:_GenerateOffset()
if(self.Properties.audioTriggerPlayTriggerName ~= nil)then
Log(self.Properties.audioTriggerPlayTriggerName); -- dbg, remove later
end
local offset = {x=0, y=0, z=0};
offset.x = randomF(-self.Properties.PlayMode.vectorRandomizationArea.x/2.0, self.Properties.PlayMode.vectorRandomizationArea.x/2.0);
offset.y = randomF(-self.Properties.PlayMode.vectorRandomizationArea.y/2.0, self.Properties.PlayMode.vectorRandomizationArea.y/2.0);
offset.z = randomF(-self.Properties.PlayMode.vectorRandomizationArea.z/2.0, self.Properties.PlayMode.vectorRandomizationArea.z/2.0);
return offset;
end
function AudioTriggerSpot:Play()

if ((self.hOnTriggerID ~= nil) and (self.Properties.bEnabled) and (not self.bIsHidden)) then
-- I have disabled this thing(as well as how I did in stop funct.). After loading the (last)save it was preventing the playing. Because of generate offset
--[[ local offset = self:_GenerateOffset();
if (LengthSqVector(offset) > 0.00001) then-- offset is longer than 1cm
self:SetAudioProxyOffset(offset, self:GetDefaultAuxAudioProxyID());
self:SetCurrentAudioEnvironments();
elseif (self.bHasMoved) then
self:SetCurrentAudioEnvironments();
end
]]
self:ExecuteAudioTrigger(self.hOnTriggerID, self:GetDefaultAuxAudioProxyID());
self.bIsPlaying = true;
self.bHasMoved = false;
self.hCurrentOnTriggerID = self.hOnTriggerID;

if (self.Properties.PlayMode.eiBehaviour == 2) then
self:SetTimer(0, 1000 * randomF(self.Properties.PlayMode.fMinDelay, self.Properties.PlayMode.fMaxDelay));
end
end
end

----------------------------------------------------------------------------------------
function AudioTriggerSpot:Stop()
if (not self.bIsHidden) then
-- Cannot check against "self.bIsPlaying" otherwise we won't execute the StopTrigger if there's no StartTrigger set!
if (self.hOffTriggerID ~= nil) then
--[[ local offset = self:_GenerateOffset();
if (LengthSqVector(offset) > 0.00001) then-- offset is longer than 1cm
self:SetAudioProxyOffset(offset, self:GetDefaultAuxAudioProxyID());
self:SetCurrentAudioEnvironments();
elseif (self.bHasMoved) then
self:SetCurrentAudioEnvironments();
end]]

self:ExecuteAudioTrigger(self.hOffTriggerID, self:GetDefaultAuxAudioProxyID());
elseif (self.hOnTriggerID ~= nil) then
self:StopAudioTrigger(self.hOnTriggerID, self:GetDefaultAuxAudioProxyID());
end
end

self.bIsPlaying = false;
self.bHasMoved = false;
self:KillTimer(0);
end


Who is online

Users browsing this forum: No registered users and 1 guest

cron