Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto base #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion lua/autorun/gearassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ local asmlib = gearasmlib; if(not asmlib) then -- Module present

------ CONFIGURE ASMLIB ------
asmlib.InitBase("gear","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.241")
asmlib.SetOpVar("TOOL_VERSION","5.248")
asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
Expand Down Expand Up @@ -194,6 +194,52 @@ local CType = asmlib.GetOpVar("CONTAIN_CONSTRAINT_TYPE")
CType:Push({Name = "AdvBS Spin Y", Make = constraint and constraint.AdvBallsocket})
CType:Push({Name = "AdvBS Spin Z", Make = constraint and constraint.AdvBallsocket})

asmlib.SetOpVar("STRUCT_SPAWN",{
Name = "Spawn data definition",
Draw = {
["RDB"] = function(scr, key, typ, inf, def, spn)
local rec, fmt = spn[key], asmlib.GetOpVar("FORM_DRAWDBG")
local fky, nav = asmlib.GetOpVar("FORM_DRWSPKY"), asmlib.GetOpVar("MISS_NOAV")
local out = (rec and tostring(stringGetFileName(rec.Slot)) or nav)
scr:DrawText(fmt:format(fky:format(key), typ, out, inf))
end,
["MTX"] = function(scr, key, typ, inf, def, spn)
local tab = spn[key]:ToTable()
local fmt = asmlib.GetOpVar("FORM_DRAWDBG")
local fky = asmlib.GetOpVar("FORM_DRWSPKY")
for iR = 1, 4 do
local out = asmlib.GetReport2(iR,tableConcat(tab[iR], ","))
scr:DrawText(fmt:format(fky:format(key), typ, out, inf))
end
end,
},
{Name = "Origin",
{"F" , "VEC", "Forward direction"},
{"R" , "VEC", "Right direction"},
{"U" , "VEC", "Up direction"},
{"OPos", "VEC", "Origin position"},
{"OAng", "ANG", "Origin angles"},
{"SPos", "VEC", "Spawn position"},
{"SAng", "ANG", "Spawn angles"},
{"DPos", "VEC", "Domain position"},
{"DAng", "ANG", "Domain angles"}
},
{Name = "Holder",
{"HPnt", "VEC", "P # Holder radius vector"},
{"HOrg", "VEC", "O # Holder mass center position"},
{"HAng", "ANG", "A # Holder custom angles"}
},
{Name = "Traced",
{"TPnt", "VEC", "P # Trace radius vector"},
{"TOrg", "VEC", "O # Trace mass center position"},
{"TAng", "ANG", "A # Trace custom angles"},
},
{Name = "Offsets",
{"PNxt", "VEC", "Custom user position"},
{"ANxt", "ANG", "Custom user angles"}
}
})

if(SERVER) then
asmlib.SetAction("DUPE_PHYS_SETTINGS",
function(oPly,oEnt,tData) -- Duplicator wrapper
Expand Down
127 changes: 75 additions & 52 deletions lua/gearassembly/gearasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ local mathModf = math and math.modf
local mathSqrt = math and math.sqrt
local mathFloor = math and math.floor
local mathClamp = math and math.Clamp
local mathRemap = math and math.Remap
local mathRandom = math and math.random
local undoCreate = undo and undo.Create
local undoFinish = undo and undo.Finish
Expand Down Expand Up @@ -338,7 +339,7 @@ function GetOwner(oEnt)
ows = oEnt.player; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.Owner; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.owner; if(IsPlayer(ows)) then return ows else ows = nil end
if(set) then -- Duplicatior die functions are registered
if(set) then -- Duplicator the functions are registered
set = set.GetCountUpdate; ows = (set.Args and set.Args[1] or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
set = set.undo1; ows = (set.Args and set.Args[1] or nil)
Expand Down Expand Up @@ -419,7 +420,7 @@ end
* pFile > The file to read the line of characters from
* bCons > Keeps data consistency. Enable to skip trim
* sChar > Custom pattern to be used when trimming
* Reurns line contents and reaching EOF flag
* Returns line contents and reaching EOF flag
* sLine > The line being read from the file
* isEOF > Flag indicating pointer reached EOF
]]
Expand Down Expand Up @@ -454,7 +455,7 @@ function WorkshopID(sKey, sID)
end -- Report overwrite value is present in the list
else -- The number does not meet the format
LogInstance("("..sKey..") Mismatch "..GetReport2(sWS, sID))
end -- Rerurn the current value under the specified key
end -- Return the current value under the specified key
end; return sWS
end

Expand Down Expand Up @@ -520,14 +521,14 @@ end
vMsg > Message being displayed
vSrc > Name of the sub-routine call (string) or parameter stack (table)
bCon > Force output in console flag
iDbg > Debug table overrive depth
tDbg > Debug table overrive
iDbg > Debug table override depth
tDbg > Debug table override
]]
function LogInstance(vMsg, vSrc, bCon, iDbg, tDbg)
local nMax = (tonumber(GetOpVar("LOG_MAXLOGS")) or 0)
if(nMax and (nMax <= 0)) then return end
local vSrc, bCon, iDbg, tDbg = vSrc, bCon, iDbg, tDbg
if(vSrc and IsTable(vSrc)) then -- Recieve the stack as table
if(vSrc and IsTable(vSrc)) then -- Receive the stack as table
vSrc, bCon, iDbg, tDbg = vSrc[1], vSrc[2], vSrc[3], vSrc[4] end
iDbg = mathFloor(tonumber(iDbg) or 0); iDbg = ((iDbg > 0) and iDbg or nil)
local tInfo = (iDbg and debugGetinfo(iDbg) or nil) -- Pass stack index
Expand Down Expand Up @@ -597,7 +598,7 @@ end

function LogTable(tT, sS, vSrc, bCon, iDbg, tDbg)
local vSrc, bCon, iDbg, tDbg = vSrc, bCon, iDbg, tDbg
if(vSrc and IsTable(vSrc)) then -- Recieve the stack as table
if(vSrc and IsTable(vSrc)) then -- Receive the stack as table
vSrc, bCon, iDbg, tDbg = vSrc[1], vSrc[2], vSrc[3], vSrc[4] end
local tP = {vSrc, bCon, iDbg, tDbg} -- Normalize parameters
tP[1], tP[2] = tostring(vSrc or ""), tobool(bCon)
Expand Down Expand Up @@ -719,33 +720,6 @@ function InitBase(sName,sPurp)
SetOpVar("TABLE_WSIDADDON", {})
SetOpVar("TABLE_FLAGS", {})
SetOpVar("TABLE_CONTAINER",{})
if(CLIENT) then
SetOpVar("FORM_ICONS","icon16/%s.png")
SetOpVar("TABLE_SKILLICON",{})
SetOpVar("TABLE_CATEGORIES",{})
SetOpVar("STRUCT_SPAWN",{
{"--- Origin ---"},
{"F", "VEC", "Forward direction"},
{"R", "VEC", "Right direction"},
{"U", "VEC", "Up direction"},
{"OPos", "VEC", "Origin position"},
{"OAng", "ANG", "Origin angles"},
{"SPos", "VEC", "Spawn position"},
{"SAng", "ANG", "Spawn angles"},
{"DPos", "VEC", "Domain position"},
{"DAng", "ANG", "Domain angles"},
{"--- Holder ---"},
{"HPnt", "VEC", "Radius vector"},
{"HOrg", "VEC", "Mass center position"},
{"HAng", "ANG", "Custom angles"},
{"--- Traced ---"},
{"TPnt", "VEC", "Radius vector"},
{"TOrg", "VEC", "Mass center position"},
{"TAng", "ANG", "Custom angles"},
{"--- Offsets ---"},
{"PNxt", "VEC", "Custom user position"},
{"ANxt", "ANG", "Custom user angles"}})
end
SetOpVar("MODELNAM_FILE","%.mdl")
SetOpVar("MODELNAM_FUNC",function(x) return " "..x:sub(2,2):upper() end)
SetOpVar("QUERY_STORE", {})
Expand All @@ -758,7 +732,14 @@ function InitBase(sName,sPurp)
SetOpVar("HASH_QUERY_STORE",GetOpVar("TOOLNAME_PU").."QHASH_QUERY")
SetOpVar("NAV_PIECE",{})
SetOpVar("NAV_PANEL",{})
return StatusPrint(true,"InitBase: Success")
if(CLIENT) then
SetOpVar("FORM_DRWSPKY", "%+6s")
SetOpVar("FORM_DRAWDBG", "%s{%s}: %s > %s")
SetOpVar("FORM_ICONS","icon16/%s.png")
SetOpVar("CLIPBOARD_TEXT","")
SetOpVar("TABLE_SKILLICON",{})
SetOpVar("TABLE_CATEGORIES",{})
end; return StatusPrint(true,"InitBase: Success")
end

------------- ANGLE ---------------
Expand Down Expand Up @@ -924,7 +905,7 @@ function GetContainer(sKey, sDef)
local mData, mID, self = {}, {}, {}
local mDef = sDef or GetOpVar("KEY_DEFAULT")
local miTop, miAll, mhCnt = 0, 0, 0
-- Returns the container iser information
-- Returns the container user information
function self:GetKey() return mKey end
-- Returns the largest index in the array part
function self:GetSize() return miTop end
Expand All @@ -936,9 +917,9 @@ function GetContainer(sKey, sDef)
function self:GetData() return mData end
-- Returns the container hash ID reference
function self:GetHashID() return mID end
-- Calls a manual collet garbage
-- Calls a manual collect garbage
function self:Collect() collectgarbage(); return self end
-- Checkes whenever there are wholes in the array part
-- Checks whenever there are wholes in the array part
function self:IsRagged() return (miAll ~= miTop) end
-- Reads the data from the container
function self:Select(nsKey)
Expand Down Expand Up @@ -1435,7 +1416,7 @@ function SetComboBoxList(cPanel, sVar)
end -- Copy the combo box content shown
pItem.OnSelect = function(pnSelf, nInd, sVal, anyData)
SetAsmConvar(nil, sVar, anyData)
end -- Apply the settinc to the specified variable
end -- Apply the setting to the specified variable
for iD = 1, #tSet do local sI = tSet[iD]
local sIco = ToIcon(sNam.."_"..sI:lower())
local sPrv = (sBase.."_"..sI:lower())
Expand Down Expand Up @@ -1463,7 +1444,7 @@ function SetNumSlider(cPanel, sVar, vDig, vMin, vMax, vDev)
-- Read minimum value form the first available
if(not IsHere(nMin)) then nMin, nDum = GetBorder(sKey)
if(not IsHere(nMin)) then nMin = GetAsmConvar(sVar, "MIN")
if(not IsHere(nMin)) then -- Mininum bound is not located
if(not IsHere(nMin)) then -- Minimum bound is not located
nMin = -mathAbs(2 * mathFloor(GetAsmConvar(sVar, "FLT")))
LogInstance("(L) Miss "..GetReport1(sKey))
else LogInstance("(L) Cvar "..GetReport2(sKey, nMin)) end
Expand Down Expand Up @@ -1497,7 +1478,7 @@ function SetButtonSlider(cPanel, sVar, nMin, nMax, nDec, tBtn)
local sTool = GetOpVar("TOOLNAME_NL")
local tConv = GetOpVar("STORE_CONVARS")
local syDis = GetOpVar("OPSYM_DISABLE")
local syRev = GetOpVar("OPSYM_REVSIGN")
local syRev = GetOpVar("OPSYM_REVISION")
local sKey, sNam, bExa = GetNameExp(sVar)
local sBase = (bExa and sNam or ("tool."..sTool.."."..sNam))
local pPanel = vguiCreate("DAsmInSliderButton", cPanel); if(not IsValid(pPanel)) then
Expand All @@ -1506,14 +1487,56 @@ 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)
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) 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:sub(1,1) == syRev) then
sTip = languageGetPhrase(sBase.."_bas"..sTxt)
elseif(sTip:sub(1,1) == syDis) then
sTip = languageGetPhrase("tool."..sTool..".buttonas"..sTxt)
end
if(sTxt:sub(1,1) == syRev) then
local sVam = sTxt:sub(2,-1)
if(tonumber(sVam)) then
local nAmt = (tonumber(sVam) or 0)
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(sVam == "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(sVam == "M") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(tonumber(GtOpVar("CLIPBOARD_TEXT")) or 0) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) SetClipboardText(nS); SetOpVar("CLIPBOARD_TEXT", nS) 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(GetSnap(nS,-GetAsmConvar("incsnpang","FLT"))) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) pS:SetValue(GetSnap(nS, GetAsmConvar("incsnpang","FLT"))) end
end
end
pPanel:SetButton(sTxt, sTip)
pPanel:SetAction(vBtn.L, vBtn.R)
Expand Down Expand Up @@ -2469,7 +2492,7 @@ local function TimerAttach(oArea,tKeys,defTable,anyMessage)
local nNowTM, tTimer = Time(), defTable.Timer -- See that there is a timer and get "now"
if(not IsHere(tTimer)) then
return StatusLog(Spot[Key],"TimerAttach: Missing timer settings") end
Spot[Key].Used = nNowTM -- Make the first selected deletable to avoid phantom records
Spot[Key].Used = nNowTM -- Make the first selected deleteable to avoid phantom records
local nLifeTM = tTimer[2]
if(nLifeTM <= 0) then
return StatusLog(Spot[Key],"TimerAttach: Timer attachment ignored") end
Expand Down Expand Up @@ -2539,10 +2562,10 @@ function CacheBoxLayout(oEnt,nCamX,nCamZ)
local oRec = CacheQueryPiece(sMod); if(not IsHere(oRec)) then
LogInstance("Record invalid <"..sMod..">"); return nil end
local stBox = oRec.Layout; if(not IsHere(stBox)) then
oRec.Layout = {}; stBox = oRec.Layout -- Allocated chace layout
oRec.Layout = {}; stBox = oRec.Layout -- Allocated cache layout
stBox.Cen, stBox.Ang = oEnt:OBBCenter(), Angle() -- Layout position and angle
stBox.Eye = oEnt:LocalToWorld(stBox.Cen) -- Layout camera eye
stBox.Len = oEnt:BoundingRadius() -- Use bounding radius as enity size
stBox.Len = oEnt:BoundingRadius() -- Use bounding radius as entity size
stBox.Cam = Vector(stBox.Eye) -- Layout camera position
local nX = stBox.Len * (tonumber(nCamX) or 0) -- Calculate camera X
local nZ = stBox.Len * (tonumber(nCamZ) or 0) -- Calculate camera Z
Expand Down
16 changes: 12 additions & 4 deletions lua/vgui/dasminsliderbutton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,25 @@ function PANEL:SetAction(fLef, fRgh, vIdx)
local iIdx = self:GetButtonID(vIdx)
if(iIdx == 0) then return self end
local pBut, pSer = self.Array[iIdx], self.Slider
pBut.DoClick = function()
local pS, sE = pcall(fLef, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
if(fLef) then
pBut.DoClick = function()
local pS, sE = pcall(fLef, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
end
else
if(not pBut.DoClick) then
pBut.DoClick = function() SetClipboardText(pBut:GetText()) end
end
end
if(fRgh) then
pBut.DoRightClick = function()
local pS, sE = pcall(fRgh, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
end
else
pBut.DoRightClick = function() SetClipboardText(pBut:GetText()) end
if(not pBut.DoRightClick) then
pBut.DoRightClick = function() SetClipboardText(pBut:GetText()) end
end
end; return self
end

Expand Down
Loading