How to make a resource only spawn on non-homeworld planets

Place to get help with not working mods / modding interface.
Post Reply
BubstyBoy
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Aug 15, 2023 3:24 pm
Contact:

How to make a resource only spawn on non-homeworld planets

Post by BubstyBoy »

Hi, I was wondering if anyone knew how to make a resource only spawn on planets and moons(and not homeworlds) when space exploration is enabled. I tried tapping into SE's universe.lua file during the data stage and adding my ore into default_resource_order, resource_word_rules.not_space, and resource_word_rules.not_homeworld, but it still appears in all those places. any ideas?

Natha
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: How to make a resource only spawn on non-homeworld planets

Post by Natha »

What you could do is to apply your resources's autoplace settings after surface creation:
- register on_surface_created
- call SE remote function `get_zone_from_surface_index` and to get the zone check if `is_homeworld` is false
- then apply map settings on this surface by adding your resource:

Code: Select all

mapgen.autoplace_settings.entity.settings.settings["your-resource"] = {frequency=1, size=1, richness=1}
if neccessary, add

Code: Select all

mapgen.property_expression_names["your-resource:richness"] = "your-noise-expression"
with a custom noise expression that reflects richness.

Post Reply

Return to “Modding help”