Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----/ TrainSignalNetwork class /---------------------------------------------
- local instances = {}
- --/ constructors /--
- function new(id1, id2)
- local self = {}
- self.subNetwork1 = {
- id = id1,
- signalState = false,
- }
- self.subNetwork2 = {
- id = id2,
- signalState = false,
- }
- return self
- end
- --/ functions /--
- function findFromComputerId(id)
- for _, tsn in pairs(instances) do
- if tsn.subNetwork1.id == id then
- return tsn, tsn.subNetwork1, tsn.subNetwork2 -- the entire system, the relevant sub-system, and the other sub-system
- elseif tsn.subNetwork2.id == id then
- return tsn, tsn.subNetwork2, tsn.subNetwork1 -- the entire system, the relevant sub-system, and the other sub-system
- end
- end
- end
- ----/ linked computer ids /---------------------------------------------
- --[[
- Each array represents a train signal network, and the numbers are computer ids
- ]]
- local linkedIds = {
- -- {120, 114},
- {3, 5},
- {8, 9},
- }
- ----/ make systems from linked ids /---------------------------------------------
- for _, list in pairs(linkedIds) do
- local trainSignalNetwork = new(unpack(list))
- table.insert(instances, trainSignalNetwork)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement