0.17 Resource generation

Place to get help with not working mods / modding interface.
_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

0.17 Resource generation

Post by _npo6ka_ »

I'm trying to write my own generation of resources, but unfortunately I can not find detailed information about the generation of resources in version 0.17.
I took the BobOres mod as a basis, and got such a problem. Some ores are generated in the same place overlapping each other. The picture clearly shows that the center point of generation coincides with several ores or liquids.
IMG
Can you please tell me what generation parameters are responsible for the spread of ores relative to each other?

My file with "autoplace-control":

Code: Select all

--Garnierite
{
	type = "autoplace-control",
	name = "garnierite",
	richness = true,
	order = "b-g",
	category = "resource",
},
--Granitic Ore
{
	type = "autoplace-control",
	name = "granitic-ore",
	richness = true,
	order = "b-h",
	category = "resource",
},
Resource garnierite:

Code: Select all

{
	type = "resource",
	name = "garnierite",
	icon = "__xander-mod-v1__/graphics/item/material/resource/garnierite.png",
	icon_size = 32,
	flags = {"placeable-neutral"},
	category = "hard-solid",
	order = "a-b-b",
	minable =
	{
		mining_time = 3,
		result = "garnierite"--,
		--fluid_amount = 10,
		--required_fluid = "blasting-fluid"
	},
	collision_box = {{ -0.1, -0.1}, {0.1, 0.1}},
	selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
	autoplace = resource_autoplace.resource_autoplace_settings {
		name = "garnierite",
		order = "b",
		base_density = 7,
		has_starting_area_placement = false,
		resource_index = resource_autoplace.get_next_resource_index(),
		regular_rq_factor_multiplier = 1.1;
	},
	stage_counts = {10000, 5000, 2000, 1000, 500, 200, 100, 10},
	stages =
	{
		sheet =
		{
			filename = "__xander-mod-v1__/graphics/entity/resource/garnierite.png",
			priority = "extra-high",
			width = 64,
			height = 64,
			frame_count = 8,
			variation_count = 8,
			hr_version =
			{
				filename = "__xander-mod-v1__/graphics/entity/resource/garnierite-hr.png",
				priority = "extra-high",
				width = 128,
				height = 128,
				frame_count = 8,
				variation_count = 8,
				scale = 0.5
			}
		}
	},
	map_color = {r = 0.28, g = 0.7, b = 0.37}
},
Resoure granitic:

Code: Select all

{
	type = "resource",
	name = "granitic",
	icon = "__xander-mod-v1__/graphics/item/material/resource/granitic.png",
	icon_size = 32,
	flags = {"placeable-neutral"},
    category = "basic-solid",
	order = "a-b-b",
	minable =
	{
		mining_particle = "granitic-particle",
		mining_time = 1,
		result = "granitic-ore"
	},
	collision_box = {{ -0.1, -0.1}, {0.1, 0.1}},
	selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
	autoplace = resource_autoplace.resource_autoplace_settings {
		name = "granitic-ore",
		order = "b",
		base_density = 7,
		has_starting_area_placement = true,
		resource_index = resource_autoplace.get_next_resource_index(),
		regular_rq_factor_multiplier = 1.1,
		starting_rq_factor_multiplier = 1.2;
	},
	stage_counts = {10000, 5000, 2000, 1000, 500, 200, 100, 10},
	stages =
	{
		sheet =
		{
			filename = "__xander-mod-v1__/graphics/entity/resource/granitic.png",
			priority = "extra-high",
			width = 64,
			height = 64,
			frame_count = 8,
			variation_count = 8,
			hr_version =
			{
				filename = "__xander-mod-v1__/graphics/entity/resource/granitic-hr.png",
				priority = "extra-high",
				width = 128,
				height = 128,
				frame_count = 8,
				variation_count = 8,
				scale = 0.5
			}
		}
	},
	map_color = {r = 0.9, g = 0.9, b = 0.5}
},
User avatar
leadraven
Filter Inserter
Filter Inserter
Posts: 354
Joined: Fri Jan 18, 2019 7:23 pm
Contact:

Re: 0.17 Resource generation

Post by leadraven »

I've just started to learn modding, and as I know it depends on resource_index. But get_next_resource_index() is calculated separately 0-1-2-... for base and 0-1-2-... for mod. Resources with similar index are placed together. I don't know how to fix it, more experienced modder needed.
_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

Re: 0.17 Resource generation

Post by _npo6ka_ »

leadraven wrote: Mon Mar 18, 2019 8:51 am I've just started to learn modding, and as I know it depends on resource_index. But get_next_resource_index() is calculated separately 0-1-2-... for base and 0-1-2-... for mod. Resources with similar index are placed together. I don't know how to fix it, more experienced modder needed.
I checked your guess, however it seems that the get_next_resource_index () function works correctly. The first value that it gave and which is placed in my ore is 6. Further, this value is increased by 1

Code: Select all

   1.692 Script @__xander-mod-v1__/prototypes/entity/resource/resource.lua:78: index
   1.692 Script @__xander-mod-v1__/prototypes/entity/resource/resource.lua:79: 6
   1.692 Script @__xander-mod-v1__/prototypes/entity/resource/resource.lua:80: 7
   1.692 Script @__xander-mod-v1__/prototypes/entity/resource/resource.lua:81: 8
   1.692 Script @__xander-mod-v1__/prototypes/entity/resource/resource.lua:82: 9
AlienX
Fast Inserter
Fast Inserter
Posts: 105
Joined: Wed May 17, 2017 7:13 pm
Contact:

Re: 0.17 Resource generation

Post by AlienX »

I have had the same issue.
It looks like incrementing the number over the hard-coded amount of ores in the game doesnt make much difference until you go much higher.

I fixed the issue in my mod by doing this:

Code: Select all

resource_index = resource_autoplace.get_next_resource_index()+30,
However, this is a duct tape fix as if another mod uses your ID then you'll be back to square one again with ores over ores.

I believe that bobbingabout has fixed this a different way by completely defining the autoplace table manually, with his own dynamically-generated noise layer, but i have not had much time to look through his code to figure it out.
_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

Re: 0.17 Resource generation

Post by _npo6ka_ »

AlienX wrote: Tue Mar 19, 2019 12:07 am I have had the same issue.
It looks like incrementing the number over the hard-coded amount of ores in the game doesnt make much difference until you go much higher.

I fixed the issue in my mod by doing this:

Code: Select all

resource_index = resource_autoplace.get_next_resource_index()+30,
However, this is a duct tape fix as if another mod uses your ID then you'll be back to square one again with ores over ores.

I believe that bobbingabout has fixed this a different way by completely defining the autoplace table manually, with his own dynamically-generated noise layer, but i have not had much time to look through his code to figure it out.
I tried to do the same, but it did not help me in solving the problem. Ores were also generated at 1 point. I even tried to multiply and divide, but this did not solve my problem.

Code: Select all

resource_index = resource_autoplace.get_next_resource_index() * 16 + 16,
I tried to change orders in all possible places, it also did not solve the problem. I am at a dead end and do not know what else to try.

Bob has the same problem with generation and he recommended using the RSO mod. I will see how ore generation is implemented in this mode, and may be I can find useful information for myself.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: 0.17 Resource generation

Post by orzelek »

RSO generates ores by itself completely separate from noise euqations. So it has no issues like that. (It has some others.. but they are well hidden :D )
LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

Re: 0.17 Resource generation

Post by LeonSkills »

I was having the exact problem yesterday
I think it's because the spot-noise uses the same seeds for all resources. (seed0 = map seed, seed1 = 100), and doesn't make use of the resource name/order to seed the generation, so all spots will be on the same locations for each resource.

What I did was copy over the whole resource-autoplace file (Where the resource_autoplace_settings() is called, demo-resource-autoplace.lua? No access to the game files atm) over into my own mod directory
And changed the
local seed1 = 100
to local seed1 = params.seed or 100

I think it was line 58 on 0.17.16

And call that file instead of the base one.

Then give a different seed as a parameter to each resource_autoplace_settings{}

Would be nice if we can actually input the seed in that file ourself as a parameter, rather than have it always be 100.
User avatar
leadraven
Filter Inserter
Filter Inserter
Posts: 354
Joined: Fri Jan 18, 2019 7:23 pm
Contact:

Re: 0.17 Resource generation

Post by leadraven »

LeonSkills wrote: Fri Mar 22, 2019 1:26 pm I think it's because the spot-noise uses the same seeds for all resources. (seed0 = map seed, seed1 = 100), and doesn't make use of the resource name/order to seed the generation, so all spots will be on the same locations for each resource.
Actually, resource_autoplace_settings uses id in some line like "ignore_bits( id ) ". And id somehow influences result. But in very limited way.
B_head
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Mar 26, 2019 3:46 pm
Contact:

Re: 0.17 Resource generation

Post by B_head »

I created a mod to make it easy to add resources.
Please try it! :D
https://mods.factorio.com/mod/resource_autoplace_kaizen
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: 0.17 Resource generation

Post by Arch666Angel »

There are several variable that needs to change to adapt to a changing environment e.g. mods:
The base_index set per resource, the starting area amount of resource and the total amount of resources, all set in the autoplace-functions and only partially exposed.
That's the main reason people are writing their own versions of it, instead of using the base game one.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: 0.17 Resource generation

Post by darkfrei »

Arch666Angel wrote: Fri Mar 29, 2019 9:43 am That's the main reason people are writing their own versions of it, instead of using the base game one.
It's not possible to use vanilla functions in mods, autoplacement function is local :(
Post Reply

Return to “Modding help”