I'm gettign the below error, and the fix is to change the order of entities built. If I put the wall first, no error, if I put the wall after the control station, I get this error when building the control station. The error line actually refers to the wall code.
Line 134 is "if entity and entity.name == "ne-living-wall" then", but I get the error when building the "AlienControlStation_Area" entity.
again, if the Control station code is at the bottom, no problem, if I put the call under it, error.

No problem:
Code: Select all
---------------------------------------------
function On_Built(event)
local entity = event.created_entity
--- Living Wall built
if entity and entity.name == "ne-living-wall" then
if global.Living_Walls_Table == nil then
global.Living_Walls_Table = {}
end
writeDebug("Living Wall has been built")
local Created_L_Wall = event.created_entity
table.insert(global.Living_Walls_Table, Created_L_Wall)
end
--- Terraforming Station has been built
if entity and entity.name == "TerraformingStation" then
if global.numTerraformingStations < 0 then
global.numTerraformingStations = 0
end
global.numTerraformingStations = global.numTerraformingStations + 1
global.factormultiplier = GetFactorPerTerraformingStation(global.numTerraformingStations)
writeDebug("The the number of Terraforming Stations: " .. global.numTerraformingStations)
end
--- Alien Control Station has been built
if entity and entity.name == "AlienControlStation_Area" then
local newAlienControlStation
local surface = event.created_entity.surface
local force = event.created_entity.force
newAlienControlStation = surface.create_entity({name = "AlienControlStation", position = event.created_entity.position, force = force})
event.created_entity.destroy()
table.insert(global.beacons, newAlienControlStation)
end
end
Code: Select all
---------------------------------------------
function On_Built(event)
local entity = event.created_entity
--- Terraforming Station has been built
if entity and entity.name == "TerraformingStation" then
if global.numTerraformingStations < 0 then
global.numTerraformingStations = 0
end
global.numTerraformingStations = global.numTerraformingStations + 1
global.factormultiplier = GetFactorPerTerraformingStation(global.numTerraformingStations)
writeDebug("The the number of Terraforming Stations: " .. global.numTerraformingStations)
end
--- Alien Control Station has been built
if entity and entity.name == "AlienControlStation_Area" then
local newAlienControlStation
local surface = event.created_entity.surface
local force = event.created_entity.force
newAlienControlStation = surface.create_entity({name = "AlienControlStation", position = event.created_entity.position, force = force})
event.created_entity.destroy()
table.insert(global.beacons, newAlienControlStation)
end
--- Living Wall built
if entity and entity.name == "ne-living-wall" then
if global.Living_Walls_Table == nil then
global.Living_Walls_Table = {}
end
writeDebug("Living Wall has been built")
local Created_L_Wall = event.created_entity
table.insert(global.Living_Walls_Table, Created_L_Wall)
end
end