Skip to content

Commit

Permalink
Added: Timer definition as table support
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Aug 30, 2024
1 parent 943913c commit 63dcf71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.782")
asmlib.SetOpVar("TOOL_VERSION","8.783")

------------ CONFIGURE GLOBAL INIT OPVARS ------------

Expand Down
25 changes: 16 additions & 9 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2643,13 +2643,20 @@ function NewTable(sTable,defTab,bDelete,bReload)
-- Generates a timer settings table and keeps the defaults
function self:TimerSetup(vTim)
local qtCmd, qtDef = self:GetCommand(), self:GetDefinition()
local sTm = tostring((vTim and vTim or qtDef.Timer) or "")
local tTm = GetOpVar("OPSYM_REVISION"):Explode(sTm)
tTm[1] = tostring(tTm[1] or "CQT") -- Timer mode
tTm[2] = (tonumber(tTm[2]) or 0) -- Record life
tTm[3] = ((tonumber(tTm[3]) or 0) ~= 0) -- Kill command
tTm[4] = ((tonumber(tTm[4]) or 0) ~= 0) -- Collect garbage call
qtCmd.Timer = tTm; return self
local vTm, tTm = (vTim and vTim or qtDef.Timer), qtCmd.Timer
if(not tTm) then qtCmd.Timer = {}; tTm = qtCmd.Timer end
if(isstring(vTm)) then -- String or table passed
local cTm = GetOpVar("OPSYM_REVISION"):Explode(vTm)
tTm[1] = tostring(cTm[1] or "CQT") -- Timer mode
tTm[2] = (tonumber(cTm[2]) or 0) -- Record life
tTm[3] = ((tonumber(cTm[3]) or 0) ~= 0) -- Kill command
tTm[4] = ((tonumber(cTm[4]) or 0) ~= 0) -- Collect garbage call
elseif(istable(vTm)) then -- Transfer table data from definition
tTm[1] = tostring(vTm[1] or vTm["Mo"] or "CQT") -- Timer mode
tTm[2] = (tonumber(vTm[2] or vTm["Li"]) or 0) -- Record life
tTm[3] = ((tonumber(vTm[3] or vTm["Rm"]) or 0) ~= 0) -- Kill command
tTm[4] = ((tonumber(vTm[4] or vTm["Co"]) or 0) ~= 0) -- Collect garbage call
end; return self
end
-- Navigates the reference in the cache
function self:GetNavigate(...)
Expand Down Expand Up @@ -2896,13 +2903,13 @@ function NewTable(sTable,defTab,bDelete,bReload)
local qtCmd = self:GetCommand(); qtCmd.STMT = "INDEX"
local tStmt = qtCmd[qtCmd.STMT]
if(not tStmt) then tStmt = {}; qtCmd[qtCmd.STMT] = tStmt end
tableEmpty(tStmt); tStmt.Size = nA
local sDiv = GetOpVar("OPSYM_DIVIDER"); tableEmpty(tStmt); tStmt.Size = nA
for iCnt = 1, nA do local vA = tA[iCnt]
if(isnumber(vA)) then vA = {vA} end; if(not istable(vA)) then
LogInstance("Argument not table "..GetReport(nA,iCnt,vA),tabDef.Nick); return self:Deny() end
local sV, nV, bNe = "", #vA, (vA.Ne or not IsHere(vA.Ne))
tStmt[iCnt] = "CREATE "..(vA.Un and "UNIQUE " or "")..qtCmd.STMT..(bNe and " IF NOT EXISTS " or " ")
.."IND_"..qtDef.Name.. "_"..tableConcat(vA).." ON "..qtDef.Name.." ( "
.."IND_"..qtDef.Name..sDiv..tableConcat(vA,sDiv).." ON "..qtDef.Name.." ( "
for iInd = 1, nV do
local iV = mathFloor(tonumber(vA[iInd]) or 0); if(iV == 0) then
LogInstance("Index mismatch "..GetReport(nA,iCnt,iInd),tabDef.Nick); return self:Deny() end
Expand Down

0 comments on commit 63dcf71

Please sign in to comment.