Skip to content

Commit

Permalink
Fixed: All ghosts are deleted on tool holster
Browse files Browse the repository at this point in the history
Renamed: `DELAY_FREEZE` to `DELAY_ACTION`
  • Loading branch information
dvdvideo1234 committed Sep 20, 2023
1 parent 0c42ec7 commit 7d357ba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion data/trackassembly/tools/hooks/pre-commit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ while(sI) do
io.write("Version found at line ["..nL.."]\n")
local vB, vE = sI:find(fNum)
if(vB and vE) then
print(sI:sub(vB, vE))
io.write("Version: "..sI:sub(vB, vE))
local nD = sI:sub(vB, vE):find(".", 1, true)
if(nD) then
local sW = trim(sI:sub(vB, vB + nD - 2))
Expand Down
4 changes: 2 additions & 2 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.728")
asmlib.SetOpVar("TOOL_VERSION","8.729")
asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3)
Expand Down Expand Up @@ -524,7 +524,7 @@ if(CLIENT) then
asmlib.WorkshopID("Anyone's Horrible Trackpack" , "2194528273")
asmlib.WorkshopID("Modular Sewer" , "2340192251")

asmlib.SetAction("CLEAR_GHOSTS" , function() asmlib.ClearGhosts(); print("NET") end)
asmlib.SetAction("CLEAR_GHOSTS" , function() asmlib.ClearGhosts() end)
asmlib.SetAction("CTXMENU_OPEN" , function() asmlib.IsFlag("tg_context_menu", true ) end)
asmlib.SetAction("CTXMENU_CLOSE", function() asmlib.IsFlag("tg_context_menu", false) end)

Expand Down
22 changes: 12 additions & 10 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ function InitBase(sName, sPurp)
SetOpVar("LOG_INIT",{"*Init", false, 0})
SetOpVar("TIME_STAMP",Time())
SetOpVar("TIME_INIT",Time())
SetOpVar("DELAY_FREEZE",0.01)
SetOpVar("DELAY_ACTION",0.01)
SetOpVar("MAX_ROTATION",360)
SetOpVar("ANG_ZERO",Angle())
SetOpVar("VEC_ZERO",Vector())
Expand Down Expand Up @@ -4625,8 +4625,8 @@ function ApplyPhysicalSettings(ePiece,bPi,bFr,bGr,sPh)
ePiece:SetMoveType(MOVETYPE_VPHYSICS) -- Moves and behaves like a normal prop
-- Delay the freeze by a tiny amount because on physgun snap the piece
-- is unfrozen automatically after physgun drop hook call
timerSimple(GetOpVar("DELAY_FREEZE"), function() -- If frozen motion is disabled
LogInstance("Freeze:["..tostring(bFr).."]", "*DELAY_FREEZE"); -- Make sure that the physics are valid
timerSimple(GetOpVar("DELAY_ACTION"), function() -- If frozen motion is disabled
LogInstance("Freeze:["..tostring(bFr).."]", "*DELAY_ACTION"); -- Make sure that the physics are valid
if(pyPiece and pyPiece:IsValid()) then pyPiece:EnableMotion(not bFr) end end )
constructSetPhysProp(nil,ePiece,0,pyPiece,{GravityToggle = bGr, Material = sPh})
duplicatorStoreEntityModifier(ePiece,sToolPrefL.."dupe_phys_set",arSettings)
Expand Down Expand Up @@ -4922,19 +4922,21 @@ end
* Well gang, I guess that wraps up the mystery.
]]
function ClearGhosts(vSiz, bCol)
print(1)
if(SERVER) then return true end
print(2)
local tGho = GetOpVar("ARRAY_GHOST")
print(3)
if(not IsHere(tGho)) then return true end
local iSiz = mathCeil(tonumber(vSiz) or tGho.Size)
print(4, iSiz)
local nDer = GetOpVar("DELAY_ACTION")
for iD = 1, iSiz do local eGho = tGho[iD]
if(eGho and eGho:IsValid()) then
print(5, eGho)
eGho:SetNoDraw(true); eGho:Remove()
end; eGho, tGho[iD] = nil, nil
timerSimple(nDer, function()
if(eGho and eGho:IsValid()) then
eGho:SetNoDraw(true)
eGho:Remove()
tGho[iD] = nil
end
end)
end
end; tGho.Size, tGho.Slot = 0, GetOpVar("MISS_NOMD")
if(bCol) then collectgarbage() end; return true
end
Expand Down
3 changes: 1 addition & 2 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1595,9 +1595,8 @@ end

function TOOL:Holster()
if(CLIENT) then return end
local user = self:GetOwner()
netStart(gsLibName.."SendDeleteGhosts")
netSend(user)
netSend(self:GetOwner())
end

function TOOL:UpdateGhostFlipOver(stTrace, sPos, sAng)
Expand Down

0 comments on commit 7d357ba

Please sign in to comment.