Skip to content

Commit

Permalink
Updated: Summarized intersection relation like selecting an constrain…
Browse files Browse the repository at this point in the history
…t anchor
  • Loading branch information
dvdvideo1234 committed Sep 13, 2017
1 parent 78107bb commit e9ffad2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 26 additions & 21 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -725,37 +719,48 @@ 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
return false
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)
Expand Down
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e9ffad2

Please sign in to comment.