diff --git a/data/expression2/TA_ExtensionTest.txt b/data/expression2/TA_ExtensionTest.txt index c85ae552..2837f97c 100644 --- a/data/expression2/TA_ExtensionTest.txt +++ b/data/expression2/TA_ExtensionTest.txt @@ -77,7 +77,7 @@ if(first() || dupefinished()) print("Skin OK<"+B+">") }else{ error("Skin fail "+B) } - E1 = E:trackasmlibMakePiece(E:pos(), E:angles():rotateAroundAxis(E:up(), 90)) - E2 = E:trackasmlibMakePiece(E:pos(), E:angles():rotateAroundAxis(E:forward(), 90), 666, "0/0", vec(50, 150, 250)) - E2 = E:trackasmlibMakePiece(E:pos(), E:angles():rotateAroundAxis(E:forward(), -90), 666, "0/0", vec(250, 150, 50)) + E1 = E:trackasmlibNewPiece(E:pos(), E:angles():rotateAroundAxis(E:up(), 90)) + E2 = E:trackasmlibNewPiece(E:pos(), E:angles():rotateAroundAxis(E:forward(), 90), 666, "0/0", vec(50, 150, 250)) + E2 = E:trackasmlibNewPiece(E:pos(), E:angles():rotateAroundAxis(E:forward(), -90), 666, "0/0", vec(250, 150, 50)) } diff --git a/lua/autorun/trackassembly_init.lua b/lua/autorun/trackassembly_init.lua index 8efeba65..547419ce 100644 --- a/lua/autorun/trackassembly_init.lua +++ b/lua/autorun/trackassembly_init.lua @@ -84,7 +84,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present ------------ CONFIGURE ASMLIB ------------ asmlib.InitBase("track","assembly") -asmlib.SetOpVar("TOOL_VERSION","8.764") +asmlib.SetOpVar("TOOL_VERSION","8.765") ------------ CONFIGURE GLOBAL INIT OPVARS ------------ @@ -152,40 +152,40 @@ asmlib.SetBorder(gsToolPrefL.."rtradmenu", -gnMaxRot, gnMaxRot) ------------ CONFIGURE LOGGING ------------ asmlib.SetOpVar("LOG_DEBUGEN",false) -asmlib.MakeAsmConvar("logsmax", 0, nil, gnIndependentUsed, "Maximum logging lines being written") -asmlib.MakeAsmConvar("logfile", 0, nil, gnIndependentUsed, "File logging output flag control") +asmlib.NewAsmConvar("logsmax", 0, nil, gnIndependentUsed, "Maximum logging lines being written") +asmlib.NewAsmConvar("logfile", 0, nil, gnIndependentUsed, "File logging output flag control") asmlib.SetLogControl(asmlib.GetAsmConvar("logsmax","INT"), asmlib.GetAsmConvar("logfile","BUL")) asmlib.SettingsLogs("SKIP"); asmlib.SettingsLogs("ONLY") ------------ CONFIGURE NON-REPLICATED CVARS ------------ Client's got a mind of its own -asmlib.MakeAsmConvar("modedb" , "LUA", nil, gnIndependentUsed, "Database storage operating mode LUA or SQL") -asmlib.MakeAsmConvar("devmode" , 0 , nil, gnIndependentUsed, "Toggle developer mode on/off server side") -asmlib.MakeAsmConvar("maxtrmarg", 0.02 , nil, gnIndependentUsed, "Maximum time to avoid performing new traces") -asmlib.MakeAsmConvar("maxmenupr", 5 , nil, gnIndependentUsed, "Maximum decimal places utilized in the control panel") -asmlib.MakeAsmConvar("timermode", "CQT@1800@1@1/CQT@900@1@1/CQT@600@1@1", nil, gnIndependentUsed, "Memory management setting when DB mode is SQL") +asmlib.NewAsmConvar("modedb" , "LUA", nil, gnIndependentUsed, "Database storage operating mode LUA or SQL") +asmlib.NewAsmConvar("devmode" , 0 , nil, gnIndependentUsed, "Toggle developer mode on/off server side") +asmlib.NewAsmConvar("maxtrmarg", 0.02 , nil, gnIndependentUsed, "Maximum time to avoid performing new traces") +asmlib.NewAsmConvar("maxmenupr", 5 , nil, gnIndependentUsed, "Maximum decimal places utilized in the control panel") +asmlib.NewAsmConvar("timermode", "CQT@1800@1@1/CQT@900@1@1/CQT@600@1@1", nil, gnIndependentUsed, "Memory management setting when DB mode is SQL") ------------ CONFIGURE REPLICATED CVARS ------------ Server tells the client what value to use -asmlib.MakeAsmConvar("maxmass" , 50000 , nil, gnServerControled, "Maximum mass that can be applied on a piece") -asmlib.MakeAsmConvar("maxlinear", 5000 , nil, gnServerControled, "Maximum linear offset of the piece") -asmlib.MakeAsmConvar("maxforce" , 100000, nil, gnServerControled, "Maximum force limit when creating welds") -asmlib.MakeAsmConvar("maxactrad", 200 , nil, gnServerControled, "Maximum active radius to search for a point ID") -asmlib.MakeAsmConvar("maxstcnt" , 200 , nil, gnServerControled, "Maximum spawned pieces in stacking mode") -asmlib.MakeAsmConvar("maxghcnt" , 1500 , nil, gnServerControled, "Maximum ghost pieces being spawned by client") -asmlib.MakeAsmConvar("enwiremod", 1 , nil, gnServerControled, "Toggle the wire extension on/off server side") -asmlib.MakeAsmConvar("enmultask", 1 , nil, gnServerControled, "Toggle the spawn multitasking on/off server side") -asmlib.MakeAsmConvar("enctxmenu", 1 , nil, gnServerControled, "Toggle the context menu on/off in general") -asmlib.MakeAsmConvar("enctxmall", 0 , nil, gnServerControled, "Toggle the context menu on/off for all props") -asmlib.MakeAsmConvar("endsvlock", 0 , nil, gnServerControled, "Toggle the DSV external database file update on/off") -asmlib.MakeAsmConvar("curvefact", 0.5 , nil, gnServerControled, "Parametric constant track curving factor") -asmlib.MakeAsmConvar("curvsmple", 50 , nil, gnServerControled, "Amount of samples between two curve nodes") -asmlib.MakeAsmConvar("spawnrate", 1 , nil, gnServerControled, "Maximum pieces spawned in every think tick") -asmlib.MakeAsmConvar("bnderrmod","LOG" , nil, gnServerControled, "Unreasonable position error handling mode") -asmlib.MakeAsmConvar("maxfruse" , 50 , nil, gnServerControled, "Maximum frequent pieces to be listed") -asmlib.MakeAsmConvar("maxspmarg", 0 , nil, gnServerControled, "Maximum spawn distance new piece created margin") -asmlib.MakeAsmConvar("dtmessage", 1 , nil, gnServerControled, "Time interval for server addressed messages") -asmlib.MakeAsmConvar("*sbox_max"..gsLimitName, 1500, nil, gnServerControled, "Maximum number of tracks to be spawned") +asmlib.NewAsmConvar("maxmass" , 50000 , nil, gnServerControled, "Maximum mass that can be applied on a piece") +asmlib.NewAsmConvar("maxlinear", 5000 , nil, gnServerControled, "Maximum linear offset of the piece") +asmlib.NewAsmConvar("maxforce" , 100000, nil, gnServerControled, "Maximum force limit when creating welds") +asmlib.NewAsmConvar("maxactrad", 200 , nil, gnServerControled, "Maximum active radius to search for a point ID") +asmlib.NewAsmConvar("maxstcnt" , 200 , nil, gnServerControled, "Maximum spawned pieces in stacking mode") +asmlib.NewAsmConvar("maxghcnt" , 1500 , nil, gnServerControled, "Maximum ghost pieces being spawned by client") +asmlib.NewAsmConvar("enwiremod", 1 , nil, gnServerControled, "Toggle the wire extension on/off server side") +asmlib.NewAsmConvar("enmultask", 1 , nil, gnServerControled, "Toggle the spawn multitasking on/off server side") +asmlib.NewAsmConvar("enctxmenu", 1 , nil, gnServerControled, "Toggle the context menu on/off in general") +asmlib.NewAsmConvar("enctxmall", 0 , nil, gnServerControled, "Toggle the context menu on/off for all props") +asmlib.NewAsmConvar("endsvlock", 0 , nil, gnServerControled, "Toggle the DSV external database file update on/off") +asmlib.NewAsmConvar("curvefact", 0.5 , nil, gnServerControled, "Parametric constant track curving factor") +asmlib.NewAsmConvar("curvsmple", 50 , nil, gnServerControled, "Amount of samples between two curve nodes") +asmlib.NewAsmConvar("spawnrate", 1 , nil, gnServerControled, "Maximum pieces spawned in every think tick") +asmlib.NewAsmConvar("bnderrmod","LOG" , nil, gnServerControled, "Unreasonable position error handling mode") +asmlib.NewAsmConvar("maxfruse" , 50 , nil, gnServerControled, "Maximum frequent pieces to be listed") +asmlib.NewAsmConvar("maxspmarg", 0 , nil, gnServerControled, "Maximum spawn distance new piece created margin") +asmlib.NewAsmConvar("dtmessage", 1 , nil, gnServerControled, "Time interval for server addressed messages") +asmlib.NewAsmConvar("*sbox_max"..gsLimitName, 1500, nil, gnServerControled, "Maximum number of tracks to be spawned") ------------ CONFIGURE INTERNALS ------------ @@ -680,7 +680,7 @@ if(CLIENT) then local atGho = asmlib.GetOpVar("ARRAY_GHOST") if(asmlib.IsModel(model)) then if(not (asmlib.HasGhosts() and ghcnt == atGho.Size and atGho.Slot == model)) then - if(not asmlib.MakeGhosts(ghcnt, model)) then + if(not asmlib.NewGhosts(ghcnt, model)) then asmlib.LogInstance("Ghosting fail",sLog); return nil end actTool:ElevateGhost(atGho[1], oPly) -- Elevate the properly created ghost end; actTool:UpdateGhost(oPly) -- Update ghosts stack for the local player @@ -1257,7 +1257,7 @@ if(CLIENT) then if(asmlib.IsModel(trRec.Slot)) then -- The model has valid pre-cache if(ghostcnt > 0) then -- The ghosting is enabled if(not (hasghost and atGhosts.Size == 1 and trRec.Slot == atGhosts.Slot)) then - if(not asmlib.MakeGhosts(1, trRec.Slot)) then + if(not asmlib.NewGhosts(1, trRec.Slot)) then asmlib.LogInstance("Ghosting fail",sLog); return nil end end local eGho = atGhosts[1]; eGho:SetNoDraw(false) eGho:SetPos(actSpawn.SPos); eGho:SetAngles(actSpawn.SAng) @@ -1659,9 +1659,9 @@ asmlib.CreateTable("PIECES",{ local noTY = asmlib.GetOpVar("MISS_NOTP") local noSQL = asmlib.GetOpVar("MISS_NOSQL") local trCls = asmlib.GetOpVar("TRACE_CLASS") - arLine[2] = asmlib.GetTerm(arLine[2], noTY, asmlib.Categorize()) - arLine[3] = asmlib.GetTerm(arLine[3], noMD, asmlib.ModelToName(arLine[1])) - arLine[8] = asmlib.GetTerm(arLine[8], noSQL, noSQL) + arLine[2] = asmlib.GetVacant(arLine[2], true, noTY, asmlib.Categorize()) + arLine[3] = asmlib.GetVacant(arLine[3], true, noMD, asmlib.ModelToName(arLine[1])) + arLine[8] = asmlib.GetVacant(arLine[8], true, noSQL, noSQL) if(not (asmlib.IsNull(arLine[8]) or trCls[arLine[8]] or asmlib.IsBlank(arLine[8]))) then asmlib.LogInstance("Register trace "..asmlib.GetReport2(arLine[8],arLine[1]),vSrc) trCls[arLine[8]] = true; -- Register the class provided to the trace hit list @@ -1786,7 +1786,7 @@ asmlib.CreateTable("PHYSPROPERTIES",{ Trigs = { Record = function(arLine, vSrc) local noTY = asmlib.GetOpVar("MISS_NOTP") - arLine[1] = asmlib.GetTerm(arLine[1],noTY,asmlib.Categorize()); return true + arLine[1] = asmlib.GetVacant(arLine[1],true,noTY,asmlib.Categorize()); return true end }, Cache = { diff --git a/lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua b/lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua index 1855840b..78fb520a 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua @@ -349,7 +349,7 @@ e2function entity entity:trackasmlibNewPiece(vector vPos, angle aAng) end __e2setcost(15) -e2function entity entity:trackasmlibApplyPhysicalAnchor(entity eBase, number nWe, number nNc, number nNw, number nFm) +e2function number entity:trackasmlibApplyPhysicalAnchor(entity eBase, number nWe, number nNc, number nNw, number nFm) if(not (this and this:IsValid() and enFlag)) then return anyFalse end if(not (eBase and eBase:IsValid())) then return anyFalse end local stRec = asmlib.CacheQueryPiece(this:GetModel()); if(not stRec) then return anyFalse end @@ -357,7 +357,7 @@ e2function entity entity:trackasmlibApplyPhysicalAnchor(entity eBase, number nWe end __e2setcost(15) -e2function entity entity:trackasmlibApplyPhysicalSettings(number nPi, number nFr, number nGr, string sPh) +e2function number entity:trackasmlibApplyPhysicalSettings(number nPi, number nFr, number nGr, string sPh) if(not (this and this:IsValid() and enFlag)) then return anyFalse end local stRec = asmlib.CacheQueryPiece(this:GetModel()); if(not stRec) then return anyFalse end return asmlib.ApplyPhysicalSettings(this,(nPi~=0),(nFr~=0),(nGr~=0),sPh) and anyTrue or anyFalse @@ -379,12 +379,12 @@ end __e2setcost(20) e2function string entity:trackasmlibGetBodyGroups() - if(not (this and this:IsValid() and enFlag)) then return 0 end + if(not (this and this:IsValid() and enFlag)) then return "" end return asmlib.GetPropBodyGroup(this) end __e2setcost(20) e2function string entity:trackasmlibGetSkin() - if(not (this and this:IsValid() and enFlag)) then return 0 end + if(not (this and this:IsValid() and enFlag)) then return "" end return asmlib.GetPropSkin(this) end diff --git a/lua/trackassembly/trackasmlib.lua b/lua/trackassembly/trackasmlib.lua index 2ddb6fcc..914d6197 100644 --- a/lua/trackassembly/trackasmlib.lua +++ b/lua/trackassembly/trackasmlib.lua @@ -438,13 +438,6 @@ function GetOwner(oEnt) end; return ows -- No owner is found. Nothing is returned end -function GetVacant(sStr) - local sD = GetOpVar("OPSYM_DISABLE") - local sS = tostring(sStr or "") -- Default to string - local bE = (IsBlank(sS) or IsNull(sS) or sS:sub(1,1) == sD) - return bE, sS -- Scan whenever data to be decoded is present -end - ------------------ LOGS ------------------------ function GetLogID() @@ -1824,10 +1817,11 @@ function GetFrequentModels(snCount) end function SetComboBoxClipboard(pnCombo) + local sV = pnCombo:GetValue() local iD = pnCombo:GetSelectedID() - local vT = pnCombo:GetOptionText(iD) - local sV = GetTerm(tostring(vT or ""), pnCombo:GetValue()) - SetClipboardText(GetTerm(sV, gsNoAV)) + local sT = pnCombo:GetOptionText(iD) + local sS = GetVacant(tostring(sT or ""), true, sS) + SetClipboardText(GetVacant(sS, true, gsNoAV)) end function SetComboBoxList(cPanel, sVar) @@ -2136,7 +2130,7 @@ end * vPos > Custom position for the placeholder ( zero if none ) * aAng > Custom angles for the placeholder ( zero if none ) ]] -function MakeEntityNone(sModel, vPos, aAng) local eNone +function NewEntityNone(sModel, vPos, aAng) local eNone if(not IsModel(sModel)) then return nil end if(SERVER) then eNone = entsCreate(GetOpVar("ENTITY_DEFCLASS")) elseif(CLIENT) then eNone = entsCreateClientProp(sModel) end @@ -2169,7 +2163,7 @@ function GetAttachmentByID(sModel, sID) if(ePiece:GetModel() ~= sModel) then ePiece:SetModel(sModel) LogInstance("Update "..GetReport3(ePiece:EntIndex(), sID, sModel)) end else -- If there is no basis need to create one for attachment extraction - ePiece = MakeEntityNone(sModel); if(not (ePiece and ePiece:IsValid())) then + ePiece = NewEntityNone(sModel); if(not (ePiece and ePiece:IsValid())) then LogInstance("Basis creation error "..GetReport2(sID, sModel)); return nil end SetOpVar("ENTITY_TRANSFORMPOA", ePiece) -- Register the entity transform basis end -- Transfer the data from the transform attachment location @@ -2329,20 +2323,24 @@ function Sort(tTable, tCols) end ------------- VARIABLE INTERFACES -------------- + --[[ - * Returns a string term whenever it is is missing or disabled + * Returns a string term whenever it is missing or disabled * If these conditions are not met the function returns missing token * sBas > The string to check whenever it is disabled or missing * vDef > The default value to return when base is not string * vDsb > The disable value to return when the base is disabled string ]] -function GetTerm(sBas, vDef, vDsb) - local sM = GetOpVar("MISS_NOAV") +function GetVacant(sBas, bTer, vDef, vDsb) local sD = GetOpVar("OPSYM_DISABLE") - if(IsString(sBas)) then - if(sBas:sub(1,1) == sD) then return tostring(vDsb or sM) - elseif(not (IsNull(sBas) or IsBlank(sBas))) then return sBas end - end; if(IsString(vDef)) then return vDef end; return sM + local sS = tostring(sBas or "") -- Default to string + local bD = (sS:sub(1,1) == sD) -- Disabled string + local bE = (IsBlank(sS) or IsNull(sS) or bD) + if(not bTer) then return bE, sS end -- Data to be decoded + local sM = GetOpVar("MISS_NOAV") -- Not available + if(bD) then return tostring(vDsb or sM) end + if(bE) then return tostring(vDef or sM) end + return sS -- Return the base string end function ModelToNameRule(sRule, gCut, gSub, gApp) @@ -2603,8 +2601,8 @@ function CreateTable(sTable,defTab,bDelete,bReload) local self, tabDef, tabCmd = {}, defTab, {} local symDis, sMoDB = GetOpVar("OPSYM_DISABLE"), GetOpVar("MODE_DATABASE") for iCnt = 1, defTab.Size do local defCol = defTab[iCnt] - defCol[3] = GetTerm(tostring(defCol[3] or symDis), symDis) - defCol[4] = GetTerm(tostring(defCol[4] or symDis), symDis) + defCol[3] = GetVacant(tostring(defCol[3] or symDis), true, symDis) + defCol[4] = GetVacant(tostring(defCol[4] or symDis), true, symDis) end; tableInsert(libQTable, defTab.Nick) libCache[defTab.Name] = {}; libQTable[defTab.Nick] = self -- Read table definition @@ -4649,7 +4647,7 @@ function NewPiece(pPly,sModel,vPos,aAng,nMass,sBgSkIDs,clColor,sMode) if(InSpawnMargin(pPly, stData, vPos, aAng)) then LogInstance("Spawn margin stop <"..sModel..">"); return nil end local sClass = GetOpVar("ENTITY_DEFCLASS") - local ePiece = entsCreate(GetTerm(stData.Unit, sClass, sClass)) + local ePiece = entsCreate(GetVacant(stData.Unit, true, sClass, sClass)) if(not (ePiece and ePiece:IsValid())) then -- Create the piece unit LogInstance("Piece invalid <"..tostring(ePiece)..">"); return nil end ePiece:SetCollisionGroup(COLLISION_GROUP_NONE) @@ -5043,7 +5041,7 @@ end * aAng > Angles for the entity, otherwise zero is used * It must have been our imagination. ]] -function MakeEntityGhost(sModel, vPos, aAng) +function NewEntityGhost(sModel, vPos, aAng) if(not IsModel(sModel)) then return nil end local cPal = GetContainer("COLORS_LIST") local eGho = entsCreateClientProp(sModel) @@ -5075,7 +5073,7 @@ end * sModel > The model which the creation is requested for * Not until we walk around the ghost town and see what we can find. ]] -function MakeGhosts(nCnt, sModel) -- Only he's not a shadow, he's a green ghost! +function NewGhosts(nCnt, sModel) -- Only he's not a shadow, he's a green ghost! if(SERVER) then return true end -- Ghosting is client side only local tGho = GetOpVar("ARRAY_GHOST") -- Read ghosts if(nCnt == 0 and tGho.Size == 0) then return true end -- Skip processing @@ -5085,7 +5083,7 @@ function MakeGhosts(nCnt, sModel) -- Only he's not a shadow, he's a green ghost! if(eGho and eGho:IsValid()) then eGho:SetNoDraw(true) if(eGho:GetModel() ~= sModel) then eGho:SetModel(sModel) end else -- Reconfigure the first `nCnt` ghosts - tGho[iD] = MakeEntityGhost(sModel); eGho = tGho[iD] + tGho[iD] = NewEntityGhost(sModel); eGho = tGho[iD] if(not (eGho and eGho:IsValid())) then ClearGhosts(iD) LogInstance("Invalid ["..iD.."]"..sModel); return false end end; iD = iD + 1 -- Fade all the ghosts and refresh these that must be drawn diff --git a/lua/weapons/gmod_tool/stools/trackassembly.lua b/lua/weapons/gmod_tool/stools/trackassembly.lua index eb63a360..ee53419b 100644 --- a/lua/weapons/gmod_tool/stools/trackassembly.lua +++ b/lua/weapons/gmod_tool/stools/trackassembly.lua @@ -2402,7 +2402,7 @@ function TOOL.BuildCPanel(CPanel) local pComboPhysName = CPanel:ComboBox(languageGetPhrase("tool."..gsToolNameL..".phyname_con"), sName) pComboPhysName:SetTooltip(languageGetPhrase("tool."..gsToolNameL..".phyname")) - pComboPhysName:SetValue(asmlib.GetTerm(asmlib.GetAsmConvar("physmater","STR"), + pComboPhysName:SetValue(asmlib.GetVacant(asmlib.GetAsmConvar("physmater","STR"), true, languageGetPhrase("tool."..gsToolNameL..".phyname_def"))) pComboPhysName.DoRightClick = function(pnSelf) asmlib.SetComboBoxClipboard(pnSelf) end pComboPhysName:Dock(TOP) -- Setting tallness gets ignored otherwise @@ -2437,7 +2437,7 @@ function TOOL.BuildCPanel(CPanel) local sName = asmlib.GetAsmConvar("bgskids", "NAM") local pText = CPanel:TextEntry(languageGetPhrase("tool."..gsToolNameL..".bgskids_con"), sName) pText:SetTooltip(languageGetPhrase("tool."..gsToolNameL..".bgskids")) - pText:SetText(asmlib.GetTerm(asmlib.GetAsmConvar("bgskids", "STR"), + pText:SetText(asmlib.GetVacant(asmlib.GetAsmConvar("bgskids", "STR"), true, languageGetPhrase("tool."..gsToolNameL..".bgskids_def"))) pText:SetEnabled(false); pText:SetTall(22)