Skip to content

Commit

Permalink
Fixed: Runtime errors
Browse files Browse the repository at this point in the history
Reduced: BAS call parameters
  • Loading branch information
dvdvideo1234 committed Nov 15, 2023
1 parent 2ed641a commit 8a5d118
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.740")
asmlib.SetOpVar("TOOL_VERSION","8.741")
asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3)
Expand Down
64 changes: 47 additions & 17 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ local mathSqrt = math and math.sqrt
local mathFloor = math and math.floor
local mathClamp = math and math.Clamp
local mathAtan2 = math and math.atan2
local mathRemap = math and math.Remap
local mathRound = math and math.Round
local mathRandom = math and math.random
local drawRoundedBox = draw and draw.RoundedBox
Expand Down Expand Up @@ -1874,28 +1875,57 @@ function SetButtonSlider(cPanel, sVar, nMin, nMax, nDec, tBtn)
pPanel:SetSlider(sKey, languageGetPhrase(sBase.."_con"), languageGetPhrase(sBase))
pPanel:Configure(nMin, nMax, tConv[sKey], nDec)
for iD = 1, #tBtn do
local vBtn, sTip = tBtn[iD]
local sTxt = tostring(vBtn.N):Trim()
if(vBtn.T) then
if(vBtn.T == syRev) then
sTip = languageGetPhrase(sBase.."_bas"..sTxt)
elseif(vBtn.T == syDis) then
sTip = languageGetPhrase("tool."..sTool..".buttonas"..sTxt)
else
sTip = tostring(vBtn.T):Trim()
end
local vBtn = tBtn[iD] -- Button info
local sTxt = tostring(vBtn.N or syDis):Trim()
local sTip = tostring(vBtn.T or syDis):Trim()
if(sTip == syRev) then
sTip = languageGetPhrase(sBase.."_bas"..sTxt)
elseif(sTip == syDis) then
sTip = languageGetPhrase("tool."..sTool..".buttonas"..sTxt)
else
sTip = tostring(sTip):Trim()
end
if(sTxt:sub(1,1) = syRev and tonumber(sTxt:sub(2,-1))) then
local nAmt = tonumber(sTxt:sub(2,-1))
if(sTxt:sub(1,1) == syRev) then
if(tonumber(sTxt:sub(2,-1))) then
local nAmt = tonumber(sTxt:sub(2,-1))
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS)
pS:SetValue(GetSign((nS < 0) and nS or (nS+1))*nAmt) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS)
pS:SetValue(-GetSign((nS < 0) and nS or (nS+1))*nAmt) end
end
sTip = languageGetPhrase("tool."..sTool..".buttonas"..syRev).." "..nAmt
elseif(sTxt:sub(2,-1) == "D") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end
end
elseif(sTxt:sub(2,-1) == "M") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) SetClipboardText(nS) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) SetClipboardText(mathRemap(nS, pS:GetMin(), pS:GetMax(), 0, 1)) end
end
end
elseif(sTxt == "+/-") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(-nS) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) pS:SetValue(mathRemap(nS, pS:GetMin(), pS:GetMax(), pS:GetMax(), pS:GetMin())) end
end
elseif(sTxt == "<>") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS)
pS:SetValue(GetSign((nS < 0) and nS or (nS+1))*nAmt) end
vBtn.L=function(pB, pS, nS) pS:SetValue(GetSnap(nS,-GetAsmConvar("incsnpang","FLT"))) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS)
pS:SetValue(-GetSign((nS < 0) and nS or (nS+1))*nAmt) end
vBtn.R=function(pB, pS, nS) pS:SetValue(GetSnap(nS, GetAsmConvar("incsnpang","FLT"))) end
end
sTip = languageGetPhrase("tool."..sTool..".buttonas"..syRev).." "..nAmt
end
pPanel:SetButton(sTxt, sTip)
pPanel:SetAction(vBtn.L, vBtn.R)
Expand Down
22 changes: 4 additions & 18 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2462,26 +2462,12 @@ function TOOL.BuildCPanel(CPanel)
asmlib.SetNumSlider(CPanel, "angsnap" , iMaxDec)
asmlib.SetButton(CPanel, "resetvars")
local tBAng = { -- Button interactive slider ( angle offsets )
{N="<>" , T = "#", -- Left click to decrease, right to increase
L=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS,-asmlib.GetAsmConvar("incsnpang","FLT"))) end,
R=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS, asmlib.GetAsmConvar("incsnpang","FLT"))) end},
{N="+/-" , T = "#", L=function(pB, pS, nS) pS:SetValue(-nS) end},
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end,
R=function(pB, pS, nS) pS:SetValue(GetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end},
{N="@45" , T = "#"}, {N="@90" , T = "#"}, {N="@135", T = "#"}, {N="@180", T = "#"}
{N="<>" }, {N="+/-"}, {N="@M" }, {N="@D" },
{N="@45"}, {N="@90"}, {N="@135"}, {N="@180"}
} -- Use the same initialization table for multiple BIS
local tBpos = { -- Button interactive slider ( position offsets )
{N="<>" , T = "#", -- Left click to decrease, right to increase
L=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS,-asmlib.GetAsmConvar("incsnplin","FLT"))) end,
R=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS, asmlib.GetAsmConvar("incsnplin","FLT"))) end},
{N="+/-" , T = "#", L=function(pB, pS, nS) pS:SetValue(-nS) end},
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end,
R=function(pB, pS, nS) pS:SetValue(GetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end},
{N="@25" , T = "#"}, {N="@50" , T = "#"}, {N="@75", T = "#"}, {N="@100", T = "#"}
{N="<>" }, {N="+/-"}, {N="@M" }, {N="@D" },
{N="@25"}, {N="@50"}, {N="@75" }, {N="@100"}
} -- Use the same initialization table for multiple BIS
asmlib.SetButtonSlider(CPanel, "nextpic", -gnMaxRot, gnMaxRot, iMaxDec, tBAng)
asmlib.SetButtonSlider(CPanel, "nextyaw", -gnMaxRot, gnMaxRot, iMaxDec, tBAng)
Expand Down

0 comments on commit 8a5d118

Please sign in to comment.