mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Fix
This commit is contained in:
@@ -245,6 +245,7 @@ function ENT:Initialize()
|
|||||||
-- Overrides for train wire values from wiremod interface and special concommand
|
-- Overrides for train wire values from wiremod interface and special concommand
|
||||||
self.TrainWireOverrides = {}
|
self.TrainWireOverrides = {}
|
||||||
self.TrainWireOutside = {}
|
self.TrainWireOutside = {}
|
||||||
|
self.TrainWireOutsideFrom = {}
|
||||||
|
|
||||||
|
|
||||||
-- Is this train 'odd' or 'even' in coupled set
|
-- Is this train 'odd' or 'even' in coupled set
|
||||||
@@ -792,9 +793,8 @@ end]]
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function ENT:LeaderReadTrainWire(id)
|
function ENT:LeaderReadTrainWire(id)
|
||||||
if self.TrainWireOverrides[id] then return self.TrainWireOverrides[id] end
|
if self.TrainWireOverrides[id] then return self.TrainWireOverrides[id] end
|
||||||
local w = self.TrainWireOutside[id]
|
if self.TrainWireOutside[id] then
|
||||||
if w then
|
return (self.TrainWireOutsideFrom[id] and self.TrainWireTurbostroi[self.TrainWireOutsideFrom[id]] or 1)*self.TrainWireOutside[id]
|
||||||
if isnumber(w) then return w elseif (self.TrainWireTurbostroi[tonumber(w)] or 0) > 0 then return 1 end
|
|
||||||
end
|
end
|
||||||
return (self.TrainWireTurbostroi[id] or 0)+(self.TrainWireWriters[id] or 0)
|
return (self.TrainWireTurbostroi[id] or 0)+(self.TrainWireWriters[id] or 0)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -392,13 +392,15 @@ concommand.Add("metrostroi_wire", function(ply, _, args)
|
|||||||
args[1] = tonumber(args[1])
|
args[1] = tonumber(args[1])
|
||||||
if not args[1] then ply:PrintMessage(HUD_PRINTCONSOLE,"1st argument must be a number") return end
|
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
|
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 "").."!")
|
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())
|
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
|
else
|
||||||
print("sets outside power in train wire "..train:EntIndex())
|
print("sets outside power in train wire "..train:EntIndex())
|
||||||
end
|
end
|
||||||
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
||||||
train.TrainWireOutside[args[1]] = args[2] and args[2] or 1
|
train.TrainWireOutside[args[1]] = 1
|
||||||
|
train.TrainWireOutsideFrom[args[1]] = args[2]
|
||||||
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
--if train.WriteTrainWire then train:WriteTrainWire(args[1],1) end
|
||||||
else
|
else
|
||||||
if IsValid(ply) then
|
if IsValid(ply) then
|
||||||
@@ -433,10 +435,17 @@ concommand.Add("metrostroi_wire_reset", function(ply, _, args)
|
|||||||
else
|
else
|
||||||
print("Reset outside power in trains ")
|
print("Reset outside power in trains ")
|
||||||
end
|
end
|
||||||
|
args[1] = tonumber(args[1])
|
||||||
if args[1] then
|
if args[1] then
|
||||||
for _,v in pairs(trainList) do v.TrainWireOutside[tonumber(args[1])] = nil end
|
for _,v in pairs(trainList) do
|
||||||
|
v.TrainWireOutside[args[1]] = nil
|
||||||
|
v.TrainWireOutsideFrom[args[1]] = nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
for _,v in pairs(trainList) do v.TrainWireOutside = {} end
|
for _,v in pairs(trainList) do
|
||||||
|
v.TrainWireOutside = {}
|
||||||
|
v.TrainWireOutsideFrom = {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if IsValid(ply) then
|
if IsValid(ply) then
|
||||||
|
|||||||
Reference in New Issue
Block a user