diff --git a/lua/autorun/ragdollmover_meta.lua b/lua/autorun/ragdollmover_meta.lua index b5dbad1..d594b32 100644 --- a/lua/autorun/ragdollmover_meta.lua +++ b/lua/autorun/ragdollmover_meta.lua @@ -16,6 +16,31 @@ local TYPE_BOOL = 5 RAGDOLLMOVER = {} +local shouldCallHook = false +hook.Add("EntityKeyValue", "RGMAllowTool", function(ent, key, val) + -- I couldn't find a clean, direct way to add ragdollmover to the m_tblToolsAllowed for both + -- loading into a map or loading a save on the same map. + if key == "gmod_allowtools" and not string.find(val, "ragdollmover") then + shouldCallHook = true + end + + -- We can't call the hook at the same time the key is gmod_allowtools because ent.m_tblToolsAllowed + -- must exist (which relies on the gmod_allowtools key), but it doesn't yet + if shouldCallHook and key ~= "gmod_allowtools" then + hook.Run("RGMAllowTool", ent) + shouldCallHook = false + end +end) + +-- Some brush entities only allow a select number of tools (see https://wiki.facepunch.com/gmod/Sandbox_Specific_Mapping) +-- Without this, the gizmos would not be "selectable" +hook.Add("RGMAllowTool", "RGMAllowTool", function(ent) + -- If the table is not filled, we don't want to insert it, as it would make other tools not work + if istable(ent.m_tblToolsAllowed) and #ent.m_tblToolsAllowed > 0 then + table.insert(ent.m_tblToolsAllowed, "ragdollmover") + end +end) + if SERVER then util.AddNetworkString("RAGDOLLMOVER_META") @@ -43,6 +68,7 @@ hook.Add("PlayerDisconnected", "RGMCleanupGizmos", function(pl) RAGDOLLMOVER[pl] = nil end) + local NumpadBindRot, NumpadBindScale = {}, {} local RotKey, ScaleKey = {}, {} local rgmMode = {} diff --git a/lua/entities/rgm_axis/shared.lua b/lua/entities/rgm_axis/shared.lua index 98a3c45..fc780ef 100644 --- a/lua/entities/rgm_axis/shared.lua +++ b/lua/entities/rgm_axis/shared.lua @@ -10,6 +10,7 @@ function ENT:Initialize() self:DrawShadow(false) self:SetCollisionBounds(-self.DefaultMinMax, self.DefaultMinMax) + self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetNotSolid(true) diff --git a/lua/weapons/gmod_tool/stools/ragdollmover.lua b/lua/weapons/gmod_tool/stools/ragdollmover.lua index e4bd7ef..d186559 100644 --- a/lua/weapons/gmod_tool/stools/ragdollmover.lua +++ b/lua/weapons/gmod_tool/stools/ragdollmover.lua @@ -1851,7 +1851,7 @@ function TOOL:Deploy() end local function EntityFilter(ent, tool) - return (ent:GetClass() == "prop_ragdoll" or ent:GetClass() == "prop_physics" or ent:GetClass() == "prop_effect") or (tool:GetClientNumber("disablefilter") ~= 0 and not ent:IsWorld()) + return ent:GetBrushPlaneCount() == 0 and ((ent:GetClass() == "prop_ragdoll" or ent:GetClass() == "prop_physics" or ent:GetClass() == "prop_effect") or (tool:GetClientNumber("disablefilter") ~= 0 and not ent:IsWorld())) end function TOOL:LeftClick() @@ -2225,7 +2225,7 @@ function TOOL:Reload() end -function TOOL:Think() +function TOOL:Think() if SERVER then @@ -2235,7 +2235,7 @@ if SERVER then if CurTime() < self.LastThink + (RAGDOLLMOVER[pl].updaterate or 0.01) then return end local plTable = RAGDOLLMOVER[pl] - + local ent = plTable.Entity local axis = plTable.Axis