Weird table access error

Place to get help with not working mods / modding interface.
Fatmice
Filter Inserter
Filter Inserter
Posts: 813
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Weird table access error

Post by Fatmice »

http://pastebin.com/CNXkDPTx
Image

The error only happens when my mod entity is adjacent to another of my mod entity. I do not see what is causing this error. Could anyone help me spot the error please? :?
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5412
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Weird table access error

Post by Klonan »

It seems you are searching for generator in this global roster, but for many records this does not exist:

Code: Select all

	if entity_name == "reactor-steam-generator-01" then
		for k,entity_table in pairs(global.ROSTER) do
			if entity_id == entity_table.record.steamgenerator.id then
				entity_table[3][1].destroy()
				entity_table[4][1].destroy()
				table.remove(global.ROSTER, k)
				return
			end
		end
	end
This looks for record.steamgenerator

However on line 905, a record is added using turbine generator:

Code: Select all

turbine_generator["record"] = {
  ["turbinegenerator"] = {
    ["id"] = event.created_entity.unit_number,
    ["position"] = {
      ["x"] = event.created_entity.position.x,
      ["y"] = event.created_entity.position.y
    }
  },
Which means for this record, steamgenerator is nil
Fatmice
Filter Inserter
Filter Inserter
Posts: 813
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Weird table access error

Post by Fatmice »

Indeed, I thought of the same on my drive home today. Well, easy fix then. Thanks Klonan :)
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
Post Reply

Return to “Modding help”