From 95d5c63cc93dc6985380fb53d4e6eb7aaa7cbd0a Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 18 Feb 2017 16:53:42 -0500 Subject: Fixed a problem with ws_prop's not loading after mapchange --- entities/entities/ws_prop/init.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/entities/entities/ws_prop/init.lua b/entities/entities/ws_prop/init.lua index f757148..c6113f9 100644 --- a/entities/entities/ws_prop/init.lua +++ b/entities/entities/ws_prop/init.lua @@ -1,7 +1,7 @@ AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") -include('shared.lua') +include("shared.lua") function ENT:Serialize() local data = {} @@ -27,9 +27,13 @@ function ENT:Initialize() self:SetSolid(SOLID_VPHYSICS) self:DrawShadow(false) - local phys = self:GetPhysicsObject() - phys:EnableMotion(false) - phys:Sleep() + //Needed if loading a ws_prop after a map start + timer.Simple(0,function() + local phys = self:GetPhysicsObject() + phys:EnableMotion(false) + phys:Sleep() + end) + if self:Health() == 0 then self:SetHealth(30) end @@ -39,10 +43,10 @@ end function ENT:OnTakeDamage(dmginfo) self.HP = self.HP-dmginfo:GetDamage() - local newcolor = (self.HP/self.MaxHP)*255 + local newcolor = (self.HP / self.MaxHP) * 255 self:SetColor(Color(newcolor,newcolor,newcolor)) if (self.HP <= 0) then - self:EmitSound(Sound("physics/wood/wood_plank_break"..math.random(1,4)..".wav")) + self:EmitSound(Sound("physics/wood/wood_plank_break" .. math.random(1,4) .. ".wav")) self:Remove() end end -- cgit v1.2.3-70-g09d2