Prototype/ResourceEntity: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(→‎Example: updated to 0.17)
(Removed old prototype docs)
Tag: Replaced
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Basics ==
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/ResourceEntityPrototype.html https://lua-api.factorio.com/latest/prototypes/ResourceEntityPrototype.html]
Prototype type: '''resource'''


A mineable/gatherable entity. Extends [[Prototype/Entity]].
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
== Mandatory properties ==
This prototype inherits all the properties from [[Prototype/Entity]].
 
=== stages ===
'''Type''': [[Types/AnimationVariations]]
 
Entity's graphics, using a graphic sheet, with variation and depletion. At least one stage must be defined.
 
=== stage_counts ===
'''Type''': [[Types/table]] of [[Types/uint32]]
 
Number of stages the animation has.
 
== Optional properties ==
 
=== infinite ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
If the ore is infinitely minable, or if it will eventually run out of resource.
 
=== highlight ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
If the resource should be highlighted when holding a mining drill that can mine it (holding a pumpjack highlights crude-oil in the base game).
 
=== randomize_visual_position ===
'''Type''': [[Types/bool]]
 
'''Default''': true
 
=== minimum ===
'''Type''': [[Types/uint32]]
 
'''Default''': 0
 
Must be not 0 when <code>infinite = true</code>.
 
=== normal ===
'''Type''': [[Types/uint32]]
 
'''Default''': 1
 
Must be not 0 when <code>infinite = true</code>.
 
=== infinite_depletion_amount ===
'''Type''': [[Types/uint32]]
 
'''Default''': 1
 
''Every time an infinite-type resource "ticks" lower it's lowered by that amount.'' -- [https://forums.factorio.com/viewtopic.php?t=47093&p=271243#p271115 Rseding91]
 
=== category ===
'''Type''': [[Types/string]]
 
'''Default''': "basic-solid"
 
The category for the resource. Available categories in vanilla can be found here: [[Data.raw#resource-category]]
 
=== map_grid ===
'''Type''': [[Types/bool]]
 
'''Default''': true
 
=== resource_patch_search_radius ===
'''Type''': [[Types/uint32]]
 
'''Default''': 3
 
When hovering over this resource in the map view: How far to search for other resource patches of this type to display as one (summing amount, white outline).
 
=== stages_effect ===
'''Type''': [[Types/AnimationVariations]]
 
=== effect_animation_period ===
'''Type''': [[Types/float]]
 
'''Default''': 0.0
 
=== effect_animation_period_deviation ===
'''Type''': [[Types/float]]
 
'''Default''': 0.0
 
=== effect_darkness_multiplier ===
'''Type''': [[Types/float]]
 
'''Default''': 1.0
 
=== min_effect_alpha ===
'''Type''': [[Types/float]]
 
'''Default''': 0.0
 
=== max_effect_alpha ===
'''Type''': [[Types/float]]
 
'''Default''': 1.0
 
=== tree_removal_probability ===
'''Type''': [[Types/double]]
 
'''Default''': 0
 
Must be positive.
 
=== tree_removal_max_distance ===
'''Type''': [[Types/double]]
 
'''Default''': 0
 
Must be positive when <code>tree_removal_probability</code> is set.
 
== Example ==
<syntaxhighlight lang="lua">{
    type = "resource",
    name = "crude-oil",
    icon = "__base__/graphics/icons/crude-oil.png",
    icon_size = 32,
    flags = {"placeable-neutral"},
    category = "basic-fluid",
    order="a-b-a",
    infinite = true,
    highlight = true,
    minimum = 60000,
    normal = 300000,
    infinite_depletion_amount = 10,
    resource_patch_search_radius = 12,
    tree_removal_probability = 0.7,
    tree_removal_max_distance = 32 * 32,
    minable =
    {
      mining_time = 1,
      results =
      {
        {
          type = "fluid",
          name = "crude-oil",
          amount_min = 10,
          amount_max = 10,
          probability = 1
        }
      }
    },
    collision_box = {{ -1.4, -1.4}, {1.4, 1.4}},
    selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
    autoplace = resource_autoplace.resource_autoplace_settings{
      name = "crude-oil",
      order = "c", -- Other resources are "b"; oil won't get placed if something else is already there.
      base_density = 8.2,
      base_spots_per_km2 = 1.8,
      random_probability = 1/48,
      random_spot_size_minimum = 1,
      random_spot_size_maximum = 1, -- don't randomize spot size
      additional_richness = 220000, -- this increases the total everywhere, so base_density needs to be decreased to compensate
      has_starting_area_placement = false,
      resource_index = resource_autoplace.resource_indexes["crude-oil"],
      regular_rq_factor_multiplier = 1
    },
    stage_counts = {0},
    stages =
    {
      sheet =
      {
        filename = "__base__/graphics/entity/crude-oil/crude-oil.png",
        priority = "extra-high",
        width = 75,
        height = 61,
        frame_count = 4,
        variation_count = 1
      }
    },
    map_color = {r=0.78, g=0.2, b=0.77},
    map_grid = false
  }</syntaxhighlight>

Latest revision as of 14:33, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/prototypes/ResourceEntityPrototype.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.