mirror of
https://github.com/dvdvideo1234/TrackAssemblyTool.git
synced 2025-03-04 03:13:32 -05:00
Fixed: Steventechno building having misaligned points
Fixed: Pre-commit hook handling UNIX format correctly Fixed: Sources in UNIX format Fixed: Correct number of kept records on timer attaching crash Added: Factory reset on the database and variables Renamed: GetPropBodyGrp to "Group" Divided: Error logs for InitAssembly() Updated: Track point exporter E2
This commit is contained in:
parent
c735b60316
commit
21e7ea6984
@ -9,14 +9,15 @@ interval(20)
|
||||
|
||||
function number isOuter(Lft, Rgh, Percent, MaxRange)
|
||||
{
|
||||
# print("isOuter "+Lft+" "+Rgh)
|
||||
Rez = 0
|
||||
T = abs(Lft-Rgh)
|
||||
Pd = ((Percent / 100) * MaxRange)
|
||||
Pu = MaxRange - Pd
|
||||
if(T > Pd){ return 1 }
|
||||
if(Lft > Pu){ return 1 }
|
||||
if(Rgh > Pu){ return 1 }
|
||||
return 0
|
||||
if(T > Pd){ Rez = 1 }
|
||||
if(Lft > Pu){ Rez = 1 }
|
||||
if(Rgh > Pu){ Rez = 1 }
|
||||
# print("isOuter "+Rez+" ["+round(T,2)+">"+round(Pd)+"] "+round(Lft,2)+">"+round(Pu)+" "+round(Rgh,2)+">"+round(Pu,2))
|
||||
return Rez
|
||||
}
|
||||
|
||||
function array clampTrace(Pos:vector,Width,Fwd:vector,Rgh:vector,Len,Holo1,Holo2)
|
||||
@ -45,14 +46,14 @@ if(first() || dupefinished())
|
||||
OutagePercentTolerance = 5
|
||||
|
||||
# Set this delta forward to slow fasten the process
|
||||
DF = 0.3
|
||||
DF = 0.5
|
||||
|
||||
# Track piece width
|
||||
TrackPieceW = 120
|
||||
TrackPieceH = 50
|
||||
TrackPieceW = 1000
|
||||
TrackPieceH = 500
|
||||
|
||||
#Generate the origin with an inset
|
||||
TrackOriginInset = 0.0001
|
||||
TrackOriginInset = 0.001
|
||||
|
||||
# Tolerance if the error gained when generating an actibe point
|
||||
TrackOriginTolerance = 10^-12
|
||||
@ -174,18 +175,32 @@ if(StraightUp != 0 && Interval == 0)
|
||||
{
|
||||
PosL = Cen - TrackPieceW * R
|
||||
PosR = Cen + TrackPieceW * R
|
||||
# holoPos(2,PosL), holoPos(3,PosR)
|
||||
VRL = clampTrace(Cen,TrackPieceW,F,R,TrackRangerMaxW,0,0)
|
||||
VR = VRL[1,number] , VL = VRL[2,number], VDM = VRL[3,number]
|
||||
# DL = rangerOffset(TrackRangerMaxW,PosL, R):distance()
|
||||
# DR = rangerOffset(TrackRangerMaxW,PosR, -R):distance()
|
||||
VDP = clampTrace(Cen + Prg - TrackOriginInset * F,TrackPieceH,F,U,TrackRangerMaxH,5,6)
|
||||
PU = VDP[1,number], PD = VDP[2,number], PDW = VDP[4,number]
|
||||
|
||||
|
||||
VDC = clampTrace(Cen,TrackPieceH,F,U,TrackRangerMaxH,7,8)
|
||||
|
||||
# print(VDC[1,number],PU, ARC[1,number])
|
||||
|
||||
if((VDC[1,number] < ARC[1,number]) && (VDC[2,number] < ARC[2,number]))
|
||||
{
|
||||
ARC = VDC
|
||||
}
|
||||
|
||||
#[
|
||||
PosU = Cen + TrackPieceH * U + Prg - TrackOriginInset * F
|
||||
PosD = Cen - TrackPieceH * U + Prg - TrackOriginInset * F
|
||||
|
||||
holoPos(5,PosU), holoPos(6,PosD)
|
||||
DU = rangerOffset(TrackRangerMaxH,PosU, -U):distance()
|
||||
DD = rangerOffset(TrackRangerMaxH,PosD, U):distance()
|
||||
]#
|
||||
|
||||
if(isOuter(VL,VR,OutagePercentTolerance,TrackRangerMaxW))
|
||||
{
|
||||
Time = 100
|
||||
@ -198,21 +213,28 @@ if(StraightUp != 0 && Interval == 0)
|
||||
DF = DF * 1.7
|
||||
}
|
||||
DF = 0.5 * DF
|
||||
# print(_HUD_PRINTTALK,"Switch!")
|
||||
}else{
|
||||
holoPos(1,Cen) holoColor(1,vec(0,255,255))
|
||||
PRL = clampTrace(Cen - TrackOriginInset * F ,TrackPieceW,F,R,TrackRangerMaxW,3,4)
|
||||
# BEGIN Defintition formulas
|
||||
|
||||
# BEGIN Definition formulas
|
||||
# Use this 2 beam tracks outside
|
||||
# PRL = clampTrace(Cen - TrackOriginInset * F ,TrackPieceW,F,R,TrackRangerMaxW,3,4)
|
||||
# TrackExtraDepth = ((ARC[1,number] - PU) / 2) + PU
|
||||
# TrackExtraSide = PRL[3,number]
|
||||
|
||||
# Use this for 2 beam tracks
|
||||
|
||||
# Use this for 2 beam tracks inside
|
||||
PRL = clampTrace(Cen - TrackOriginInset * F ,0,F,R,TrackRangerMaxW,3,4)
|
||||
TrackExtraDepth = ((ARC[1,number] - PU) / 2) + PU
|
||||
TrackExtraSide = PRL[3,number]
|
||||
|
||||
#Use this for monorail
|
||||
#Use ths for monorail
|
||||
# PRL = clampTrace(Cen - TrackOriginInset * F ,TrackPieceW,F,R,TrackRangerMaxW,3,4)
|
||||
# TrackExtraDepth = ARC[1,number] + ARC[4,number]
|
||||
# TrackExtraSide = PRL[3,number]
|
||||
|
||||
# END Definition formulas
|
||||
# END Defintition formulas
|
||||
|
||||
ORG = Cen + TrackPieceH * U
|
||||
ORG = ORG - TrackExtraSide * R
|
||||
@ -221,7 +243,8 @@ if(StraightUp != 0 && Interval == 0)
|
||||
A = round(Base:toLocal((F):toAngle(U)))
|
||||
|
||||
S = toString(abs(DF)-abs(TrackOriginTolerance)):sub(1,1)
|
||||
|
||||
|
||||
# print(S+" "+DF)
|
||||
if(S == "-")
|
||||
{
|
||||
print("Origin: "+toString(O)+" Angle: "+toString(A)+" ["+toString(DF)+"]")
|
||||
|
@ -46,8 +46,8 @@ end
|
||||
if(sEnd == "DOS") then sEnd = "\r\n" end
|
||||
if(sEnd == "UNX") then sEnd = "\n" end
|
||||
io.write("------------------ OPEN FILE ------------------\n")
|
||||
local fOut = io.open(sOut,"w+")
|
||||
local fInp = io.open(sInp,"r+")
|
||||
local fOut = io.open(sOut,"wb")
|
||||
local fInp = io.open(sInp,"rb")
|
||||
if(not fOut) then
|
||||
io.write("File "..sOut.." not found\n")
|
||||
return false
|
||||
@ -92,7 +92,7 @@ while(sI) do
|
||||
end
|
||||
end
|
||||
end; nL = nL + 1
|
||||
fOut:write(sI..sEnd)
|
||||
fOut:write(sI,sEnd)
|
||||
sI = fInp:read()
|
||||
end
|
||||
io.write("------------------ FINISH ------------------\n")
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,324 +1,324 @@
|
||||
----- Localizing the asmlib module
|
||||
local asmlib = trackasmlib
|
||||
----- Localizing needed functions
|
||||
local Vector = Vector
|
||||
local Angle = Angle
|
||||
local Color = Color
|
||||
local tonumber = tonumber
|
||||
local tostring = tostring
|
||||
local stringSub = string and string.sub
|
||||
local stringUpper = string and string.upper
|
||||
local stringLen = string and string.len
|
||||
|
||||
----- Get extension enabled flag
|
||||
local enFlag = ((tonumber(asmlib.GetCoVar("enwiremod","INT")) or 0) ~= 0) and true or false
|
||||
local anyTrue = 1
|
||||
local anyFalse = 0
|
||||
--------- Pieces ----------
|
||||
|
||||
__e2setcost(50)
|
||||
e2function string entity:trackasmlibGenActivePointINS(entity ucsEnt, string sType, string sName, number nPoint, string sP)
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
if(not (ucsEnt and ucsEnt:IsValid())) then return "" end
|
||||
local C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
local ucsPos = ucsEnt:GetPos()
|
||||
local sO = tostring(ucsPos[C1])..","..tostring(ucsPos[C2])..","..tostring(ucsPos[C3])
|
||||
C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
local ucsAng = ucsEnt:GetAngles()
|
||||
local sA = tostring(ucsAng[C1])..", "..tostring(ucsAng[C2])..", "..tostring(ucsAng[C3])
|
||||
return "asmlib.InsertRecord({\""..this:GetModel().."\", \""..sType..
|
||||
"\", \""..sName.."\", "..tostring(nPoint or 0)..", \""..sP..
|
||||
"\", \""..sO.."\", \""..sA.."\"})"
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function string entity:trackasmlibGenActivePointDSV(entity ucsEnt, string sType, string sName, number nPoint, string sP, string sDelim)
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
if(not (ucsEnt and ucsEnt:IsValid())) then return "" end
|
||||
local sDelim = stringSub(sDelim,1,1)
|
||||
if(not (stringLen(sDelim) > 0)) then return "" end
|
||||
local C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
local ucsPos = ucsEnt:GetPos()
|
||||
local sO = tostring(ucsPos[C1])..","..tostring(ucsPos[C2])..","..tostring(ucsPos[C3])
|
||||
C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
local ucsAng = ucsEnt:GetAngles()
|
||||
local sA = tostring(ucsAng[C1])..","..tostring(ucsAng[C2])..","..tostring(ucsAng[C3])
|
||||
return "TRACKASSEMBLY_PIECES"..sDelim.."\""..this:GetModel().."\""..sDelim.."\""..
|
||||
sType.."\""..sDelim.."\""..sName.."\""..sDelim..tostring(nPoint or 0)..
|
||||
sDelim.."\""..sP.."\""..sDelim.."\""..sO.."\""..sDelim.."\""..sA.."\""
|
||||
end
|
||||
|
||||
__e2setcost(100)
|
||||
e2function array entity:trackasmlibSnapEntity(vector trHitPos , string hdModel , number hdPointID,
|
||||
number nActRadius, number enFlatten, number enIgnTyp ,
|
||||
vector ucsOffPos , vector ucsOffAng)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local stSpawn = asmlib.GetEntitySpawn(this,trHitPos,hdModel,hdPointID,
|
||||
nActRadius,enFlatten,enIgnTyp,
|
||||
ucsPos[1],ucsPos[2],ucsPos[3],
|
||||
ucsAng[1],ucsAng[2],ucsAng[3])
|
||||
if(not stSpawn) then return {} end
|
||||
return {stSpawn.SPos, stSpawn.SAng}
|
||||
end
|
||||
|
||||
__e2setcost(80)
|
||||
e2function array trackasmlibSnapNormal(vector ucsPos , angle ucsAng , string hdModel,
|
||||
number hdPointID, vector ucsOffPos, vector ucsOffAng)
|
||||
if(not enFlag) then return {} end
|
||||
local stSpawn = asmlib.GetNormalSpawn(ucsPos,ucsAng,hdModel,hdPointID,
|
||||
ucsOffPos[1],ucsOffPos[2],ucsOffPos[3],
|
||||
ucsOffAng[1],ucsOffAng[2],ucsOffAng[3])
|
||||
if(not stSpawn) then return {} end
|
||||
return {stSpawn.SPos, stSpawn.SAng}
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibIsPiece(string sModel)
|
||||
if(not enFlag) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibIsPiece()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(120)
|
||||
e2function array trackasmlibGetOffset(string sModel, number nOffset, string sPOA)
|
||||
if(not enFlag) then return {} end
|
||||
local stPOA = asmlib.LocatePOA(asmlib.CacheQueryPiece(sModel),nOffset)
|
||||
if(not stPOA) then return {} end
|
||||
local sPOA = stringSub(stringUpper(tostring(sPOA)),1,1)
|
||||
local arResult = {}
|
||||
local C1, C2, C3, C4
|
||||
if (sPOA == "P") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "O") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "A") then C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
else return arResult end
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[2] = stPOA[sPOA][C2]
|
||||
arResult[3] = stPOA[sPOA][C3]
|
||||
C1, C2, C3, C4 = asmlib.GetIndexes("S")
|
||||
arResult[4] = stPOA[sPOA][C1]
|
||||
arResult[5] = stPOA[sPOA][C2]
|
||||
arResult[6] = stPOA[sPOA][C3]
|
||||
arResult[7] = stPOA[sPOA][C4] and 1 or 0
|
||||
return arResult
|
||||
end
|
||||
|
||||
__e2setcost(120)
|
||||
e2function array entity:trackasmlibGetOffset(number nOffset, string sPOA)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local stPOA = asmlib.LocatePOA(asmlib.CacheQueryPiece(this:GetModel()),nOffset)
|
||||
if(not stPOA) then return {} end
|
||||
local sPOA = stringSub(stringUpper(tostring(sPOA)),1,1)
|
||||
local arResult = {}
|
||||
local C1, C2, C3, C4
|
||||
if (sPOA == "P") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "O") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "A") then C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
else return arResult end
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[2] = stPOA[sPOA][C2]
|
||||
arResult[3] = stPOA[sPOA][C3]
|
||||
C1, C2, C3, C4 = asmlib.GetIndexes("S")
|
||||
arResult[4] = stPOA[sPOA][C1]
|
||||
arResult[5] = stPOA[sPOA][C2]
|
||||
arResult[6] = stPOA[sPOA][C3]
|
||||
arResult[7] = stPOA[sPOA][C4] and 1 or 0
|
||||
return arResult
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string trackasmlibGetType(string sModel)
|
||||
if(not enFlag) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Type) then return stRecord.Type else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string entity:trackasmlibGetType()
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Type) then return stRecord.Type else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string trackasmlibGetName(string sModel)
|
||||
if(not enFlag) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Name) then return stRecord.Name else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string entity:trackasmlibGetName()
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Name) then return stRecord.Name else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibGetPointsCount(string sModel)
|
||||
if(not enFlag) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibGetPointsCount()
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
---------- Additions ------------
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibHasAdditions(string sModel)
|
||||
if(not enFlag) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibHasAdditions()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function number trackasmlibGetAdditionsCount(string sModel)
|
||||
if(not enFlag) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function number entity:trackasmlibGetAdditionsCount()
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(60)
|
||||
e2function array trackasmlibGetAdditionsLine(string sModel, number nLine)
|
||||
if(not enFlag) then return {} end
|
||||
local defAddit = asmlib.GetOpVar("DEFTABLE_ADDITIONS")
|
||||
if(not defAddit) then
|
||||
return asmlib.StatusLog({},"entity:trackasmlibGetAdditionLine(number): No table definition")
|
||||
end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(not stRecord) then return {} end
|
||||
if(not stRecord[nLine]) then return {} end
|
||||
stRecord = stRecord[nLine] -- Ordered by ID. Get the line per model
|
||||
local cntField = 2 -- The model is missed by the main SELECT
|
||||
local arAdditionsLine = {}
|
||||
while(defAddit[cntField]) do
|
||||
arAdditionsLine[cntField-1] = stRecord[defAddit[cntField][1]]
|
||||
cntField = cntField + 1
|
||||
end
|
||||
return arAdditionsLine
|
||||
end
|
||||
|
||||
__e2setcost(60)
|
||||
e2function array entity:trackasmlibGetAdditionsLine(number nLine)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local defAddit = asmlib.GetOpVar("DEFTABLE_ADDITIONS")
|
||||
if(not defAddit) then
|
||||
return asmlib.StatusLog({},"entity:trackasmlibGetAdditionLine(number): No table definition")
|
||||
end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(not stRecord) then return {} end
|
||||
if(not stRecord[nLine]) then return {} end
|
||||
stRecord = stRecord[nLine] -- Ordered by ID. Get the line per model
|
||||
local cntField = 2 -- The model is missed by the main SELECT
|
||||
local arAdditionsLine = {}
|
||||
while(defAddit[cntField]) do
|
||||
arAdditionsLine[cntField-1] = stRecord[defAddit[cntField][1]]
|
||||
cntField = cntField + 1
|
||||
end
|
||||
return arAdditionsLine
|
||||
end
|
||||
|
||||
------------ PhysProperties ------------
|
||||
|
||||
__e2setcost(15)
|
||||
e2function array trackasmlibGetProperty(string sType)
|
||||
if(not enFlag) then return {} end
|
||||
local stRecord = asmlib.CacheQueryProperty(sType)
|
||||
if(not stRecord) then return {} end
|
||||
return stRecord
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function array trackasmlibGetProperty()
|
||||
if(not enFlag) then return {} end
|
||||
local stRecord = asmlib.CacheQueryProperty()
|
||||
if(not stRecord) then return {} end
|
||||
return stRecord
|
||||
end
|
||||
|
||||
----------- Piece creator --------------
|
||||
|
||||
__e2setcost(50)
|
||||
e2function entity trackasmlibMakePiece(string sModel, vector vPos, angle aAng, number nMass, string sBgpID, number nR, number nG, number nB, number nA)
|
||||
if(not enFlag) then return nil end
|
||||
return asmlib.MakePiece(sModel,Vector(vPos[1],vPos[2],vPos[3]),
|
||||
Angle (aAng[1],aAng[2],aAng[3]),
|
||||
nMass or 50000,sBgpID or "",
|
||||
Color(nR or 255, nG or 255, nB or 255, nA or 255))
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function entity entity:trackasmlibMakePiece(vector vPos, angle aAng)
|
||||
if(not (this and this:IsValid() and enFlag)) then return nil end
|
||||
local phthis = this:GetPhysicsObject()
|
||||
if(not (phthis and phthis:IsValid())) then return nil end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return nil end
|
||||
local sBgpID = asmlib.GetPropBodyGrp(this)..
|
||||
asmlib.GetOpVar("OPSYM_DIRECTORY")..
|
||||
asmlib.GetPropSkin(this)
|
||||
return asmlib.MakePiece(this:GetModel(),
|
||||
Vector(vPos[1],vPos[2],vPos[3]),
|
||||
Angle (aAng[1],aAng[2],aAng[3]),
|
||||
phthis:GetMass(),sBgpID,this:GetColor())
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function entity entity:trackasmlibApplyPhysicalAnchor(entity eBase, number nWe, number nNc)
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
if(not (eBase and eBase:IsValid())) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return anyFalse end
|
||||
return asmlib.ApplyPhysicalAnchor(this,eBase,nWe,nNc) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function entity entity:trackasmlibApplyPhysicalSettings(number nPi, number nFr, number nGr, string sPh)
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return anyFalse end
|
||||
return asmlib.ApplyPhysicalSettings(this,nPi,nFr,nGr,sPh) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(35)
|
||||
e2function number entity:trackasmlibAttachAdditions()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(not stRecord) then return 0 end
|
||||
return asmlib.AttachAdditions(this) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(20)
|
||||
e2function number entity:trackasmlibAttachBodyGroups(string sBgpID)
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return 0 end
|
||||
return asmlib.AttachBodyGroups(this, sBgpID) and anyTrue or anyFalse
|
||||
----- Localizing the asmlib module
|
||||
local asmlib = trackasmlib
|
||||
----- Localizing needed functions
|
||||
local Vector = Vector
|
||||
local Angle = Angle
|
||||
local Color = Color
|
||||
local tonumber = tonumber
|
||||
local tostring = tostring
|
||||
local stringSub = string and string.sub
|
||||
local stringUpper = string and string.upper
|
||||
local stringLen = string and string.len
|
||||
|
||||
----- Get extension enabled flag
|
||||
local enFlag = ((tonumber(asmlib.GetCoVar("enwiremod","INT")) or 0) ~= 0) and true or false
|
||||
local anyTrue = 1
|
||||
local anyFalse = 0
|
||||
--------- Pieces ----------
|
||||
|
||||
__e2setcost(50)
|
||||
e2function string entity:trackasmlibGenActivePointINS(entity ucsEnt, string sType, string sName, number nPoint, string sP)
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
if(not (ucsEnt and ucsEnt:IsValid())) then return "" end
|
||||
local C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
local ucsPos = ucsEnt:GetPos()
|
||||
local sO = tostring(ucsPos[C1])..","..tostring(ucsPos[C2])..","..tostring(ucsPos[C3])
|
||||
C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
local ucsAng = ucsEnt:GetAngles()
|
||||
local sA = tostring(ucsAng[C1])..", "..tostring(ucsAng[C2])..", "..tostring(ucsAng[C3])
|
||||
return "asmlib.InsertRecord({\""..this:GetModel().."\", \""..sType..
|
||||
"\", \""..sName.."\", "..tostring(nPoint or 0)..", \""..sP..
|
||||
"\", \""..sO.."\", \""..sA.."\"})"
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function string entity:trackasmlibGenActivePointDSV(entity ucsEnt, string sType, string sName, number nPoint, string sP, string sDelim)
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
if(not (ucsEnt and ucsEnt:IsValid())) then return "" end
|
||||
local sDelim = stringSub(sDelim,1,1)
|
||||
if(not (stringLen(sDelim) > 0)) then return "" end
|
||||
local C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
local ucsPos = ucsEnt:GetPos()
|
||||
local sO = tostring(ucsPos[C1])..","..tostring(ucsPos[C2])..","..tostring(ucsPos[C3])
|
||||
C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
local ucsAng = ucsEnt:GetAngles()
|
||||
local sA = tostring(ucsAng[C1])..","..tostring(ucsAng[C2])..","..tostring(ucsAng[C3])
|
||||
return "TRACKASSEMBLY_PIECES"..sDelim.."\""..this:GetModel().."\""..sDelim.."\""..
|
||||
sType.."\""..sDelim.."\""..sName.."\""..sDelim..tostring(nPoint or 0)..
|
||||
sDelim.."\""..sP.."\""..sDelim.."\""..sO.."\""..sDelim.."\""..sA.."\""
|
||||
end
|
||||
|
||||
__e2setcost(100)
|
||||
e2function array entity:trackasmlibSnapEntity(vector trHitPos , string hdModel , number hdPointID,
|
||||
number nActRadius, number enFlatten, number enIgnTyp ,
|
||||
vector ucsOffPos , vector ucsOffAng)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local stSpawn = asmlib.GetEntitySpawn(this,trHitPos,hdModel,hdPointID,
|
||||
nActRadius,enFlatten,enIgnTyp,
|
||||
ucsPos[1],ucsPos[2],ucsPos[3],
|
||||
ucsAng[1],ucsAng[2],ucsAng[3])
|
||||
if(not stSpawn) then return {} end
|
||||
return {stSpawn.SPos, stSpawn.SAng}
|
||||
end
|
||||
|
||||
__e2setcost(80)
|
||||
e2function array trackasmlibSnapNormal(vector ucsPos , angle ucsAng , string hdModel,
|
||||
number hdPointID, vector ucsOffPos, vector ucsOffAng)
|
||||
if(not enFlag) then return {} end
|
||||
local stSpawn = asmlib.GetNormalSpawn(ucsPos,ucsAng,hdModel,hdPointID,
|
||||
ucsOffPos[1],ucsOffPos[2],ucsOffPos[3],
|
||||
ucsOffAng[1],ucsOffAng[2],ucsOffAng[3])
|
||||
if(not stSpawn) then return {} end
|
||||
return {stSpawn.SPos, stSpawn.SAng}
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibIsPiece(string sModel)
|
||||
if(not enFlag) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibIsPiece()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(120)
|
||||
e2function array trackasmlibGetOffset(string sModel, number nOffset, string sPOA)
|
||||
if(not enFlag) then return {} end
|
||||
local stPOA = asmlib.LocatePOA(asmlib.CacheQueryPiece(sModel),nOffset)
|
||||
if(not stPOA) then return {} end
|
||||
local sPOA = stringSub(stringUpper(tostring(sPOA)),1,1)
|
||||
local arResult = {}
|
||||
local C1, C2, C3, C4
|
||||
if (sPOA == "P") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "O") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "A") then C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
else return arResult end
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[2] = stPOA[sPOA][C2]
|
||||
arResult[3] = stPOA[sPOA][C3]
|
||||
C1, C2, C3, C4 = asmlib.GetIndexes("S")
|
||||
arResult[4] = stPOA[sPOA][C1]
|
||||
arResult[5] = stPOA[sPOA][C2]
|
||||
arResult[6] = stPOA[sPOA][C3]
|
||||
arResult[7] = stPOA[sPOA][C4] and 1 or 0
|
||||
return arResult
|
||||
end
|
||||
|
||||
__e2setcost(120)
|
||||
e2function array entity:trackasmlibGetOffset(number nOffset, string sPOA)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local stPOA = asmlib.LocatePOA(asmlib.CacheQueryPiece(this:GetModel()),nOffset)
|
||||
if(not stPOA) then return {} end
|
||||
local sPOA = stringSub(stringUpper(tostring(sPOA)),1,1)
|
||||
local arResult = {}
|
||||
local C1, C2, C3, C4
|
||||
if (sPOA == "P") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "O") then C1, C2, C3 = asmlib.GetIndexes("V")
|
||||
elseif(sPOA == "A") then C1, C2, C3 = asmlib.GetIndexes("A")
|
||||
else return arResult end
|
||||
arResult[1] = stPOA[sPOA][C1]
|
||||
arResult[2] = stPOA[sPOA][C2]
|
||||
arResult[3] = stPOA[sPOA][C3]
|
||||
C1, C2, C3, C4 = asmlib.GetIndexes("S")
|
||||
arResult[4] = stPOA[sPOA][C1]
|
||||
arResult[5] = stPOA[sPOA][C2]
|
||||
arResult[6] = stPOA[sPOA][C3]
|
||||
arResult[7] = stPOA[sPOA][C4] and 1 or 0
|
||||
return arResult
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string trackasmlibGetType(string sModel)
|
||||
if(not enFlag) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Type) then return stRecord.Type else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string entity:trackasmlibGetType()
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Type) then return stRecord.Type else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string trackasmlibGetName(string sModel)
|
||||
if(not enFlag) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Name) then return stRecord.Name else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function string entity:trackasmlibGetName()
|
||||
if(not (this and this:IsValid() and enFlag)) then return "" end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Name) then return stRecord.Name else return "" end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibGetPointsCount(string sModel)
|
||||
if(not enFlag) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(sModel)
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibGetPointsCount()
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
---------- Additions ------------
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number trackasmlibHasAdditions(string sModel)
|
||||
if(not enFlag) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(30)
|
||||
e2function number entity:trackasmlibHasAdditions()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(stRecord) then return anyTrue else return anyFalse end
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function number trackasmlibGetAdditionsCount(string sModel)
|
||||
if(not enFlag) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function number entity:trackasmlibGetAdditionsCount()
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(stRecord and stRecord.Kept) then return stRecord.Kept else return 0 end
|
||||
end
|
||||
|
||||
__e2setcost(60)
|
||||
e2function array trackasmlibGetAdditionsLine(string sModel, number nLine)
|
||||
if(not enFlag) then return {} end
|
||||
local defAddit = asmlib.GetOpVar("DEFTABLE_ADDITIONS")
|
||||
if(not defAddit) then
|
||||
return asmlib.StatusLog({},"entity:trackasmlibGetAdditionLine(number): No table definition")
|
||||
end
|
||||
local stRecord = asmlib.CacheQueryAdditions(sModel)
|
||||
if(not stRecord) then return {} end
|
||||
if(not stRecord[nLine]) then return {} end
|
||||
stRecord = stRecord[nLine] -- Ordered by ID. Get the line per model
|
||||
local cntField = 2 -- The model is missed by the main SELECT
|
||||
local arAdditionsLine = {}
|
||||
while(defAddit[cntField]) do
|
||||
arAdditionsLine[cntField-1] = stRecord[defAddit[cntField][1]]
|
||||
cntField = cntField + 1
|
||||
end
|
||||
return arAdditionsLine
|
||||
end
|
||||
|
||||
__e2setcost(60)
|
||||
e2function array entity:trackasmlibGetAdditionsLine(number nLine)
|
||||
if(not (this and this:IsValid() and enFlag)) then return {} end
|
||||
local defAddit = asmlib.GetOpVar("DEFTABLE_ADDITIONS")
|
||||
if(not defAddit) then
|
||||
return asmlib.StatusLog({},"entity:trackasmlibGetAdditionLine(number): No table definition")
|
||||
end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(not stRecord) then return {} end
|
||||
if(not stRecord[nLine]) then return {} end
|
||||
stRecord = stRecord[nLine] -- Ordered by ID. Get the line per model
|
||||
local cntField = 2 -- The model is missed by the main SELECT
|
||||
local arAdditionsLine = {}
|
||||
while(defAddit[cntField]) do
|
||||
arAdditionsLine[cntField-1] = stRecord[defAddit[cntField][1]]
|
||||
cntField = cntField + 1
|
||||
end
|
||||
return arAdditionsLine
|
||||
end
|
||||
|
||||
------------ PhysProperties ------------
|
||||
|
||||
__e2setcost(15)
|
||||
e2function array trackasmlibGetProperty(string sType)
|
||||
if(not enFlag) then return {} end
|
||||
local stRecord = asmlib.CacheQueryProperty(sType)
|
||||
if(not stRecord) then return {} end
|
||||
return stRecord
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function array trackasmlibGetProperty()
|
||||
if(not enFlag) then return {} end
|
||||
local stRecord = asmlib.CacheQueryProperty()
|
||||
if(not stRecord) then return {} end
|
||||
return stRecord
|
||||
end
|
||||
|
||||
----------- Piece creator --------------
|
||||
|
||||
__e2setcost(50)
|
||||
e2function entity trackasmlibMakePiece(string sModel, vector vPos, angle aAng, number nMass, string sBgpID, number nR, number nG, number nB, number nA)
|
||||
if(not enFlag) then return nil end
|
||||
return asmlib.MakePiece(sModel,Vector(vPos[1],vPos[2],vPos[3]),
|
||||
Angle (aAng[1],aAng[2],aAng[3]),
|
||||
nMass or 50000,sBgpID or "",
|
||||
Color(nR or 255, nG or 255, nB or 255, nA or 255))
|
||||
end
|
||||
|
||||
__e2setcost(50)
|
||||
e2function entity entity:trackasmlibMakePiece(vector vPos, angle aAng)
|
||||
if(not (this and this:IsValid() and enFlag)) then return nil end
|
||||
local phthis = this:GetPhysicsObject()
|
||||
if(not (phthis and phthis:IsValid())) then return nil end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return nil end
|
||||
local sBgpID = asmlib.GetPropBodyGroup(this)..
|
||||
asmlib.GetOpVar("OPSYM_DIRECTORY")..
|
||||
asmlib.GetPropSkin(this)
|
||||
return asmlib.MakePiece(this:GetModel(),
|
||||
Vector(vPos[1],vPos[2],vPos[3]),
|
||||
Angle (aAng[1],aAng[2],aAng[3]),
|
||||
phthis:GetMass(),sBgpID,this:GetColor())
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function entity entity:trackasmlibApplyPhysicalAnchor(entity eBase, number nWe, number nNc)
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
if(not (eBase and eBase:IsValid())) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return anyFalse end
|
||||
return asmlib.ApplyPhysicalAnchor(this,eBase,nWe,nNc) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(15)
|
||||
e2function entity entity:trackasmlibApplyPhysicalSettings(number nPi, number nFr, number nGr, string sPh)
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return anyFalse end
|
||||
return asmlib.ApplyPhysicalSettings(this,nPi,nFr,nGr,sPh) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(35)
|
||||
e2function number entity:trackasmlibAttachAdditions()
|
||||
if(not (this and this:IsValid() and enFlag)) then return anyFalse end
|
||||
local stRecord = asmlib.CacheQueryAdditions(this:GetModel())
|
||||
if(not stRecord) then return 0 end
|
||||
return asmlib.AttachAdditions(this) and anyTrue or anyFalse
|
||||
end
|
||||
|
||||
__e2setcost(20)
|
||||
e2function number entity:trackasmlibAttachBodyGroups(string sBgpID)
|
||||
if(not (this and this:IsValid() and enFlag)) then return 0 end
|
||||
local stRecord = asmlib.CacheQueryPiece(this:GetModel())
|
||||
if(not stRecord) then return 0 end
|
||||
return asmlib.AttachBodyGroups(this, sBgpID) and anyTrue or anyFalse
|
||||
end
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
13
readme.md
13
readme.md
@ -133,7 +133,7 @@ A: Here they are, with available status, why I did not do some of them ( in the
|
||||
20) Mr. Train's G-Gauge rails
|
||||
21) Ron's 56 gauge rails ( Removed by the add-on owner. Discontinued )
|
||||
22) Ron's 2ft track pack
|
||||
23) PHX Tubes ( In DEV 0% Done )
|
||||
23) PHX Tubes
|
||||
|
||||
Q: Dude the rails are not showing in the menu, what should I do ?
|
||||
A: SUBSCRIBE TO THE OWNER OF THE ADDON !!!!
|
||||
@ -160,6 +160,17 @@ A: Remember when I got suggestions to do the switchers.
|
||||
is chosen when stacking is in place. The end of the line with the green
|
||||
circle points to the next active position that is chosen.
|
||||
|
||||
Q: Dude I've messed up my console variables, how can I factory-reset them ?
|
||||
A: Easy. First you need to enable the developer mode via "trackassembly_devmode 1"
|
||||
Then in the bodygroup/skin text box ( or "trackassembly_bgskids" variable ) enter:
|
||||
"reset cvars":
|
||||
reset all cvars to the factory default settings
|
||||
"delete"
|
||||
followed by space for deleting the exported database without quitting
|
||||
the game, followed by either "cl" or "sv" or both, separated by space
|
||||
to delete the client or server or both instance generated databases
|
||||
N: The console variables being set in this question will be reset also
|
||||
|
||||
Q: How can I control errors when the clients are flooding my server with rails,
|
||||
and stacking/spawning outside of the map bounds?
|
||||
A: Easy, :D Just set "trackassembly_bnderrmod" to one of the following values
|
||||
|
Loading…
Reference in New Issue
Block a user