From ce11e77d7cf4a02e23579aeab02b5ee426debcfc Mon Sep 17 00:00:00 2001 From: templeofshadow Date: Mon, 29 Jun 2026 20:03:05 -0500 Subject: [PATCH] change some ordering and add some debug prints to thruster init functions --- main.lua | 99 ++++++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 57 deletions(-) diff --git a/main.lua b/main.lua index 3e21008..381694e 100644 --- a/main.lua +++ b/main.lua @@ -291,19 +291,10 @@ function PropellerInit() power = (tv.getSignal())/15 } end - if Thrusters[peripheral.getName(pv)] ~= nil then - if Thrusters[peripheral.getName(pv)].type == nil then - Thrusters[peripheral.getName(pv)].type = "rotator" - end - Thrusters[peripheral.getName(pv)].thruster = pv - Thrusters[peripheral.getName(pv)].transmission = peripheral.wrap(tv) - if Thrusters[peripheral.getName(pv)].affectVectors == nil then - Thrusters[peripheral.getName(pv)].affectVectors = {} - end - Thrusters[peripheral.getName(pv)].power = (tv.getSignal())/15 - end end end + elseif Config.Debug then + print("DEBUG: thruster of name "..peripheral.getName(pv).." already indexed, skipping (called by PropellerInit)") end end end @@ -351,56 +342,12 @@ function ThrusterInit() }, power = tv.getPower() } - end - if Thrusters[peripheral.getName(tv)] ~= nil then - if Thrusters[peripheral.getName(tv)].type == nil then - Thrusters[peripheral.getName(tv)].type = "thruster" - end - Thrusters[peripheral.getName(tv)].thruster = tv - Thrusters[peripheral.getName(tv)].transmission = nil - if Thrusters[peripheral.getName(tv)].affectVectors == nil then - Thrusters[peripheral.getName(tv)].affectVectors = {} - end - Thrusters[peripheral.getName(tv)].power = tv.getPower() + elseif Config.Debug then + print("DEBUG: thruster of name "..peripheral.getName(tv).." already indexed, skipping (called by ThrusterInit)") end end end -function Update() - PropellerInit() - ThrusterInit() -end - -local function checkIfThrusterIsIndexed() - local thrusters = {} - local unindexedThrusters = {} - - for _, v in ipairs(ThrusterTypes) do - local thrustersList = peripheral.find(v) - if thrustersList then - table.insert(thrusters, thrustersList) - end - end - - for _, v in ipairs(PropellerTypes) do - local thrustersList = peripheral.find(v) - if thrustersList then - table.insert(thrusters, thrustersList) - end - end - - for _, v in ipairs(thrusters) do - if Thrusters[peripheral.getName(v)] == nil then - table.insert(unindexedThrusters, v) - end - end - - if #unindexedThrusters == 0 then - return nil - end - return unindexedThrusters -end - -- this is for populating nil values from thruster config files local function populateThrusterValues() for _, thruster in pairs(Thrusters) do @@ -441,6 +388,8 @@ local function populateThrusterValues() thruster.transmission = peripheral.getName(transmission) end end + elseif Config.Debug then + print("DEBUG: No transmissions of type "..transmissionType.." (print from populateThrusterValues)") end end end @@ -463,6 +412,42 @@ local function populateThrusterValues() end end +function Update() + populateThrusterValues() + PropellerInit() + ThrusterInit() +end + +local function checkIfThrusterIsIndexed() + local thrusters = {} + local unindexedThrusters = {} + + for _, v in ipairs(ThrusterTypes) do + local thrustersList = peripheral.find(v) + if thrustersList then + table.insert(thrusters, thrustersList) + end + end + + for _, v in ipairs(PropellerTypes) do + local thrustersList = peripheral.find(v) + if thrustersList then + table.insert(thrusters, thrustersList) + end + end + + for _, v in ipairs(thrusters) do + if Thrusters[peripheral.getName(v)] == nil then + table.insert(unindexedThrusters, v) + end + end + + if #unindexedThrusters == 0 then + return nil + end + return unindexedThrusters +end + local function partiallyUpdateThrusters(thrusterList) local thrusterTypes = { "thruster",