Skip to content

Commit

Permalink
Works 100% Added timer for PHYSPROPERTIES
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Nov 22, 2015
1 parent 16fce6c commit 3717a06
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
16 changes: 7 additions & 9 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
asmlib.InitAssembly("track")
asmlib.SetOpVar("TOOL_VERSION","4.106")
asmlib.SetOpVar("TOOL_VERSION","4.107")
asmlib.SetOpVar("DIRPATH_BAS",asmlib.GetOpVar("TOOLNAME_NL")..asmlib.GetOpVar("OPSYM_DIRECTORY"))
asmlib.SetOpVar("DIRPATH_EXP","exp"..asmlib.GetOpVar("OPSYM_DIRECTORY"))
asmlib.SetOpVar("DIRPATH_DSV","dsv"..asmlib.GetOpVar("OPSYM_DIRECTORY"))
Expand Down Expand Up @@ -453,8 +453,8 @@ else
asmlib.InsertRecord({"models/minitrains/switch.mdl", "#", "Switch Y", 2, "", "0, -8.509, 1", ""})
asmlib.InsertRecord({"models/minitrains/switch.mdl", "#", "Switch Y", 3, "", "-128, 6.493, 0.998", "0,-180,0"})
asmlib.DefaultType("PHX Monorail")
asmlib.InsertRecord({"models/props_phx/trains/monorail3.mdl", "#", "Straight Long", 2, "", "0.23999999463558,929.88500976563,13.796999931335", "0,90,0"})
asmlib.InsertRecord({"models/props_phx/trains/monorail3.mdl", "#", "Straight Long", 1, "", "0.23999999463558,-933.13500976563,13.796999931335", "0,-90,0"})
asmlib.InsertRecord({"models/props_phx/trains/monorail3.mdl", "#", "Straight Long", 2, "", "0.23999999463558,929.88500976563,13.796999931335", "0,90,0"})
asmlib.InsertRecord({"models/props_phx/trains/monorail2.mdl", "#", "Straight Middle", 1, "", "0.23899999260902,-461.63598632813,13.798000335693", "0,-90,0"})
asmlib.InsertRecord({"models/props_phx/trains/monorail2.mdl", "#", "Straight Middle", 2, "", "0.26499998569489,463.88500976563,13.803999900818", "0,90,0"})
asmlib.InsertRecord({"models/props_phx/trains/monorail1.mdl", "#", "Straight Short", 1, "", "229.30000305176,0.21699999272823,13.796999931335", ""})
Expand Down Expand Up @@ -503,8 +503,8 @@ else
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_45_down.mdl", "#", "#", 2, "", "71.037002563477,-0.01799999922514,3.9509999752045", "45,0,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_45_up.mdl", "#", "#", 1, "", "-75.013000488281,0.0070000002160668,11.218000411987", "0,180,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_45_up.mdl", "#", "#", 2, "", "71.172996520996,0.003000000026077,71.908996582031", "-45,0,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_x.mdl", "#", "Cross 45", 2, "", "-349.47299194336,49.611000061035,11.215000152588", "0,180,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_x.mdl", "#", "Cross 45", 1, "", "250.45899963379,49.613998413086,11.215000152588", ""})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_x.mdl", "#", "Cross 45", 2, "", "-349.47299194336,49.611000061035,11.215000152588", "0,180,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_x.mdl", "#", "Cross 45", 3, "", "162.61000061035,-162.4940032959,11.232999801636", "0,-45,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_x.mdl", "#", "Cross 45", 4, "", "-261.61999511719,261.73300170898,11.232999801636", "0,135,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_crossing.mdl", "#", "Cross 90", 1, "", "74.978996276855,0,12.559000015259", ""})
Expand Down Expand Up @@ -972,12 +972,10 @@ else
asmlib.DefaultType("Sligwof's Railcar")
asmlib.InsertRecord({"models/swrcs/swrccross.mdl", "#", "Switcher Cross", 1, "", "500,0,0", ""})
asmlib.InsertRecord({"models/swrcs/swrccross.mdl", "#", "Switcher Cross", 2, "", "-2673,0,0", "0,180,0"})
asmlib.InsertRecord({"models/swrcs/swrccross.mdl", "#", "Switcher Cross", 1, "", "500,0,0", ""})
asmlib.InsertRecord({"models/swrcs/swrccross.mdl", "#", "Switcher Cross", 2, "", "-2673,0,0", "0,180,0"})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 1, "", "890, 748.009, 2.994", ""})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 2, "", "890, 451.998, 2.994", ""})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 3, "", "889.999, -452.001, 2.974", ""})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 4, "", "889.999, -748.027, 2.974", ""})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 3, "", "890, -452.001, 2.974", ""})
asmlib.InsertRecord({"models/swrcs/swrccurve001.mdl", "#", "U-Turn", 4, "", "890, -748.027, 2.974", ""})
asmlib.InsertRecord({"models/swrcs/swrclooping.mdl", "#", "Loop 180", 1, "", "810, -252.447, -0.005", ""})
asmlib.InsertRecord({"models/swrcs/swrclooping.mdl", "#", "Loop 180", 2, "", "-809.999, 136.997, -0.002", "0,180,0"})
asmlib.InsertRecord({"models/swrcs/swrcloopingspecial.mdl", "#", "LoopSwitch 180", 1, "", "927.001, -194.403, -0.036", ""})
Expand Down Expand Up @@ -1054,10 +1052,10 @@ else
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_2road_dl_sdw_1x2.mdl", "#", "#", 2, "", "-268, -72, 2.5", "0,-90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_3road_dl_sdw_1x3.mdl", "#", "#", 1, "", "-196,0,1.999", "0,90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_3road_dl_sdw_1x3.mdl", "#", "#", 2, "", "-196,-216,1.999", "0,-90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_4road_dl_sdw_1x4.mdl", "#", "#", 2, "", "-268,-144,2.498", "0,-90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_4road_dl_sdw_1x4.mdl", "#", "#", 1, "", "-268,144,2.499", "0,90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_5road_dl_sdw_1x5.mdl", "#", "#", 2, "", "-268,-180,2.498", "0,-90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_4road_dl_sdw_1x4.mdl", "#", "#", 2, "", "-268,-144,2.498", "0,-90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_5road_dl_sdw_1x5.mdl", "#", "#", 1, "", "-268,180,2.498", "0,90,0"})
asmlib.InsertRecord({"models/buildingspack/roadswsidewalk/2_5road_dl_sdw_1x5.mdl", "#", "#", 2, "", "-268,-180,2.498", "0,-90,0"})
asmlib.SettingsModelToName("SET",nil,{"lot","lot_"},nil)
asmlib.InsertRecord({"models/buildingspack/emptylots/lot16x16.mdl", "#", "#", 1, "", "-268, 575, 2.5", "0,90,0"})
asmlib.InsertRecord({"models/buildingspack/emptylots/lot16x16.mdl", "#", "#", 2, "", "-268, -577.002, 2.501", "0,-90,0"})
Expand Down
76 changes: 39 additions & 37 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,9 @@ function LogInstance(anyStuff)
iNdex = iNdex + 1
sOnly = logOnly[iNdex]
end
if((not logHere) and IsBool(logHere)) then
return
end
end
if((not logHere) and IsBool(logHere)) then
return
end
if(SERVER) then
Log("SERVER > ["..sModeDB.."] "..anyStuff)
Expand Down Expand Up @@ -2404,6 +2404,7 @@ function InsertRecord(sTable,tData)
if(not tTypes) then
Cache[sKeyType] = {}
tTypes = Cache[sKeyType]
tTypes.Kept = 0
end
if(not tNames) then
Cache[sKeyName] = {}
Expand All @@ -2413,11 +2414,15 @@ function InsertRecord(sTable,tData)
if(not IsExistent(iNameID)) then return StatusLog(nil,"InsertRecord: Cannot match "..defTable[2][1]) end
if(not IsExistent(tNames[snPrimayKey])) then
-- If a new type is inserted
local lenTypes = ArrayCount(tTypes)
tTypes[lenTypes + 1] = MatchType(defTable,snPrimayKey,1)
tTypes.Kept = tTypes.Kept + 1
tTypes[tTypes.Kept] = MatchType(defTable,snPrimayKey,1)
tNames[snPrimayKey] = {}
tNames[snPrimayKey].Kept = 0
end
tNames[snPrimayKey][iNameID] = MatchType(defTable,tData[3],3)
tNames[snPrimayKey].Kept = iNameID
Print(tTypes,"tTypes_asd")
Print(tNames,"tNames_asd")
else
return StatusLog(false,"InsertRecord: No settings for table "..sTable)
end
Expand All @@ -2430,19 +2435,14 @@ local function NavigateTable(oLocation,tKeys)
if(not IsExistent(oLocation)) then return StatusLog(nil,"NavigateTable: Location missing") end
if(not IsExistent(tKeys)) then return StatusLog(nil,"NavigateTable: Key table missing") end
if(not IsExistent(tKeys[1])) then return StatusLog(nil,"NavigateTable: First key missing") end
local Cnt = 1
local Place, Key
local Place, Key, Cnt = oLocation, tKeys[1], 1
while(tKeys[Cnt]) do
Key = tKeys[Cnt]
if(Place) then
if(tKeys[Cnt+1]) then
Place = Place[Key]
if(not IsExistent(Place)) then return StatusLog(nil,"NavigateTable: Key #"..tostring(Key).." irrelevant to location") end
end
else
Place = oLocation[Key]
if(not IsExistent(Place)) then return StatusLog(nil,"NavigateTable: First key irrelevant to location") end
end
if(tKeys[Cnt+1]) then
Place = Place[Key]
LogInstance("NavigateTable: Step ["..Key.."]")
if(not IsExistent(Place)) then return StatusLog(nil,"NavigateTable: Key #"..tostring(Key).." irrelevant to location") end
end
Cnt = Cnt + 1
end
return Place, Key
Expand All @@ -2452,8 +2452,8 @@ function TimerSetting(sTimerSet) -- Generates a timer settings table and keeps t
if(not IsExistent(sTimerSet)) then return StatusLog(nil,"TimerSetting: No setting netting") end
if(not IsString(sTimerSet)) then return StatusLog(nil,"TimerSetting: Setting not a string") end
local tBoom = StringExplode(sTimerSet,GetOpVar("OPSYM_REVSIGN"))
tBoom[1] = tostring(tBoom[1] or "CQT")
tBoom[2] = (tonumber(tBoom[2]) or 0)
tBoom[1] = tostring(tBoom[1] or "CQT")
tBoom[2] = (tonumber(tBoom[2]) or 0)
tBoom[3] = ((tonumber(tBoom[3]) or 0) ~= 0) and true or false
tBoom[4] = ((tonumber(tBoom[4]) or 0) ~= 0) and true or false
return tBoom
Expand All @@ -2463,7 +2463,7 @@ local function AttachTimer(oLocation,tKeys,defTable,anyMessage)
if(not defTable) then return StatusLog(nil,"AttachTimer: Missing table definition") end
local Place, Key = NavigateTable(oLocation,tKeys)
if(not (IsExistent(Place) and IsExistent(Key))) then return StatusLog(nil,"AttachTimer: Navigation failed") end
if(not IsExistent(Place[Key])) then return StatusLog(nil,"AttachTimer: Place not found") end
if(not IsExistent(Place[Key])) then return StatusLog(nil,"AttachTimer: Data not found") end
if(IsExistent(Place[Key].Kept)) then Place[Key].Kept = Place[Key].Kept - 1 end -- Get the proper line count
local tTimer = defTable.Timer
if(not IsExistent(tTimer)) then return StatusLog(Place[Key],"AttachTimer: Missing timer settings") end
Expand All @@ -2472,6 +2472,7 @@ local function AttachTimer(oLocation,tKeys,defTable,anyMessage)
if(not (IsExistent(sModeTM) and IsExistent(nLifeTM))) then return StatusLog(Place[Key],"AttachTimer: Missing timer mode/life") end
if(nLifeTM <= 0) then return StatusLog(Place[Key],"AttachTimer: Timer life ignored") end
local sModeDB = GetOpVar("MODE_DATABASE")
LogInstance("AttachTimer: Called by <"..anyMessage..">")
if(sModeDB == "SQL") then
LogInstance("AttachTimer: Place["..tostring(Key).."] Marked !")
local bKillRC = tTimer[3]
Expand Down Expand Up @@ -2674,32 +2675,32 @@ function CacheQueryPanel()
if(not IsExistent(libCache[namTable])) then
return StatusLog(nil,"CacheQueryPanel: Cache not allocated for "..namTable)
end
local Cache = libCache[namTable]
local Panel = libCache[keyPanel]
local caInd = {namTable,sModel}
if(IsExistent(Panel) and IsExistent(Panel.Kept)) then
local stPanel = libCache[keyPanel]
local caInd = {keyPanel}
if(IsExistent(stPanel) and IsExistent(stPanel.Kept)) then
LogInstance("CacheQueryPanel: From Pool")
if(stAddition.Kept > 0) then
if(stPanel.Kept > 0) then
return RestartTimer(libCache,caInd,defTable,"CacheQueryPanel")
end
return nil
else
libCache[keyPanel] = {}
Panel = libCache[keyPanel]
stPanel = libCache[keyPanel]
local sModeDB = GetOpVar("MODE_DATABASE")
if(sModeDB == "SQL") then
local Q = SQLBuildSelect(defTable,{1,2,3},{{4,1}},{2,3})
if(not IsExistent(Q)) then return StatusLog(nil,"CacheQueryPanel: Build error: "..SQLBuildError()) end
local qData = sql.Query(Q)
if(not qData and IsBool(qData)) then return StatusLog(nil,"CacheQueryPanel: SQL exec error "..sql.LastError()) end
if(not (qData and qData[1])) then return StatusLog(nil,"CacheQueryPanel: No data found >"..Q.."<") end
Panel.Kept = 1
while(qData[Panel.Kept]) do
Panel[Panel.Kept] = qData[Panel.Kept]
Panel.Kept = Panel.Kept + 1
stPanel.Kept = 1
while(qData[stPanel.Kept]) do
stPanel[stPanel.Kept] = qData[stPanel.Kept]
stPanel.Kept = stPanel.Kept + 1
end
return AttachTimer(libCache,caInd,defTable,"CacheQueryPanel")
elseif(sModeDB == "LUA") then
local Cache = libCache[namTable]
local tData = {}
local iNdex = 0
for sModel, tRecord in pairs(Cache) do
Expand All @@ -2709,10 +2710,10 @@ function CacheQueryPanel()
if(not tSorted) then return StatusLog(nil,"CacheQueryPanel: Cannot sort cache data") end
iNdex = 1
while(tSorted[iNdex]) do
Panel[iNdex] = tData[tSorted[iNdex].Key]
stPanel[iNdex] = tData[tSorted[iNdex].Key]
iNdex = iNdex + 1
end
return Panel
return stPanel
else
return StatusLog(nil,"CacheQueryPanel: Wrong database mode >"..sModeDB.."<")
end
Expand All @@ -2735,13 +2736,13 @@ function CacheQueryProperty(sType)
if(IsString(sType) and (sType ~= "")) then -- Get names per type
local sType = MatchType(defTable,sType,1,false,"",true,true)
local keyName = GetOpVar("HASH_PROPERTY_NAMES")
local Names = Cache[keyName]
local arNames = Cache[keyName]
local caInd = {namTable,keyName,sType}
if(not IsExistent(Names)) then
if(not IsExistent(arNames)) then
Cache[keyName] = {}
Names = Cache[keyName]
arNames = Cache[keyName]
end
local stName = Names[sType]
local stName = arNames[sType]
if(IsExistent(stName) and IsExistent(stName.Kept)) then
LogInstance("CacheQueryProperty["..sType.."]: From Pool")
if(stName.Kept > 0) then
Expand All @@ -2750,8 +2751,8 @@ function CacheQueryProperty(sType)
return nil
else
if(sModeDB == "SQL") then
Names[sType] = {}
stName = Names[sType]
arNames[sType] = {}
stName = arNames[sType]
stName.Kept = 0
local Q = SQLBuildSelect(defTable,{3},{{1,sType}},{2})
if(not IsExistent(Q)) then return StatusLog(nil,"CacheQueryProperty["..sType.."]: Build error: "..SQLBuildError()) end
Expand All @@ -2773,6 +2774,7 @@ function CacheQueryProperty(sType)
else
local keyType = GetOpVar("HASH_PROPERTY_TYPES")
local stType = Cache[keyType]
local caInd = {namTable,keyType}
if(IsExistent(stType) and IsExistent(stType.Kept)) then -- Get All type names
LogInstance("CacheQueryProperty: From Pool")
if(stType.Kept > 0) then
Expand Down

0 comments on commit 3717a06

Please sign in to comment.