Skip to content

Commit 9732326

Browse files
committed
Threadedness and save ammo counter properly
1 parent 8f9e72d commit 9732326

File tree

1 file changed

+8
-3
lines changed
  • Data/Ronin.rte/Devices/Weapons/K98K

1 file changed

+8
-3
lines changed

Data/Ronin.rte/Devices/Weapons/K98K/K98K.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ function Create(self)
4848
self.origSharpLength = self.SharpLength;
4949

5050
self.origReloadAngle = self.ReloadAngle
51-
52-
self.ammoCounter = self.RoundInMagCount;
51+
52+
self.ammoCounter = self:NumberValueExists("ammoCounter") and self:GetNumberValue("ammoCounter") or self.RoundInMagCount;
53+
self:RemoveNumberValue("ammoCounter");
5354
self.maxAmmoCount = self.Magazine and self.Magazine.Capacity or 5; -- loading a game might mess this up, so... fall-back
5455

5556
self.delayedFire = false
@@ -71,7 +72,7 @@ function Create(self)
7172
self.chamberDelay = 300;
7273
end
7374

74-
function Update(self)
75+
function ThreadedUpdate(self)
7576
self.chamberSound.Pos = self.Pos;
7677
self.preSound.Pos = self.Pos;
7778

@@ -283,4 +284,8 @@ function Update(self)
283284
if self.InheritedRotAngleTarget > 0 then
284285
self.InheritedRotAngleTarget = math.max(self.InheritedRotAngleTarget - TimerMan.DeltaTimeSecs, 0);
285286
end
287+
end
288+
289+
function OnSave(self)
290+
self:SetNumberValue("ammoCounter", self.ammoCounter);
286291
end

0 commit comments

Comments
 (0)