mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
sroutes
This commit is contained in:
@@ -506,24 +506,47 @@ tps:defaultAccess( ULib.ACCESS_ALL )
|
|||||||
tps:help( "Teleport between stations." )
|
tps:help( "Teleport between stations." )
|
||||||
|
|
||||||
|
|
||||||
function ulx.getroutes( calling_ply )
|
function ulx.sroutes( calling_ply, signal )
|
||||||
if not IsValid(calling_ply) then return end
|
if not IsValid(calling_ply) then return end
|
||||||
local Train = calling_ply:GetTrain()
|
local Train = calling_ply:GetTrain()
|
||||||
if not IsValid(Train) then
|
if IsValid(Train) then
|
||||||
ULib.tsayError( calling_ply, "You must sit in train",true)
|
local signal
|
||||||
return
|
-- Get train position
|
||||||
end
|
local pos = Metrostroi.TrainPositions[Train]
|
||||||
|
if pos then pos = pos[1] end
|
||||||
|
-- Get previous ARS section
|
||||||
|
if pos then
|
||||||
|
signal = Metrostroi.GetARSJoint(pos.node1,pos.x,Metrostroi.TrainDirections[Train], Train)
|
||||||
|
end
|
||||||
|
|
||||||
local signal
|
if signal then
|
||||||
-- Get train position
|
local found = false
|
||||||
local pos = Metrostroi.TrainPositions[Train]
|
for k,v in pairs(signal.Routes or {}) do
|
||||||
if pos then pos = pos[1] end
|
if v.RouteName != "" then
|
||||||
-- Get previous ARS section
|
found = true
|
||||||
if pos then
|
break
|
||||||
signal = Metrostroi.GetARSJoint(pos.node1,pos.x,Metrostroi.TrainDirections[Train], Train)
|
end
|
||||||
end
|
end
|
||||||
|
if not found then
|
||||||
|
ULib.tsayError( calling_ply, "Signal routes not found", true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ulx.fancyLog("Routes of signal #s:", signal.Name)
|
||||||
|
for k,v in pairs(signal.Routes) do
|
||||||
|
if v.RouteName != "" then
|
||||||
|
ulx.fancyLog("#s", v.RouteName)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ULib.tsayError( calling_ply, "Signal not found", true)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local signal = Metrostroi.GetSignalByName(sig)
|
||||||
|
if not signal then
|
||||||
|
ULib.tsayError( calling_ply, "Signal not found", true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if signal then
|
|
||||||
local found = false
|
local found = false
|
||||||
for k,v in pairs(signal.Routes or {}) do
|
for k,v in pairs(signal.Routes or {}) do
|
||||||
if v.RouteName != "" then
|
if v.RouteName != "" then
|
||||||
@@ -541,44 +564,13 @@ function ulx.getroutes( calling_ply )
|
|||||||
ulx.fancyLog("#s", v.RouteName)
|
ulx.fancyLog("#s", v.RouteName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
ULib.tsayError( calling_ply, "Signal not found", true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local getroutes = ulx.command( CATEGORY_NAME, "ulx getroutes", ulx.getroutes, "!getroutes" )
|
local sroutes = ulx.command( CATEGORY_NAME, "ulx sroutes", ulx.sroutes, "!sroutes" )
|
||||||
getroutes:defaultAccess( ULib.ACCESS_ALL )
|
sroutes:addParam{ type=ULib.cmds.StringArg, hint="Signal", ULib.cmds.takeRestOfLine }
|
||||||
getroutes:help( "Print routes of next signal" )
|
sroutes:defaultAccess( ULib.ACCESS_ALL )
|
||||||
|
sroutes:help( "Print routes of next signal" )
|
||||||
|
|
||||||
function ulx.getsigroutes( calling_ply, sig )
|
|
||||||
if not IsValid(calling_ply) then return end
|
|
||||||
local signal = Metrostroi.GetSignalByName(sig)
|
|
||||||
if not signal then
|
|
||||||
ULib.tsayError( calling_ply, "Signal not found", true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local found = false
|
|
||||||
for k,v in pairs(signal.Routes or {}) do
|
|
||||||
if v.RouteName != "" then
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not found then
|
|
||||||
ULib.tsayError( calling_ply, "Signal routes not found", true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
ulx.fancyLog("Routes of signal #s:", signal.Name)
|
|
||||||
for k,v in pairs(signal.Routes) do
|
|
||||||
if v.RouteName != "" then
|
|
||||||
ulx.fancyLog("#s", v.RouteName)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local getsigroutes = ulx.command( CATEGORY_NAME, "ulx getsigroutes", ulx.getsigroutes, "!getsigroutes" )
|
|
||||||
getsigroutes:addParam{ type=ULib.cmds.StringArg, hint="Signal", ULib.cmds.takeRestOfLine }
|
|
||||||
getsigroutes:defaultAccess( ULib.ACCESS_ALL )
|
|
||||||
getsigroutes:help( "Print routes of signal" )
|
|
||||||
|
|
||||||
--Костылииии
|
--Костылииии
|
||||||
function ulx.sopen( calling_ply, arg )
|
function ulx.sopen( calling_ply, arg )
|
||||||
|
|||||||
Reference in New Issue
Block a user