• Need Help- Trying to Fix Dimensions for gmod 13
    3 replies, posted
This addon/mod was made by Overv (as far as I know since that's what it says on the beta page) at some point that I'm assuming was a long time ago. I found it in the Garrysmod beta only mostly fixed and I wanted to integrate it into a gamemode I'm working on (derived from sandbox, so I have no problem using it in addon form). The Dimensions addon is designed to separate gameplay into distinct "dimensions" or "rooms" where you can only see and interact with props, npcs, other players, etc in the same dimension as you. The main problem I'm having is that ropes and tracer fire are still visible when you're in another dimension. The code is otherwise working and I haven't had to add anything to it except minor bug fixing. I'm just going to post the actual area of code I'm having trouble with because everything else is working fine. I'm not getting any error messages, it just isn't working as intended. Original Code (for reference): cl_dimensionscore.lua: [lua]function Dimensions:SetEntityVisiblity( ent, dimension ) if ( ent:EntIndex() < 0 or !ent:IsValid() ) then return end local visible = false if ( ent:GetOwner():IsValid() ) then visible = ent:GetOwner():GetDimension() == dimension elseif ( ent:GetClass() == "class C_RopeKeyframe" ) then visible = ent:GetNWEntity( "CEnt", ent ):GetDimension() == dimension else visible = ent:GetDimension() == dimension end if ( ent:GetClass() == "class C_RopeKeyframe" ) then if ( visible ) then ent:SetColor(Color(255, 255, 255, 255)) else ent:SetColor(Color(255, 255, 255, 0)) end else ent:SetNoDraw( !visible ) if ( visible and !ent.DimensionVisibility ) then ent:CreateShadow() end end ent.DimensionVisibility = visible end function Dimensions.RenderEntities() local localDimension = LocalPlayer():GetViewDimension() for _, ent in ipairs( ents.GetAll() ) do Dimensions:SetEntityVisiblity( ent, localDimension ) if ( ent.Dimension and ent.Dimension != ent:GetDimension() and ( ent.Dimension != localDimension and ent:GetDimension() == localDimension ) or ( ent.Dimension == localDimension and ent:GetDimension() != localDimension ) and !ent:GetOwner():IsValid() ) then local ed = EffectData() ed:SetEntity( ent ) util.Effect( "entity_remove", ed, true, true ) end ent.Dimension = ent:GetDimension() end end hook.Add( "RenderScene", "DimensionsEntityDrawing", Dimensions.RenderEntities )[/lua] My Version. trying to fix the error (doesn't seem to make any difference) I commented out a section that was another attempt (it still didn't work): cl_dimensionscore.lua: [lua]function Dimensions:SetEntityVisiblity( ent, dimension ) if ( ent:EntIndex() < 0 or !ent:IsValid() ) then return end local visible = false local localDimension = LocalPlayer():GetViewDimension() --if ( ent:GetOwner():IsValid() ) then -- visible = ent:GetOwner():GetDimension() == dimension --elseif ( ent:GetClass() == "C_RopeKeyframe" ) then -- if ent:GetNWEntity( "CEnt", ent ):GetDimension() == localDimension then -- visible = true -- else -- visible = false -- end -- print(visible) -- print(ent:GetNWEntity( "CEnt", ent ):GetDimension()) --else -- visible = ent:GetDimension() == dimension --end if ( ent:GetOwner():IsValid() ) then if ent:GetOwner() == LocalPlayer() then if ent:GetDimension() == localDimension then visible = true end end elseif ( ent:GetClass() == "class C_RopeKeyframe" ) then if ent:GetNWEntity( "CEnt", ent ):GetDimension() == localDimension then visible = true print(visible) end else if ent:GetDimension() == localDimension then visible = true else visible = false end end if ( ent:GetClass() == "C_RopeKeyframe" ) then if ( visible ) then ent:SetColor(255, 255, 255, 255) else ent:SetColor(255,255,255,0) ent:SetRenderMode(RENDERMODE_TRANSALPHA) end else ent:SetNoDraw( !visible ) if ( visible and !ent.DimensionVisibility ) then ent:CreateShadow() end end ent.DimensionVisibility = visible end function Dimensions.RenderEntities() local localDimension = LocalPlayer():GetViewDimension() for _, ent in ipairs( ents.GetAll() ) do Dimensions:SetEntityVisiblity( ent, localDimension ) if ( ent.Dimension and ent.Dimension != ent:GetDimension() and ( ent.Dimension != localDimension and ent:GetDimension() == localDimension ) or ( ent.Dimension == localDimension and ent:GetDimension() != localDimension ) and !ent:GetOwner():IsValid() ) then local ed = EffectData() ed:SetEntity( ent ) util.Effect( "entity_remove", ed, true, true ) end ent.Dimension = ent:GetDimension() end end hook.Add( "RenderScene", "DimensionsEntityDrawing", Dimensions.RenderEntities )[/lua] If there isn't anything obvious there then here's the full code. This includes the serverside stuff for the Networked Entity, which I checked and seems to be working. original code (I just added "_R = debug.getregistry()"): cl_dimensionscore.lua [lua]--[[------------------------------------------------------------------------------------------------------------------ Clientside dimensions core ------------------------------------------------------------------------------------------------------------------]]-- Dimensions = {} --for debugging purposes -Zyler _R = debug.getregistry() --[[------------------------------------------------------------------------------------------------------------------ Get dimension function ------------------------------------------------------------------------------------------------------------------]]-- function _R.Entity:GetDimension() if ( !self:IsValid() ) then return 1 end local val = self:GetDTInt( 3 ) if ( val == 0 and self != LocalPlayer() ) then val = LocalPlayer():GetDimension() end return val end function _R.Entity:GetViewDimension() local val = self:GetDTInt( 2 ) if ( val == 0 ) then val = LocalPlayer():GetDimension() end return val end --[[------------------------------------------------------------------------------------------------------------------ Collision prediction ------------------------------------------------------------------------------------------------------------------]]-- function Dimensions.ShouldCollide( ent1, ent2 ) if ( ent1:GetDimension() != ent2:GetDimension() && !ent1:IsWorld() && !ent2:IsWorld() ) then return false end end hook.Add( "ShouldCollide", "DimensionsCollisionHandling", Dimensions.ShouldCollide ) --[[------------------------------------------------------------------------------------------------------------------ Trace modification ------------------------------------------------------------------------------------------------------------------]]-- Dimensions.OriginalTraceLine = util.TraceLine function util.TraceLine( td, dimension ) if ( !dimension ) then dimension = LocalPlayer():GetDimension() end local originalResult = Dimensions.OriginalTraceLine( td ) if ( !originalResult.Entity:IsValid() or originalResult.Entity:GetDimension() == dimension ) then return originalResult else if ( td.filter ) then if ( type( td.filter ) == "table" ) then table.insert( td.filter, originalResult.Entity ) else td.filter = { td.filter, originalResult.Entity } end else td.filter = originalResult.Entity end return util.TraceLine( td ) end end Dimensions.OriginalPlayerTrace = util.GetPlayerTrace function util.GetPlayerTrace( ply, dir ) local originalResult = Dimensions.OriginalPlayerTrace( ply, dir ) originalResult.filter = { ply } for _, ent in ipairs( ents.GetAll() ) do if ( ent:GetDimension() != ply:GetDimension() ) then table.insert( originalResult.filter, ent ) end end return originalResult end --[[------------------------------------------------------------------------------------------------------------------ Rendering --------------------------------------------------------------------------------------------------
BUMP
[QUOTE=Zyler;38545306]BUMP[/QUOTE] Again, Still having problems with this
...
Sorry, you need to Log In to post a reply to this thread.