Help Converting to 0.12 please

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Help Converting to 0.12 please

Post by TheSAguy »

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

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.
Attachments
factorio-current.log
Crash Log
(4.89 KiB) Downloaded 189 times
Natural-Evolution_3.0.7.zip
NE 3.0.7
(879.64 KiB) Downloaded 132 times
1.zip
Save
(3.29 MiB) Downloaded 146 times
Last edited by TheSAguy on Tue Jul 21, 2015 2:55 am, edited 6 times in total.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Help Converting to 0.12 please

Post by orzelek »

It's this (line 11-12):

Code: Select all

event.createdentity
It also needs an _ - might not be in rename script.

Not sure where to go further - didn't use your mod :D
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

Orzelek,
Found a major bug with your Factorio experience...
Evidence below:
orzelek wrote: Not sure where to go further - didn't use your mod :D
So I think I have most thinks working, except my Alien Control stations. I'm not getting any errors, but it's not converting any aliens. Could someone please take a look?

Thanks.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

I think I've tracked town my problem. It's with inserting things into tables.

Here is my current code:

Code: Select all

    if event.created_entity.name == "AlienControlStation" then
		table.insert(global.beacons, entity)
		
	end
How should this be updated with v.12?
MOD attached to first post.

HELP appreciated!

Thanks.
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Help Converting to 0.12 please

Post by drs9999 »

Shouldn't:

Code: Select all

table.insert(global.beacons, entity)
rather be:

Code: Select all

table.insert(global.beacons, event.created_entity)
?
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

Thanks drs9999,
Got that part fixed. Now having a problem with: "find_entities_filtered"

Getting this error:
Image

I have "find_entities_filtered" code in two places:
Line 166, triggers the error above

Code: Select all

local bases = game.find_entities_filtered{type="unit-spawner", area=Get_Bounding_Box(beacon.position, NEConfig.SpawnerSearchDistance)}
and line 203:

Code: Select all

if game.find_entities_filtered{name="AlienControlStation", area=Get_Bounding_Box(mind.position, NEConfig.UnitSearchDistance)}[1] then 
I know this is with the change that happend in v0.12 described below:

Code: Select all

Some commands moved from LuaGame to LuaSurface: get_pollution, can_place_entity, find_entity, find_entities, find_entities_filtered,
find_non_colliding_position, find_enemy_units, find_nearest_enemy, set_multi_command, create_entity, create_unit_group, build_enemy_base,
get_tile, get_tileproperties, set_tiles, pollute, get_chunks, is_chunk_generated
But don't exactly know what that means.

Besides fixing this code, is there a place I can go to learn a little more about all these changes??
I'm really not understanding the new "surface" thing...

Thanks for your help guys!
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Help Converting to 0.12 please

Post by ratchetfreak »

TheSAguy wrote:Thanks drs9999,
Got that part fixed. Now having a problem with: "find_entities_filtered"

Getting this error:
Image

I have "find_entities_filtered" code in two places:
Line 166, triggers the error above

Code: Select all

local bases = game.find_entities_filtered{type="unit-spawner", area=Get_Bounding_Box(beacon.position, NEConfig.SpawnerSearchDistance)}
and line 203:

Code: Select all

if game.find_entities_filtered{name="AlienControlStation", area=Get_Bounding_Box(mind.position, NEConfig.UnitSearchDistance)}[1] then 
I know this is with the change that happend in v0.12 described below:

Code: Select all

Some commands moved from LuaGame to LuaSurface: get_pollution, can_place_entity, find_entity, find_entities, find_entities_filtered,
find_non_colliding_position, find_enemy_units, find_nearest_enemy, set_multi_command, create_entity, create_unit_group, build_enemy_base,
get_tile, get_tileproperties, set_tiles, pollute, get_chunks, is_chunk_generated
But don't exactly know what that means.

Besides fixing this code, is there a place I can go to learn a little more about all these changes??
I'm really not understanding the new "surface" thing...

Thanks for your help guys!
in the event you should get a surface variable (sometimes from the entity the event is about)

otherwise the default surface is game.surfaces['nauvis'] (IIRC)
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

Thanks,

Got the surface thing fixed (I think),
Now getting this:Image

I think I saw something about the "equils" being replaced by "=="

Code: Select all

if base.force.equals(game.forces.enemy) and math.random(global.minds.difficulty*2)==1 then
What's the new syntax?
Thanks.
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Help Converting to 0.12 please

Post by ratchetfreak »

just the == sign:

Code: Select all

    if base.force == game.forces.enemy and math.random(global.minds.difficulty*2)==1 then
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

Okay,
Fixed that, but now I'm getting a game crash. No error massage....
Please see initial post.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Converting to 0.12 please

Post by TheSAguy »

I think I've narrowed down what is causing my crash, but can't get it fixed.
Please see updated first post.

Thanks..
yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

Re: Help Converting to 0.12 please

Post by yeganer »

I have no idea what your enemies variable contains BUT you could debug that thing by printing out your variables.

because i think you might be looping over something completely different and then comparing stuff and in the end doing something unexpected.

i think you might me interested in
surface.find_entities_filtered({...,force=game.forces.enemy})

In general i think it was a bad idea to rewrite your 1st post because it doesn't show your initial problem and others might have the same problem as you. now they won't find this.
Anyway, dump the table and look whats wrong with it.
Hint:
game.player.print(serpent.dump(table))

The last 2 calls in the crashlog are
Unit::releaseFromSpawner
and Unit::setCommand

so it might be your setcommand that crashes.
perhaps you could try to test that part of the code in the console?
Post Reply

Return to “Modding help”