Page 1 of 1

Adding a new ressource to the game

Posted: Sat Apr 23, 2022 3:03 pm
by egooo
Hello,

I have added a new resource to my mod. I'm still working on the details. But the first thing I noticed is, that the icon is not shown in the map generation dialogue. Where is this icon taken from? I would've guessed it is the icon specified in 'icon' of the resource prototype.
Map generator.PNG
Map generator.PNG (70.63 KiB) Viewed 1471 times
A reduced example code is attached.

Re: Adding a new ressource to the game

Posted: Sun Apr 24, 2022 8:27 am
by Qon
The things listed there are the resources that are placed on the map. So my guess is that you didn't add an icon for the autoplace-control prototype, just for the resource itself. The oil patch doesn't have the liquid black oil drop as icon, right? It has the sprite of oil pool that you see on the ground. So look for how sprite/icon references are handled for the prototypes of the other resources.

So I just checked in my Factorio/data/base/prototypes/autoplace-controls.lua file
and see things like

Code: Select all

{
    type = "autoplace-control",
    name = "uranium-ore",
    localised_name = {"", "[entity=uranium-ore] ", {"entity-name.uranium-ore"}},
    richness = true,
    order = "b-e",
    category = "resource"
  },
  {
    type = "autoplace-control",
    name = "crude-oil",
    localised_name = {"", "[entity=crude-oil] ", {"entity-name.crude-oil"}},
    richness = true,
    order = "b-f",
    category = "resource"
  },
Look at localised_name. If you want an icon in the name, add an icon in the name. Add as many icons as you want. You can make it completely out of icons if you want.

Re: Adding a new ressource to the game

Posted: Sun Apr 24, 2022 9:36 am
by egooo
Wow, the icon is part of the name! Thanks, it's working now.

Re: Adding a new ressource to the game

Posted: Mon Apr 25, 2022 8:34 pm
by egooo
Is it possible to prevent grass on a resource? Grass growing on top of a sunflower don't look right ;-)

Re: Adding a new ressource to the game

Posted: Tue Apr 26, 2022 8:44 am
by egooo
It is not possible to change the render_layer of a resource, correct? Sunflower on top of grass would be nice.

So the only way is to have no grass placed on the resource field. I already set 'remove_decoratives' to true. But this doesns't seem to work either.

Any ideas?

Re: Adding a new ressource to the game

Posted: Tue Apr 26, 2022 2:03 pm
by DaveMcW
If you are comfortable with control.lua scripting, you could add a simple-entity on top of each resource with the render_layer you want.

You would have to handle on_chunk_generated and on_resource_depleted events.

Re: Adding a new ressource to the game

Posted: Wed Apr 27, 2022 1:21 pm
by egooo
Thanks for the idea! I'll take this in consideration, when starting to implement the control stage features. Do you thinks it is also possible to implement the richness based variations of the graphic?