From e9ffad2f7e62f8188e53b47050757a6fad7a5338 Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Wed, 13 Sep 2017 22:18:26 +0300 Subject: [PATCH] Updated: Summarized intersection relation like selecting an constraint anchor --- lua/autorun/trackassembly_init.lua | 2 +- .../gmod_tool/stools/trackassembly.lua | 47 ++++++++++--------- readme.md | 12 +++++ 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/lua/autorun/trackassembly_init.lua b/lua/autorun/trackassembly_init.lua index e22eb09f..a4906ebe 100644 --- a/lua/autorun/trackassembly_init.lua +++ b/lua/autorun/trackassembly_init.lua @@ -33,7 +33,7 @@ local asmlib = trackasmlib ------ CONFIGURE ASMLIB ------ asmlib.InitBase("track","assembly") -asmlib.SetOpVar("TOOL_VERSION","5.370") +asmlib.SetOpVar("TOOL_VERSION","5.371") asmlib.SetIndexes("V",1,2,3) asmlib.SetIndexes("A",1,2,3) asmlib.SetIndexes("S",4,5,6,7) diff --git a/lua/weapons/gmod_tool/stools/trackassembly.lua b/lua/weapons/gmod_tool/stools/trackassembly.lua index 0442dfc5..fd1eac3e 100644 --- a/lua/weapons/gmod_tool/stools/trackassembly.lua +++ b/lua/weapons/gmod_tool/stools/trackassembly.lua @@ -692,22 +692,16 @@ function TOOL:RightClick(stTrace) return asmlib.StatusLog(true,"TOOL:RightClick(World): Success open frame") end elseif(trEnt and trEnt:IsValid()) then - if(workmode == 1) then - if(enpntmscr) then + if(enpntmscr) then + if(not self:SelectModel(trEnt:GetModel())) then + return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Model not piece")) end + return asmlib.StatusLog(true,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Success") + else + if(asmlib.CheckButtonPly(ply,IN_USE)) then if(not self:SelectModel(trEnt:GetModel())) then return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Model not piece")) end return asmlib.StatusLog(true,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Success") - else - if(asmlib.CheckButtonPly(ply,IN_USE)) then - if(not self:SelectModel(trEnt:GetModel())) then - return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Model not piece")) end - return asmlib.StatusLog(true,"TOOL:RightClick(Select,"..tostring(enpntmscr).."): Success") - end end - elseif(workmode == 2 and asmlib.CheckButtonPly(ply,IN_USE)) then -- Curve ray fitting - if(not self:IntersectRelate(ply, trEnt, stTrace.HitPos)) then - return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:RightClick(Ray,"..tostring(enpntmscr).."): Relation fail")) end - return asmlib.StatusLog(true,"TOOL:RightClick(Ray): Success") end end if(not enpntmscr) then @@ -725,28 +719,38 @@ function TOOL:Reload(stTrace) local workmode = self:GetWorkingMode() asmlib.ReadKeyPly(ply) if(stTrace.HitWorld) then - if(workmode == 2) then self:IntersectClear() - return asmlib.StatusLog(true,"TOOL:Reload(Relate): Relation clear") end if(self:GetDeveloperMode()) then asmlib.SetLogControl(self:GetLogLines(),self:GetLogFile()) end - if(asmlib.CheckButtonPly(ply,IN_SPEED)) then self:ClearAnchor() end if(self:GetExportDB()) then asmlib.LogInstance("TOOL:Reload(World): Exporting DB") asmlib.ExportDSV("PIECES") asmlib.ExportDSV("ADDITIONS") asmlib.ExportDSV("PHYSPROPERTIES") asmlib.ConCommandPly(ply, "exportdb", 0) + end + if(asmlib.CheckButtonPly(ply,IN_SPEED)) then + if(workmode == 1) then self:ClearAnchor() + asmlib.LogInstance("TOOL:Reload(Anchor): Clear") + elseif(workmode == 2) then self:IntersectClear() + asmlib.LogInstance("TOOL:Reload(Relate): Clear") + end end; return asmlib.StatusLog(true,"TOOL:Reload(World): Success") elseif(trEnt and trEnt:IsValid()) then if(not asmlib.IsPhysTrace(stTrace)) then return false end if(asmlib.IsOther(trEnt)) then - return asmlib.StatusLog(false,"TOOL:Reload(Prop): Trace other object") end + return asmlib.StatusLog(false,"TOOL:Reload(Prop): Trace other object") end if(asmlib.CheckButtonPly(ply,IN_SPEED)) then - self:SetAnchor(stTrace) - return asmlib.StatusLog(true,"TOOL:Reload(Prop): Anchor set") + if(workmode == 1) then -- General anchor + if(not self:SetAnchor(stTrace)) then + return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:Reload(Prop): Anchor set fail")) end + return asmlib.StatusLog(true,"TOOL:Reload(Prop): Anchor set") + elseif(workmode == 2) then -- Intersect relation + if(not self:IntersectRelate(ply, trEnt, stTrace.HitPos)) then + return asmlib.StatusLog(false,self:GetStatus(stTrace,"TOOL:Reload(Prop): Relation set fail")) end + return asmlib.StatusLog(true,"TOOL:Reload(Prop): Relation set") + end end local trRec = asmlib.CacheQueryPiece(trEnt:GetModel()) - if(asmlib.IsExistent(trRec)) then - trEnt:Remove() + if(asmlib.IsExistent(trRec)) then trEnt:Remove() return asmlib.StatusLog(true,"TOOL:Reload(Prop): Removed a piece") end end @@ -754,8 +758,9 @@ function TOOL:Reload(stTrace) end function TOOL:Holster() + local gho = self.GhostEntity self:ReleaseGhostEntity() -- Remove the ghost prop to save memory - if(self.GhostEntity and self.GhostEntity:IsValid()) then self.GhostEntity:Remove() end + if(gho and gho:IsValid()) then gho:Remove() end end function TOOL:UpdateGhost(ePiece, oPly) diff --git a/readme.md b/readme.md index 98dcab91..bdc72cd0 100644 --- a/readme.md +++ b/readme.md @@ -22,6 +22,18 @@ A: I was always annoyed when building a railroad track in-game, spending a lot o Also, another great achievement progress is in place, so 10x guys for helping me, help you, help us all ! ( Portal quote ) +Q: Hey, I cannot align my track crurves properly. Can you help ? +A: Yep sure. In the right panel, there is a drop-down menu which has a bunch of tool modes listed. + Go ahead and select the "Active point intersection". After you change the mode, an intersection + relation entity is needed to complete the process. Hitting SPEED + RELOAD ( Default: Shift + R ) + just like the anchor, will select the relation active point of the entity in question, which is closest + to the player hit position. Now trace a track piece and the ghost of the curve will be drawn. You can + clamp the spawn position in a box using the primary position flag /applinfst/ ( Apply linear first ) or switch + the origin angle with the ray direction angle by using primary angle flag /appangfst/ ( Apply angular first ) + In this working mode the angular and linear offsets adjust the piece offsets relative to the ray intersection + position where the trace and relation rays meet. Press ATTACK1 ( Def: Left click ) if you are happy with where + the ghost is located and where the spawn piece will go at. + Q: What are the most important things that I need in order to build a track using this script? A: Just subscribe to the workshop item: http://steamcommunity.com/sharedfiles/filedetails/?id=287012681