[Mod 1.0, 2.0] Info mod

Tools which are useful for mod development.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

[Mod 1.0, 2.0] Info mod

Post by darkfrei »

This mod adds all Factorio base tables into log file.
2018-12-07 22_35_49-D__Factorio_0.16_factorio-current.log - Notepad++.png
2018-12-07 22_35_49-D__Factorio_0.16_factorio-current.log - Notepad++.png (30.9 KiB) Viewed 6938 times
The same you can find in
Factorio\data\base\prototypes\decorative\decoratives.lua

Code: Select all

loot =
    {
      {item = "stone", probability = 1, count_min = 5, count_max = 10}
    },
Adding new loot:

Code: Select all

data.raw["simple-entity"]["stone-rock"].loot[2] = {item = "iron-ore", probability = 0.2, count_min = 1, count_max = 5}
Notepad++ Replace all lines starting with "/"

Code: Select all

.*  / 
old versions
Attachments
_info-mod_2.1.1.zip
For version 2.0
(2.11 KiB) Downloaded 16 times
Last edited by darkfrei on Sun Nov 03, 2024 8:21 pm, edited 24 times in total.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Mod 0.15] Info mod

Post by darkfrei »

Another example:

You want play Factorio 0.15, but you haven't enough time for it. Let's make all recipes cheaper! Finding in the log file:
2.251 Script data.lua:17: 5 / data.raw.recipe.wood.type = recipe
2.251 Script data.lua:17: 5 / data.raw.recipe.wood.name = wood
2.251 Script data.lua:17: 7 / data.raw.recipe.wood.ingredients.1.1 = raw-wood
2.251 Script data.lua:17: 7 / data.raw.recipe.wood.ingredients.1.2 = 1
2.251 Script data.lua:17: 5 / data.raw.recipe.wood.result = wood
2.251 Script data.lua:17: 5 / data.raw.recipe.wood.result_count = 2
Then our mod have this code:

Code: Select all

for i, recipe in pairs(data.raw.recipe) do
	if recipe.type == "recipe" then
		if recipe.ingredients then
			for i in pairs(recipe.ingredients) do
				recipe.ingredients[i][2] = 1
			end
			if recipe.result then
				recipe.result_count = 2
			end
	end
end
That's all!
First try
First try
2017-04-26 21_24_14.png (73.73 KiB) Viewed 8276 times
Really? Not all of them. By the 0.15 we have normal and expensive recipes:
1.570 Script data.lua:17: 5 / data.raw.recipe.electric-mining-drill.type = recipe
1.570 Script data.lua:17: 5 / data.raw.recipe.electric-mining-drill.name = electric-mining-drill
1.570 Script data.lua:17: 6 / data.raw.recipe.electric-mining-drill.normal.energy_required = 2
1.570 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.1.1 = electronic-circuit
1.570 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.1.2 = 3
1.571 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.2.1 = iron-gear-wheel
1.571 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.2.2 = 5
1.571 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.3.1 = iron-plate
1.571 Script data.lua:17: 8 / data.raw.recipe.electric-mining-drill.normal.ingredients.3.2 = 10
1.571 Script data.lua:17: 6 / data.raw.recipe.electric-mining-drill.normal.result = electric-mining-drill
It means, if we have .normal, then we are need exception:

Code: Select all

for i, recipe in pairs(data.raw.recipe) do
	if recipe.type == "recipe" then
		if recipe.ingredients then
			for i in pairs(recipe.ingredients) do
				recipe.ingredients[i][2] = 1
			end
			if recipe.result then
				recipe.result_count = 2
			end
		elseif recipe.normal.ingredients then -- for 0.15 for normal and expensive recipes 
			for i in pairs(recipe.normal.ingredients) do
				recipe.normal.ingredients[i][2] = 1
			end
			if recipe.normal.result then
				recipe.normal.result_count = 2
			end
		end
	end
end
And now by the normal difficult settings we are have cheap recipes!
Second try
Second try
2017-04-26 21_32_19.png (51.39 KiB) Viewed 8276 times
cheap-factorio-recipes_0.0.1.zip
The mod for 0.15
(1.07 KiB) Downloaded 248 times
If you find now recipes with liquids, it's have:
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.1.2 = 1
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.1.type = fluid
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.1.name = petroleum-gas
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.1.amount = 20
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.2.2 = 1
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.2.type = item
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.2.name = coal
1.542 Script data.lua:17: 7 / data.raw.recipe.plastic-bar.ingredients.2.amount = 1
Now you can add another exception and change .ingredients.1.amount = 20 to 1, and we don't need here .ingredients.1.2 = 1 anymore.
Last edited by darkfrei on Tue Feb 27, 2018 6:37 pm, edited 1 time in total.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Mod 0.15] Info mod

Post by darkfrei »

Version 0.1.0
The code was rewrite. Example:

Code: Select all

  1.715 Script @__info-mod__/info.lua:22:  / data.raw["simple-entity"]["red-desert-rock-big-01"].name = "red-desert-rock-big-01"
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Mod 0.15] Info mod

Post by darkfrei »

Version 0.1.1
Now digit index has right syntax

Code: Select all

   5.940 Script @__info-mod__/info.lua:29:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[1][1] = "firearm-magazine"
   5.940 Script @__info-mod__/info.lua:31:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[1][2] = 1
   5.940 Script @__info-mod__/info.lua:29:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[2][1] = "steel-plate"
   5.940 Script @__info-mod__/info.lua:31:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[2][2] = 1
   5.940 Script @__info-mod__/info.lua:29:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[3][1] = "copper-plate"
   5.940 Script @__info-mod__/info.lua:31:  / data.raw.recipe["piercing-rounds-magazine"].ingredients[3][2] = 5
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Mod 0.15] Info mod

Post by darkfrei »

Verson for 0.16
Attachments
info-mod_0.2.0.zip
For 0.16
(1.27 KiB) Downloaded 235 times
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Mod 0.16] Info mod

Post by darkfrei »

New version: Now sorted by prototype type.
Attachments
_info-mod_0.2.1.zip
For 0.16
(1.35 KiB) Downloaded 252 times
Post Reply

Return to “Development tools”