added some more debug prints to populateThrusterValues
This commit is contained in:
10
main.lua
10
main.lua
@@ -256,7 +256,7 @@ function PropellerInit()
|
||||
|
||||
for pi, pv in ipairs(propellers) do
|
||||
if Thrusters[peripheral.getName(pv)] == nil then
|
||||
for ti, tv in ipairs(transmissions) do
|
||||
for _, tv in pairs(transmissions) do
|
||||
if pv.getSubnetworkAnchorId() == tv.getSelfId() then
|
||||
if Thrusters[peripheral.getName(pv)] == nil then
|
||||
Thrusters[peripheral.getName(pv)] = {
|
||||
@@ -352,7 +352,7 @@ end
|
||||
local function populateThrusterValues()
|
||||
for _, thruster in pairs(Thrusters) do
|
||||
if thruster.name == nil and thruster.thruster == nil then -- as long as we have one of thruster or name, we can fetch other data
|
||||
print("ERROR: Thruster "..peripheral.getName(thruster.thruster).." has no name or thruster object. Removing entry in thruster list")
|
||||
print("ERROR: Thruster ".._.." has no name or thruster object. Removing entry in thruster list")
|
||||
Thrusters[_] = nil
|
||||
return
|
||||
end
|
||||
@@ -364,8 +364,10 @@ local function populateThrusterValues()
|
||||
thruster.thruster = peripheral.wrap(thruster.name)
|
||||
end
|
||||
if thruster.type == nil then
|
||||
if Config.Debug then print("DEBUG: Thruster "..thruster.name.." does not have a type.") end
|
||||
for _, tt in ipairs(ThrusterTypes) do
|
||||
if peripheral.getType(thruster.thruster) == tt then
|
||||
if Config.Debug then print("DEBUG: Detected thruster "..thruster.name.." is of type 'thruster'.") end
|
||||
thruster.type = "thruster"
|
||||
break
|
||||
end
|
||||
@@ -373,18 +375,21 @@ local function populateThrusterValues()
|
||||
|
||||
for _, pt in ipairs(PropellerTypes) do
|
||||
if peripheral.getType(thruster.thruster) == pt then
|
||||
if Config.Debug then print("DEBUG: Detected thruster "..thruster.name.." is of type 'rotator'.") end
|
||||
thruster.type = "rotator"
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if thruster.type == "rotator" and thruster.transmission == nil then
|
||||
if Config.Debug then print("DEBUG: Thruster "..thruster.name.." does not have an associated transmission.") end
|
||||
local subnetworkId = peripheral.wrap(thruster.name).getSubnetworkAnchorId()
|
||||
for _, transmissionType in ipairs(TransmissionTypes) do
|
||||
local transmissions = { peripheral.find(transmissionType) }
|
||||
if transmissions ~= nil and transmissions[1] ~= nil then
|
||||
for _, transmission in ipairs(transmissions) do
|
||||
if transmission.getSelfId() == subnetworkId then
|
||||
if Config.Debug then print("DEBUG: Detected that thruster "..thruster.name.." is connected to transmission "..peripheral.getName(transmission)) end
|
||||
thruster.transmission = peripheral.getName(transmission)
|
||||
end
|
||||
end
|
||||
@@ -394,6 +399,7 @@ local function populateThrusterValues()
|
||||
end
|
||||
end
|
||||
if thruster.power == nil then
|
||||
if Config.Debug then print("DEBUG: Thruster "..thruster.name..": thruster power is not populated") end
|
||||
if thruster.type == "thruster" then
|
||||
thruster.power = thruster.thruster.getPower()
|
||||
elseif thruster.type == "rotator" then
|
||||
|
||||
Reference in New Issue
Block a user