mirror of
https://github.com/Mista-Tea/improved-stacker.git
synced 2025-03-04 03:12:57 -05:00
Fixing saving stacked entities with duplicator
Resolves the following issue when trying to save stacked entities with the Duplicator tool: [ERROR] gamemodes/sandbox/entities/weapons/gmod_tool/stools/duplicator/icon.lua:182: attempt to perform arithmetic on field 'r' (a nil value) 1. v - gamemodes/sandbox/entities/weapons/gmod_tool/stools/duplicator/icon.lua:182 2. unknown - lua/includes/modules/hook.lua:84
This commit is contained in:
parent
d4f7458768
commit
af0cff715b
@ -635,10 +635,13 @@ function TOOL:LeftClick( trace )
|
||||
local entMod = ent:GetModel()
|
||||
local entSkin = ent:GetSkin()
|
||||
local entMat = ent:GetMaterial()
|
||||
local entCol = ent:GetColor()
|
||||
local entRM = ent:GetRenderMode()
|
||||
local entRFX = ent:GetRenderFX()
|
||||
|
||||
|
||||
local colorData = {
|
||||
Color = ent:GetColor(),
|
||||
RenderMode = ent:GetRenderMode(),
|
||||
RenderFX = ent:GetRenderFX()
|
||||
}
|
||||
|
||||
local physMat = ent:GetPhysicsObject():GetMaterial()
|
||||
local physGrav = ent:GetPhysicsObject():IsGravityEnabled()
|
||||
local lastEnt = ent
|
||||
@ -679,7 +682,7 @@ function TOOL:LeftClick( trace )
|
||||
-- detect that the entity came from Stacker
|
||||
if ( !IsValid( newEnt ) or hook.Run( "StackerEntity", newEnt, ply ) ~= nil ) then break end
|
||||
if ( !IsValid( newEnt ) or hook.Run( "PlayerSpawnedProp", ply, entMod, newEnt ) ~= nil ) then break end
|
||||
|
||||
|
||||
-- increase the total number of active stacker props spawned by the player by 1
|
||||
self:IncrementStackerEnts()
|
||||
|
||||
@ -694,7 +697,7 @@ function TOOL:LeftClick( trace )
|
||||
end, ply )
|
||||
|
||||
self:ApplyMaterial( newEnt, entMat )
|
||||
self:ApplyColor( newEnt, entCol, entRM, entRFX )
|
||||
self:ApplyColor( newEnt, colorData )
|
||||
self:ApplyFreeze( ply, newEnt )
|
||||
self:ApplyWeld( lastEnt, newEnt )
|
||||
|
||||
@ -739,13 +742,14 @@ end
|
||||
--
|
||||
-- Attempts to apply the original entity's color onto the stacked props.
|
||||
--]]--
|
||||
function TOOL:ApplyColor( ent, color, renderMode, renderFX )
|
||||
function TOOL:ApplyColor( ent, data )
|
||||
if ( !self:ShouldApplyColor() ) then return end
|
||||
|
||||
ent:SetColor( data.Color )
|
||||
ent:SetRenderMode( data.RenderMode )
|
||||
ent:SetRenderFX( data.RenderFX )
|
||||
|
||||
ent:SetColor( color )
|
||||
ent:SetRenderMode( renderMode )
|
||||
ent:SetRenderFX( renderFX )
|
||||
duplicator.StoreEntityModifier( ent, "colour", { Color = color, RenderMode = renderMode, RenderFX = renderFX } )
|
||||
duplicator.StoreEntityModifier( ent, "colour", table.Copy( data ) )
|
||||
end
|
||||
|
||||
--[[--------------------------------------------------------------------------
|
||||
@ -1069,4 +1073,4 @@ function TOOL.BuildCPanel( cpanel )
|
||||
cpanel:AddControl( "Checkbox", { Label = "Ghost all props in the stack", Command = "stacker_ghostall", Description = "Creates every ghost prop in the stack instead of just the first ghost prop" } )
|
||||
cpanel:AddControl( "Checkbox", { Label = "Add halos to ghosted props", Command = "stacker_halo", Description = "Gives halos to all of the props in to ghosted stack" } )
|
||||
cpanel:AddControl( "Color", { Label = "Halo color", Red = "stacker_halo_r", Green = "stacker_halo_g", Blue = "stacker_halo_b", Alpha = "stacker_halo_a" } )
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user