mirror of
https://github.com/CapsAdmin/pac3.git
synced 2025-03-04 03:03:01 -05:00
fixed cloned parts not saving and parenting properly
git-svn-id: http://gmodcapsadmin.googlecode.com/svn/trunk/addons/pac3@39 047d434e-d786-fb00-e516-99c5e643cd71
This commit is contained in:
parent
d96b13a451
commit
dbb02e107f
@ -74,13 +74,15 @@ end
|
||||
pac.AddHook("OnEntityCreated")
|
||||
|
||||
function pac.EntityRemoved(ent)
|
||||
for key, part in pairs(pac.GetParts()) do
|
||||
if part:IsValid() and part:GetOwner() == ent then
|
||||
part:Remove()
|
||||
timer.Simple(2, function()
|
||||
for key, part in pairs(pac.GetParts(true)) do
|
||||
if part:IsValid() and part:GetOwner() == ent then
|
||||
part:Remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
--pac.AddHook("EntityRemoved")
|
||||
pac.AddHook("EntityRemoved")
|
||||
|
||||
if net then
|
||||
net.Receive("pac_submit", function()
|
||||
|
@ -53,6 +53,9 @@ concommand.Add("pac_restart", function()
|
||||
local was_open
|
||||
if pace then was_open = pace.Editor:IsValid() pace.Panic() end
|
||||
|
||||
pac = {}
|
||||
pace = {}
|
||||
|
||||
include("autorun/pac_init.lua")
|
||||
include("autorun/pace_init.lua")
|
||||
|
||||
|
@ -14,7 +14,6 @@ function pac.CreatePart(name)
|
||||
table.insert(pac.ActiveParts, part)
|
||||
part.Id = part_count
|
||||
|
||||
part:SetName("part " .. #pac.ActiveParts)
|
||||
part:SetPlayerOwner(LocalPlayer())
|
||||
|
||||
pac.CallHook("OnPartCreated", part)
|
||||
@ -131,6 +130,16 @@ do -- meta
|
||||
self.Parent = pac.NULL
|
||||
end
|
||||
|
||||
function PART:SetName(var)
|
||||
for key, part in pairs(pac.GetParts()) do
|
||||
if part:GetName() == var and part ~= self then
|
||||
self.Name = var .. " conflict"
|
||||
return
|
||||
end
|
||||
end
|
||||
self.Name = var
|
||||
end
|
||||
|
||||
do -- owner
|
||||
function PART:SetOwner(ent)
|
||||
ent = ent or NULL
|
||||
@ -244,7 +253,7 @@ do -- meta
|
||||
|
||||
function PART:HasChild(part)
|
||||
for key, child in pairs(self:GetChildren()) do
|
||||
if child == part then
|
||||
if child == part or child:HasChild(part) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -370,7 +379,7 @@ do -- meta
|
||||
self.Parent.ClassName ~= "player"
|
||||
)
|
||||
then
|
||||
local ent = self.Parent.Entity -- model
|
||||
local ent = self.Parent.Entity or NULL -- model
|
||||
|
||||
if ent:IsValid() then
|
||||
pos, ang = ent:GetBonePosition(self.BoneIndex)
|
||||
@ -434,7 +443,6 @@ do -- meta
|
||||
|
||||
for key, value in pairs(tbl.children) do
|
||||
local part = pac.CreatePart(value.self.ClassName)
|
||||
part:SetOwner(self:GetOwner())
|
||||
part:SetTable(value)
|
||||
self:AddChild(part)
|
||||
end
|
||||
@ -458,7 +466,7 @@ do -- meta
|
||||
for _, key in pairs(self:GetStorableVars()) do
|
||||
tbl.self[key] = COPY(self[key])
|
||||
end
|
||||
|
||||
|
||||
for _, part in pairs(self:GetChildren()) do
|
||||
table.insert(tbl.children, part:ToTable())
|
||||
end
|
||||
@ -478,9 +486,7 @@ do -- meta
|
||||
|
||||
function PART:Clone()
|
||||
local part = pac.CreatePart(self.ClassName)
|
||||
part:SetOwner(self:GetOwner())
|
||||
part:SetTable(self:ToTable())
|
||||
part:SetName(self:GetName() .. " copy")
|
||||
return part
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user