Help Converting to 0.12 please
Posted: Sat Jul 18, 2015 2:32 am
Hi,
I'm getting a game crashing error.
Not getting any error messages, just crash.
The crash is happening when I place an Alien Control Station.
I've attached a save, just before putting it down. Once I do, it crashes once it converts...
I have narrowed down the problem to the below lines of code. If I comment these two lines out (230 & 231) in the function Convert_Base, I don't get the error:
elseif enemy.type=="unit" then
table.insert(units, enemy)
The second possibility is lines 258 - 260
Thanks.
I'm getting a game crashing error.
Not getting any error messages, just crash.
The crash is happening when I place an Alien Control Station.
I've attached a save, just before putting it down. Once I do, it crashes once it converts...
I have narrowed down the problem to the below lines of code. If I comment these two lines out (230 & 231) in the function Convert_Base, I don't get the error:
elseif enemy.type=="unit" then
table.insert(units, enemy)
The second possibility is lines 258 - 260
Code: Select all
function Convert_Base(base, died)
local enemies=Get_Bounding_Box(base.position, NEConfig.UnitSearchDistance/global.minds.difficulty2)
local units={}
local hives={}
local worms={}
local count=0
enemies = surface.find_entities(enemies)
for i, enemy in ipairs(enemies) do
if enemy.type=="turret" and enemy.force ==(game.forces.enemy) then
table.insert(worms, enemy)
elseif enemy.type=="unit-spawner" then
table.insert(hives, enemy)
[color=#FF0000] elseif enemy.type=="unit" then
table.insert(units, enemy)[/color]
end
end
count=#units+#hives+#worms
if count~=0 then -- prevent empty random interval
writeDebug("The number of Units Converted: " .. count)
end
if count~=0 and math.random(global.minds.difficulty2+math.sqrt(count))==1 then
if died then table.insert(global.hiveminds, game.create_entity{name=base.name, position=base.position, force=game.player.force}) end
for _, worm in pairs(worms) do worm.force=game.player.force writeDebug("Turret/Worm Converted") end
for _, hive in pairs(hives) do hive.force=game.player.force table.insert(global.hiveminds, hive) end
[color=#FF0000]for _, unit in pairs(units) do
unit.force=game.player.force
unit.set_command{type=defines.command.wander, distraction=defines.distraction.by_enemy}[/color]
-- remove mind controlled biters in range from the minds table
--so they aren't converted back into enemies when wandering away from the beacon
for i, controlled in ipairs(global.minds) do
writeDebug{unit, controlled}
if unit ==(controlled) then
--if unit.equals(controlled) then
table.remove(global.minds, i)
break
end
end
end
end
end
Thanks.