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
|
for pi, pv in ipairs(propellers) do
|
||||||
if Thrusters[peripheral.getName(pv)] == nil then
|
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 pv.getSubnetworkAnchorId() == tv.getSelfId() then
|
||||||
if Thrusters[peripheral.getName(pv)] == nil then
|
if Thrusters[peripheral.getName(pv)] == nil then
|
||||||
Thrusters[peripheral.getName(pv)] = {
|
Thrusters[peripheral.getName(pv)] = {
|
||||||
@@ -352,7 +352,7 @@ end
|
|||||||
local function populateThrusterValues()
|
local function populateThrusterValues()
|
||||||
for _, thruster in pairs(Thrusters) do
|
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
|
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
|
Thrusters[_] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -364,8 +364,10 @@ local function populateThrusterValues()
|
|||||||
thruster.thruster = peripheral.wrap(thruster.name)
|
thruster.thruster = peripheral.wrap(thruster.name)
|
||||||
end
|
end
|
||||||
if thruster.type == nil then
|
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
|
for _, tt in ipairs(ThrusterTypes) do
|
||||||
if peripheral.getType(thruster.thruster) == tt then
|
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"
|
thruster.type = "thruster"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -373,18 +375,21 @@ local function populateThrusterValues()
|
|||||||
|
|
||||||
for _, pt in ipairs(PropellerTypes) do
|
for _, pt in ipairs(PropellerTypes) do
|
||||||
if peripheral.getType(thruster.thruster) == pt then
|
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"
|
thruster.type = "rotator"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if thruster.type == "rotator" and thruster.transmission == nil then
|
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()
|
local subnetworkId = peripheral.wrap(thruster.name).getSubnetworkAnchorId()
|
||||||
for _, transmissionType in ipairs(TransmissionTypes) do
|
for _, transmissionType in ipairs(TransmissionTypes) do
|
||||||
local transmissions = { peripheral.find(transmissionType) }
|
local transmissions = { peripheral.find(transmissionType) }
|
||||||
if transmissions ~= nil and transmissions[1] ~= nil then
|
if transmissions ~= nil and transmissions[1] ~= nil then
|
||||||
for _, transmission in ipairs(transmissions) do
|
for _, transmission in ipairs(transmissions) do
|
||||||
if transmission.getSelfId() == subnetworkId then
|
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)
|
thruster.transmission = peripheral.getName(transmission)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -394,6 +399,7 @@ local function populateThrusterValues()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if thruster.power == nil then
|
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
|
if thruster.type == "thruster" then
|
||||||
thruster.power = thruster.thruster.getPower()
|
thruster.power = thruster.thruster.getPower()
|
||||||
elseif thruster.type == "rotator" then
|
elseif thruster.type == "rotator" then
|
||||||
|
|||||||
Reference in New Issue
Block a user