Converting to 12.11 help - Solved

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

Converting to 12.11 help - Solved

Post by TheSAguy »

Thought I'd just ask, vs. going through a lot of mods to see what others have done. (Can always do that later...)

I'm getting an error on the "pairs" in below code:
This is in the data-updates.lua (Natural_Evolution_Enemies Mod)

Code: Select all

function Add_Poison_Resist(Raw,Percent)
	local Resist = {type = "poison",percent = Percent}
	for i,d in pairs(Raw) do
		if d.resistances ==nil then d.resistances={} end
		table.insert(d.resistances, Resist)
	end
end
I'm also getting an error on the below, control.lua, though I can just comma that out for now:
Does not like the "game.forces"

Code: Select all

	for k,force in pairs(game.forces) do 
		force.reset_recipes()
		force.reset_technologies() 
	end
Not yet sure if there are any other issues.
Here is my MOD if anyone want's to take a stab at it: GITHUB

Thanks for any help!!
Last edited by TheSAguy on Tue Nov 03, 2015 6:34 pm, edited 1 time in total.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Converting to 12.11 help

Post by orzelek »

First one is simple - you are trying to add resistance for rail entity that doesn't exist anymore.
There is now a straight-rail and curved-rail as two separate entities.

Second part is what was specifically blocked in 0.12.11 so it won't work there anymore.
This part should probably become a migration script or use the new configuration update event and be executed there.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1455
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Converting to 12.11 help

Post by TheSAguy »

orzelek wrote:First one is simple - you are trying to add resistance for rail entity that doesn't exist anymore.
There is now a straight-rail and curved-rail as two separate entities.

Second part is what was specifically blocked in 0.12.11 so it won't work there anymore.
This part should probably become a migration script or use the new configuration update event and be executed there.
Thanks Orzelek!
Okay, next crash:

Code: Select all

	for i = 1, #game.players, 1 do
        if game.players[i].force.technologies["AlienUnderstanding"].researched then
           game.players[i].force.recipes["Thumper"].enabled = true
        end
    end
I know that most, if not all cases of "game" have been removed. So what will I need to replace it with here?
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Converting to 12.11 help

Post by orzelek »

TheSAguy wrote:
orzelek wrote:First one is simple - you are trying to add resistance for rail entity that doesn't exist anymore.
There is now a straight-rail and curved-rail as two separate entities.

Second part is what was specifically blocked in 0.12.11 so it won't work there anymore.
This part should probably become a migration script or use the new configuration update event and be executed there.
Thanks Orzelek!
Okay, next crash:

Code: Select all

	for i = 1, #game.players, 1 do
        if game.players[i].force.technologies["AlienUnderstanding"].researched then
           game.players[i].force.recipes["Thumper"].enabled = true
        end
    end
I know that most, if not all cases of "game" have been removed. So what will I need to replace it with here?
It's more of the same - basically game is banned from on_load event. And this code here is not needed for on load most likely - it should be also a part of migration script.
There is a nice example of such script in data\base\migrations directory in file "2015-07-02_Factorio_0.12.0.lua". It contains the code to make sure that techs are unlocking stuff that was added to them later. Should be a good source of proper for loop for doing this.

You also have the same code with game.force iteration in enemies mod - after removing that one game will properly load. From what I see this removed code is not required to make mod work properly so it should work.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1455
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Converting to 12.11 help

Post by TheSAguy »

I have one piece of code that I forgot to convert to 12.11.
How would I cycle through players in 12.11? Currently I'm using:

Code: Select all

	
if event.entity.type == "unit-spawner" then

	writeDebug("YOU KILLED A SPAWNER")
		for i = 1, #game.players, 1 do
			player = game.players[i]
			player.surface.set_multi_command{command = {type=defines.command.attack, target=player.character, distraction=defines.distraction.by_enemy},unit_count = (20+math.floor(game.evolution_factor*100/#game.players)), unit_search_distance = 600}
		end

end
I think "#game.players" will currently crash, won't it?
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Converting to 12.11 help

Post by orzelek »

It works like previously - it doesn't work only in on_load event handler. All others should be ok.
Post Reply

Return to “Modding help”