change some ordering and add some debug prints to thruster init functions
This commit is contained in:
99
main.lua
99
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",
|
||||
|
||||
Reference in New Issue
Block a user