Skip to content

Commit

Permalink
Changed: Variable name convention from subtype to category
Browse files Browse the repository at this point in the history
Changed: Unrelated category to "other"
Added: Category for: SligWolf's Minis, SProps, XQM Coaster, XQM Ball Rails
  • Loading branch information
dvdvideo1234 committed Jun 27, 2016
1 parent 63b5999 commit 5681872
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
25 changes: 18 additions & 7 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local asmlib = trackasmlib

------ CONFIGURE ASMLIB ------
asmlib.InitAssembly("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.260")
asmlib.SetOpVar("TOOL_VERSION","5.261")
asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
Expand Down Expand Up @@ -459,7 +459,10 @@ else
asmlib.InsertRecord({"models/sligwolf/rerailer/rerailer_2.mdl", "#", "Middle Double", 2, "-1882.106, 0, 3.031", "-2367.072, 0, -5.412", "0,-180,0"})
asmlib.InsertRecord({"models/sligwolf/rerailer/rerailer_1.mdl", "#", "Short Double", 1, "-221.409, 0, 3.031", "219.412, 0, -5.411", ""})
asmlib.InsertRecord({"models/sligwolf/rerailer/rerailer_1.mdl", "#", "Short Double", 2, "-1103.05, 0, 0.009", "-1543.871, 0, -5.411", "0,-180,0"})
asmlib.DefaultType("SligWolf's Minis")
asmlib.DefaultType("SligWolf's Minis",function(m)
local r = stringGsub(stringGsub(m,"models/minitrains/",""),"_","/")
local s = stringFind(r,"/") or stringFind(r,"%."); r = (s and stringSub(r,1,s-1) or "other")
if(r == "sw") then r = "buffer" end; return asmlib.ModelToName(r,true); end)
asmlib.InsertRecord({"models/minitrains/straight_16.mdl", "#", "#", 1, "", "0, -8.507, 1", ""})
asmlib.InsertRecord({"models/minitrains/straight_16.mdl", "#", "#", 2, "", "-16, -8.507, 1", "0,-180,0"})
asmlib.InsertRecord({"models/minitrains/straight_32.mdl", "#", "#", 1, "", "0, -8.507, 1", ""})
Expand Down Expand Up @@ -642,7 +645,10 @@ else
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_switch2.mdl", "#", "Switch Left [X]", 1, "", " 829.880005, -0.001465, 11.218994", ""})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_switch2.mdl", "#", "Switch Left [X]", 2, "", "-370.037262, -0.000456, 11.218994", "0,-180,0"})
asmlib.InsertRecord({"models/props_phx/trains/tracks/track_switch2.mdl", "#", "Switch Left [X]", 3, "", "-158.311356,-338.111572, 11.218994", "0,-135,0"})
asmlib.DefaultType("SProps")
asmlib.DefaultType("SProps",function(m)
local r = stringGsub(stringGsub(m,"models/sprops/trans/train/",""),"_","/")
if(stringFind(r,"track/")) then r = stringGsub(r,"track/","") end; local s = stringSub(r,1,1); if(s == "s") then r = "straight" end;
if(s == "t") then r = "turn" end; if(s == "h") then r = "ramp" end; return asmlib.ModelToName(r,true) end)
asmlib.SettingsModelToName("SET",nil,{"track_s0","straight_"},{"","x"})
asmlib.InsertRecord({"models/sprops/trans/train/track_s01.mdl", "#", "#", 1, "", " 0,0,7.624", ""})
asmlib.InsertRecord({"models/sprops/trans/train/track_s01.mdl", "#", "#", 2, "", "-162,0,7.624", "0,180,0"})
Expand All @@ -669,7 +675,9 @@ else
asmlib.InsertRecord({"models/sprops/trans/train/track_t90_01.mdl", "#", "#", 1, "", "0,0,7.624", ""})
asmlib.InsertRecord({"models/sprops/trans/train/track_t90_01.mdl", "#", "#", 2, "", "-825,825,7.624", "0,90,0"})
asmlib.InsertRecord({"models/sprops/trans/train/rerailer.mdl", "#", "#", 1, "-1088.178,0,19.886", "-1280.383,0,7.618", "0,180,0"})
asmlib.DefaultType("XQM Coaster")
asmlib.DefaultType("XQM Coaster",function(m)
local r = stringGsub(stringGsub(m,"models/xqm/coastertrack/",""),"_","/"); local s = stringFind(r,"/");
r = (s and stringSub(r,1,s-1) or "other"); return asmlib.ModelToName(r,true); end)
asmlib.InsertRecord({"models/xqm/coastertrack/slope_225_1.mdl", "#", "#", 1, "", "75.790,-0.013,-2.414", ""})
asmlib.InsertRecord({"models/xqm/coastertrack/slope_225_1.mdl", "#", "#", 2, "", "-70.806,-0.003.923,26.580", "@-22.5,180,0"})
asmlib.InsertRecord({"models/xqm/coastertrack/slope_225_2.mdl", "#", "#", 1, "", "149.8, -0.013, -9.62", ""})
Expand Down Expand Up @@ -938,7 +946,10 @@ else
asmlib.InsertRecord({"models/props_phx/misc/iron_beam3.mdl", "#", "#", 2, "", "-94.079, 0.002, 5.002", "0,180,0"})
asmlib.InsertRecord({"models/props_phx/misc/iron_beam4.mdl", "#", "#", 1, "", " 175.507, 0.001, 5.002", "0, 0,0"})
asmlib.InsertRecord({"models/props_phx/misc/iron_beam4.mdl", "#", "#", 2, "", "-201.413, 0.001, 5.002", "0,180,0"})
asmlib.DefaultType("XQM Ball Rails")
asmlib.DefaultType("XQM Ball Rails",function(m)
local r = stringGsub(stringGsub(m,"models/xqm/rails/",""),"_","/")
local s = stringFind(r,"/"); r = (s and stringSub(r,1,s-1) or "other")
return asmlib.ModelToName(r,true); end)
asmlib.InsertRecord({"models/xqm/rails/tunnel_1.mdl", "#", "#", 1, "", "6, 0, -2.25", ""})
asmlib.InsertRecord({"models/xqm/rails/tunnel_1.mdl", "#", "#", 2, "", "-6, 0, -2.25", "0,180,0"})
asmlib.InsertRecord({"models/xqm/rails/tunnel_2.mdl", "#", "#", 1, "", "6, 0, -2.25", ""})
Expand Down Expand Up @@ -1162,7 +1173,7 @@ else
asmlib.InsertRecord({"models/props_wasteland/bridge_low_res.mdl", "#", "#", 2, "", "-576, 219.145, 992.765", "0, 180,0"})
asmlib.DefaultType("StephenTechno's Buildings",function(m)
local r = stringGsub(stringGsub(m,"models/buildingspack/",""),"_","/")
local p = stringFind(r,"/"); r = (p and stringSub(r,1,p-1) or "")
local s = stringFind(r,"/"); r = (s and stringSub(r,1,s-1) or "other")
if(stringFind(r,"emptylots")) then r = "empty_lots" end
if(stringFind(r,"roadsdw" )) then r = stringGsub(r,"roadsdw","double_") end
if(stringFind(r,"roadsw" )) then r = stringGsub(r,"roadsw" ,"single_") end
Expand Down Expand Up @@ -1427,7 +1438,7 @@ else
asmlib.InsertRecord({"models/props/m_gauge/track/m_gauge_switch_righthand.mdl", "#", "#", 3, "", "-256,10,0.016", "0,180,0"})
asmlib.DefaultType("Mr.Train's G-Gauge",function(m)
local r = stringGsub(stringGsub(m,"models/props/g_gauge/track/g_gauge_track_",""),"_","/")
local p = stringFind(r,"/"); r = (p and stringSub(r,1,p-1) or "other")
local s = stringFind(r,"/"); r = (s and stringSub(r,1,s-1) or "other")
if(r == "s") then r = "curve"..r end; return asmlib.ModelToName(r,true) end)
asmlib.SettingsModelToName("SET",nil,{"g_gauge_track_",""},nil)
asmlib.InsertRecord({"models/props/g_gauge/track/g_gauge_track_straight_32.mdl" , "#", "#", 1, "", " 16,0,1.516", ""})
Expand Down
10 changes: 5 additions & 5 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function InitAssembly(sName,sPurpose)
SetOpVar("ARRAY_DECODEPOA",{0,0,0,1,1,1,false})
SetOpVar("TABLE_FREQUENT_MODELS",{})
SetOpVar("TABLE_BORDERS",{})
SetOpVar("TABLE_SUBTYPES",{})
SetOpVar("TABLE_CATEGORIES",{})
SetOpVar("FILE_MODEL","%.mdl")
SetOpVar("OOP_DEFAULTKEY","(!@<#_$|%^|&>*)DEFKEY(*>&|^%|$_#<@!)")
SetOpVar("CVAR_LIMITNAME","asm"..GetOpVar("NAME_INIT").."s")
Expand Down Expand Up @@ -1428,13 +1428,13 @@ function SettingsModelToName(sMode, gCut, gSub, gApp)
end
end

function DefaultType(anyType,fooSubtype)
function DefaultType(anyType,fooCateg)
if(not IsExistent(anyType)) then
return (GetOpVar("DEFAULT_TYPE") or "") end
SettingsModelToName("CLR")
if(type(fooSubtype) == "function") then
local Sub = GetOpVar("TABLE_SUBTYPES")
Sub[anyType] = fooSubtype
if(type(fooCateg) == "function") then
local Categ = GetOpVar("TABLE_CATEGORIES")
Categ[anyType] = fooCateg
end
SetOpVar("DEFAULT_TYPE",tostring(anyType))
end
Expand Down
24 changes: 12 additions & 12 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -954,13 +954,13 @@ function TOOL.BuildCPanel(CPanel)
local Panel = asmlib.CacheQueryPanel()
if(not Panel) then return asmlib.StatusPrint(nil,"TOOL:BuildCPanel(cPanel): Panel population empty") end
local defTable = asmlib.GetOpVar("DEFTABLE_PIECES")
local subTypes = asmlib.GetOpVar("TABLE_SUBTYPES")
local catTypes = asmlib.GetOpVar("TABLE_CATEGORIES")
local pTree = vguiCreate("DTree")
pTree:SetPos(2, CurY)
pTree:SetSize(2, 400)
pTree:SetTooltip(languageGetPhrase("tool."..gsToolNameL..".tree"))
pTree:SetIndentSize(0)
local iCnt, pFolders, pSubtype, pNode = 1, {}, {}
local iCnt, pFolders, pCategory, pNode = 1, {}, {}
while(Panel[iCnt]) do
local Rec = Panel[iCnt]
local Mod = Rec[defTable[1][1]]
Expand All @@ -979,22 +979,22 @@ function TOOL.BuildCPanel(CPanel)
end -- Reset the primary tree node pointer
if(pFolders[Typ]) then pItem = pFolders[Typ] else pItem = pTree end
-- Register the subtype if definition functional is given
if(subTypes[Typ]) then -- There is a subtype definition
if(not pSubtype[Typ]) then pSubtype[Typ] = {} end
local nmSub = subTypes[Typ](Mod)
local pnSub = pSubtype[Typ][nmSub]
if(not pnSub) then
if(not asmlib.IsEmptyString(nmSub)) then -- No subtype folder made already
pItem = pItem:AddNode(nmSub) -- The item pointer will refer to the new directory
pItem:SetName(nmSub)
if(catTypes[Typ]) then -- There is a subtype definition
if(not pCategory[Typ]) then pCategory[Typ] = {} end
local nmCat = catTypes[Typ](Mod)
local pnCat = pCategory[Typ][nmCat]
if(not pnCat) then
if(not asmlib.IsEmptyString(nmCat)) then -- No subtype folder made already
pItem = pItem:AddNode(nmCat) -- The item pointer will refer to the new directory
pItem:SetName(nmCat)
pItem.Icon:SetImage("icon16/folder.png")
pItem.InternalDoClick = function() end
pItem.DoClick = function() return false end
pItem.Label.UpdateColours = function(pSelf)
return pSelf:SetTextStyleColor(conPalette:Select("tx")) end
pSubtype[Typ][nmSub] = pItem
pCategory[Typ][nmCat] = pItem
end
else pItem = pnSub end
else pItem = pnCat end
end
-- Register the node asociated with the track piece
pNode = pItem:AddNode(Nam)
Expand Down

0 comments on commit 5681872

Please sign in to comment.