mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
@@ -249,6 +249,7 @@ function ENT:Initialize()
|
||||
-- Overrides for train wire values from wiremod interface and special concommand
|
||||
self.TrainWireOverrides = {}
|
||||
self.TrainWireOutside = {}
|
||||
self.TrainWireOutsideFrom = {}
|
||||
|
||||
|
||||
-- Is this train 'odd' or 'even' in coupled set
|
||||
@@ -798,7 +799,9 @@ end]]
|
||||
--------------------------------------------------------------------------------
|
||||
function ENT:LeaderReadTrainWire(id)
|
||||
if self.TrainWireOverrides[id] then return self.TrainWireOverrides[id] end
|
||||
if self.TrainWireOutside[id] then return self.TrainWireOutside[id] end
|
||||
if self.TrainWireOutside[id] then
|
||||
return (self.TrainWireOutsideFrom[id] and (self.TrainWireTurbostroi[self.TrainWireOutsideFrom[id]] or 0) or 1)*self.TrainWireOutside[id]
|
||||
end
|
||||
return (self.TrainWireTurbostroi[id] or 0)+(self.TrainWireWriters[id] or 0)
|
||||
end
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ concommand.Add("metrostroi_fail", function(ply, _, args)
|
||||
if train then
|
||||
if IsValid(ply) then
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"Generating random failure in your train!")
|
||||
print("Player "..tostring(ply).." generated random failure in train "..train:EntIndex())
|
||||
print(tostring(ply).." generated random failure in train "..train:EntIndex())
|
||||
else
|
||||
print("Generating random failure in train "..train:EntIndex())
|
||||
end
|
||||
@@ -355,7 +355,7 @@ concommand.Add("metrostroi_fail_reset", function(ply, _, args)
|
||||
if #trainList > 0 then
|
||||
if IsValid(ply) then
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"Reset all failures in your train!")
|
||||
print("Player "..tostring(ply).." reset all failures in train "..trainList[1]:EntIndex())
|
||||
print(tostring(ply).." reset all failures in train "..trainList[1]:EntIndex())
|
||||
else
|
||||
print("Reset all failures in train "..trainList[1]:EntIndex())
|
||||
end
|
||||
@@ -390,14 +390,17 @@ concommand.Add("metrostroi_wire", function(ply, _, args)
|
||||
if train then
|
||||
if IsValid(ply) then
|
||||
args[1] = tonumber(args[1])
|
||||
if not args[1] then ply:PrintMessage(HUD_PRINTCONSOLE,"Argument must be a number") return end
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"sets outside power in train wire"..args[1].."!")
|
||||
print("Player "..tostring(ply).." sets outside power in train "..args[1].." wire failure in train "..train:EntIndex())
|
||||
if not args[1] then ply:PrintMessage(HUD_PRINTCONSOLE,"1st argument must be a number") return end
|
||||
if args[2] and not tonumber(args[2]) then ply:PrintMessage(HUD_PRINTCONSOLE,"2nd argument must be a number") return end
|
||||
args[2] = tonumber(args[2])
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"sets outside power in train wire"..args[1]..(args[2] and "(from "..args[2].." wire)" or "").."!")
|
||||
print(tostring(ply).." sets outside power in train "..args[1].." wire"..(args[2] and "(from "..args[2].." wire)" or "").." failure in train number "..train:GetWagonNumber())
|
||||
else
|
||||
print("sets outside power in train wire "..train:EntIndex())
|
||||
end
|
||||
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
||||
train.TrainWireOutside[args[1]] = 1
|
||||
train.TrainWireOutsideFrom[args[1]] = args[2]
|
||||
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
||||
else
|
||||
if IsValid(ply) then
|
||||
@@ -426,12 +429,24 @@ concommand.Add("metrostroi_wire_reset", function(ply, _, args)
|
||||
|
||||
if #trainList > 0 then
|
||||
if IsValid(ply) then
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"reset wire outside power in train!")
|
||||
print("Player "..tostring(ply).." reset outside power in train ")
|
||||
if args[1] and not tonumber(args[1]) then ply:PrintMessage(HUD_PRINTCONSOLE,"Argument must be a number") return end
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"reset "..(args[1] and args[1].." " or "").."wire outside power in train!")
|
||||
print(tostring(ply).." reset "..(args[1] and args[1].." wire " or "").."outside power in train ")
|
||||
else
|
||||
print("Reset outside power in trains ")
|
||||
end
|
||||
args[1] = tonumber(args[1])
|
||||
if args[1] then
|
||||
for _,v in pairs(trainList) do
|
||||
v.TrainWireOutside[args[1]] = nil
|
||||
v.TrainWireOutsideFrom[args[1]] = nil
|
||||
end
|
||||
else
|
||||
for _,v in pairs(trainList) do
|
||||
v.TrainWireOutside = {}
|
||||
v.TrainWireOutsideFrom = {}
|
||||
end
|
||||
end
|
||||
for _,v in pairs(trainList) do v.TrainWireOutside = {} end
|
||||
else
|
||||
if IsValid(ply) then
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"You must be inside a train!")
|
||||
@@ -453,7 +468,7 @@ concommand.Add("metrostroi_can", function(ply, _, args)
|
||||
if tonumber(args[4]) then value = tonumber(args[4]) end
|
||||
local srcid = tonumber(args[5])
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE,"Hacking CAN!")
|
||||
print(Format("Player %s hack CAN(%s->%s:%s %s=%s)",ply,srcid,system,id,name,value))
|
||||
print(Format("%s hack CAN(%s->%s:%s %s=%s)",ply,srcid,system,id,name,value))
|
||||
train:CANWrite("Hacker",srcid or train:GetWagonNumber(),system,id,name,value)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user