Prototype/ResourceEntity: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (→‎category: typo)
(0.18.31: hr mining drill)
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Basics ==
{{Prototype parent|Prototype/Entity}}
A mineable/gatherable entity. An extension of [[Prototype/Entity]].
A mineable/gatherable entity.
== Properties ==
=== infinite ===
'''Type''': [[Types/bool]]


'''Default''': false
{{Prototype TOC|resource}}


If the ore is infinitely minable, or if it will eventually run out of resource.
== Mandatory properties ==
=== highlight ===
This prototype inherits all the properties from [[Prototype/Entity]].
'''Type''': [[Types/bool]]


'''Default''': false
{{Prototype property|stages|[[Types/AnimationVariations|AnimationVariations]]}}
Entity's graphics, using a graphic sheet, with variation and depletion. At least one stage must be defined.


If the ore appears on the map overview separately from large ore veins, or not.
{{Prototype property|stage_counts|[[Types/table|table]] of [[Types/uint32|uint32]]}}
Number of stages the animation has.


=== minimum ===
== Optional properties ==
'''Type''': [[Types/uint]]


'''Default''': 0
{{Prototype property|infinite|[[Types/bool|bool]]|false|optional=true}}
If the ore is infinitely minable, or if it will eventually run out of resource.


=== normal ===
{{Prototype property|highlight|[[Types/bool|bool]]|false|optional=true}}
'''Type''': [[Types/uint]]
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).


'''Default''': 1
{{Prototype property|randomize_visual_position|[[Types/bool|bool]]|true|optional=true}}


=== infinite_depletion_amount ===
{{Prototype property|map_grid|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/uint]]
Whether the resource should have a grid pattern on the map instead of a solid map color.


'''Default''': 1
{{Prototype property|minimum|[[Types/uint32|uint32]]|0|optional=true}}
Must be not 0 when <code>infinite = true</code>.


{{Prototype property|normal|[[Types/uint32|uint32]]|1|optional=true}}
Must be not 0 when <code>infinite = true</code>.
{{Prototype property|infinite_depletion_amount|[[Types/uint32|uint32]]|1|optional=true}}
''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]
''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]


=== stages ===
{{Prototype property|resource_patch_search_radius|[[Types/uint32|uint32]]|3|optional=true}}
'''Type''': [[Types/AnimationVariations]]
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).
 
Entity's graphics, using a graphic sheet, with variation and depletion.
 
=== category ===
'''Type''': [[Types/string]]
 
'''Default''': basic-solid


{{Prototype property|category|[[Types/string|string]]|"basic-solid"|optional=true}}
The category for the resource. Available categories in vanilla can be found here: [[Data.raw#resource-category]]
The category for the resource. Available categories in vanilla can be found here: [[Data.raw#resource-category]]


=== map_grid ===
{{Prototype property|walking_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/bool]]
Sound played when the player walks over this resource.


'''Default''': true
{{Prototype property|stages_effect|[[Types/AnimationVariations|AnimationVariations]]|optional=true}}
An effect that can be overlayed above the normal ore graphics. Used in the base game to make [[uranium ore]] glow.


=== resource_patch_search_radius ===
{{Prototype property|effect_animation_period|[[Types/float|float]]|0.0|optional=true}}
'''Type''': [[Types/uint]]
How long it takes <code>stages_effect</code> to go from <code>min_effect_alpha</code> to <code>max_effect_alpha</code>.


'''Default''': 3
{{Prototype property|effect_animation_period_deviation|[[Types/float|float]]|0.0|optional=true}}
How much <code>effect_animation_period</code> can deviate from its original value. Used to make the stages effect alpha change look less uniform.


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).
{{Prototype property|effect_darkness_multiplier|[[Types/float|float]]|1.0|optional=true}}
How much the surface darkness should affect the alpha of <code>stages_effect</code>.


=== stages_effect ===
{{Prototype property|min_effect_alpha|[[Types/float|float]]|0.0|optional=true}}
'''Type''': [[Types/AnimationVariations]]
Minimal alpha value of <code>stages_effect</code>.


=== effect_animation_period ===
{{Prototype property|max_effect_alpha|[[Types/float|float]]|1.0|optional=true}}
'''Type''': [[Types/float]]
Maximal alpha value of <code>stages_effect</code>.


'''Default''': 0.0
{{Prototype property|tree_removal_probability|[[Types/double|double]]|0|optional=true}}
=== effect_animation_period_deviation ===
Must be positive.
'''Type''': [[Types/float]]


'''Default''': 0.0
{{Prototype property|tree_removal_max_distance|[[Types/double|double]]|0|optional=true}}
=== effect_darkness_multiplier ===
Must be positive when <code>tree_removal_probability</code> is set.
'''Type''': [[Types/float]]


'''Default''': 1.0
{{Prototype property|mining_visualisation_tint|[[Types/Color|Color]]|unset|optional=true}}
=== min_effect_alpha ===
Defaults to the resources map color if left unset and map color is set, otherwise defaults to white if left unset.
'''Type''': [[Types/float]]
 
'''Default''': 0.0
=== max_effect_alpha ===
'''Type''': [[Types/float]]
 
'''Default''': 1.0
=== tree_removal_probability ===
'''Type''': [[Types/double]]
 
'''Default''': 0
=== tree_removal_max_distance ===
'''Type''': [[Types/double]]
 
'''Default''': 0
 
=== stage_counts ===
'''Type''': [[Types/table]] of [[Types/uint]]
 
Number of stages the animation has.


== Example ==
== Example ==
<syntaxhighlight lang="lua">{
<syntaxhighlight lang="lua">{
  {
    type = "resource",
  type = "resource",
    name = "crude-oil",
  name = "crude-oil",
    icon = "__base__/graphics/icons/crude-oil.png",
  icon = "__base__/graphics/icons/crude-oil.png",
    icon_size = 32,
  flags = {"placeable-neutral"},
    flags = {"placeable-neutral"},
  category = "basic-fluid",
    category = "basic-fluid",
  order="a-b-a",
    order="a-b-a",
  infinite = true,
    infinite = true,
  highlight = true,
    highlight = true,
  minimum = 60000,
    minimum = 60000,
  normal = 300000,
    normal = 300000,
  infinite_depletion_amount = 10,
    infinite_depletion_amount = 10,
  resource_patch_search_radius = 12,
    resource_patch_search_radius = 12,
  minable =
     tree_removal_probability = 0.7,
  {
     tree_removal_max_distance = 32 * 32,
     hardness = 1,
     minable =
     mining_time = 1,
     results =
     {
     {
      mining_time = 1,
      results =
       {
       {
         type = "fluid",
         {
        name = "crude-oil",
          type = "fluid",
        amount_min = 10,
          name = "crude-oil",
        amount_max = 10,
          amount_min = 10,
        probability = 1
          amount_max = 10,
          probability = 1
        }
       }
       }
     }
     },
  },
    collision_box = {{ -1.4, -1.4}, {1.4, 1.4}},
  collision_box = {{ -1.4, -1.4}, {1.4, 1.4}},
    selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
  selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
    autoplace = resource_autoplace.resource_autoplace_settings{
  autoplace =
      name = "crude-oil",
  {
      order = "c", -- Other resources are "b"; oil won't get placed if something else is already there.
    control = "crude-oil",
      base_density = 8.2,
    sharpness = 0.99,
      base_spots_per_km2 = 1.8,
    max_probability = 0.02,
      random_probability = 1/48,
    richness_base = 240000,
      random_spot_size_minimum = 1,
    richness_multiplier = 300000,
      random_spot_size_maximum = 1, -- don't randomize spot size
    richness_multiplier_distance_bonus = 3000,
      additional_richness = 220000, -- this increases the total everywhere, so base_density needs to be decreased to compensate
    coverage = 0.02, -- Cover on average 2% of surface area.
      has_starting_area_placement = false,
     peaks =
      resource_index = resource_autoplace.resource_indexes["crude-oil"],
      regular_rq_factor_multiplier = 1
    },
    stage_counts = {0},
     stages =
     {
     {
      sheet =
       {
       {
         noise_layer = "crude-oil",
         filename = "__base__/graphics/entity/crude-oil/crude-oil.png",
         noise_octaves_difference = -1,
         priority = "extra-high",
         noise_persistence = 0.4,
        width = 75,
        height = 61,
         frame_count = 4,
        variation_count = 1
       }
       }
     }
     },
  },
     map_color = {r=0.78, g=0.2, b=0.77},
  stage_counts = {0},
    map_grid = false
  stages =
  }</syntaxhighlight>
  {
     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>

Revision as of 11:23, 22 July 2020

Prototype definitions » PrototypeBase » Prototype/Entity » Prototype/ResourceEntity


A mineable/gatherable entity.


Prototype/ResourceEntity — resource
stage_counts::table of uint32
stages::AnimationVariations
category::string (optional)
effect_animation_period::float (optional)
effect_animation_period_deviation::float (optional)
effect_darkness_multiplier::float (optional)
highlight::bool (optional)
infinite::bool (optional)
infinite_depletion_amount::uint32 (optional)
map_grid::bool (optional)
max_effect_alpha::float (optional)
min_effect_alpha::float (optional)
minimum::uint32 (optional)
mining_visualisation_tint::Color (optional)
normal::uint32 (optional)
randomize_visual_position::bool (optional)
resource_patch_search_radius::uint32 (optional)
stages_effect::AnimationVariations (optional)
tree_removal_max_distance::double (optional)
tree_removal_probability::double (optional)
walking_sound::Sound (optional)
Inherited from Prototype/Entity
icons, icon, icon_size (IconSpecification)::IconSpecification
additional_pastable_entities::table of string (optional)
alert_icon_scale::float (optional)
alert_icon_shift::vector (optional)
allow_copy_paste::bool (optional)
autoplace::AutoplaceSpecification (optional)
build_base_evolution_requirement::double (optional)
build_grid_size::uint8 (optional)
build_sound::Sound (optional)
close_sound::Sound (optional)
collision_box::BoundingBox (optional)
collision_mask::CollisionMask (optional)
created_effect::Trigger (optional)
created_smoke::CreateTrivialSmokeEffectItem (optional)
drawing_box::BoundingBox (optional)
emissions_per_second::double (optional)
enemy_map_color::Color (optional)
fast_replaceable_group::string (optional)
flags::EntityPrototypeFlags (optional)
friendly_map_color::Color (optional)
hit_visualization_box::BoundingBox (optional)
map_color::Color (optional)
map_generator_bounding_box::BoundingBox (optional)
minable::MinableProperties (optional)
mined_sound::Sound (optional)
mining_sound::Sound (optional)
next_upgrade::string (optional)
open_sound::Sound (optional)
placeable_by::ItemToPlace or table of ItemToPlace (optional)
protected_from_tile_building::bool (optional)
radius_visualisation_specification::RadiusVisualisationSpecification (optional)
remains_when_mined::string or table of string (optional)
remove_decoratives::string (optional)
rotated_sound::Sound (optional)
selectable_in_game::bool (optional)
selection_box::BoundingBox (optional)
selection_priority::uint8 (optional)
shooting_cursor_size::double (optional)
sticker_box::BoundingBox (optional)
subgroup::string (optional)
tile_height::uint32 (optional)
tile_width::uint32 (optional)
trigger_target_mask::TriggerTargetMask (optional)
vehicle_impact_sound::Sound (optional)
water_reflection::WaterReflectionDefinition (optional)
working_sound::WorkingSound (optional)
Inherited from PrototypeBase
name::string
type::string
localised_description::LocalisedString (optional)
localised_name::LocalisedString (optional)
order::Order (optional)

Mandatory properties

This prototype inherits all the properties from Prototype/Entity.

stages

Type: AnimationVariations
Entity's graphics, using a graphic sheet, with variation and depletion. At least one stage must be defined.

stage_counts

Type: table of uint32
Number of stages the animation has.

Optional properties

infinite

Type: bool
Default: false
If the ore is infinitely minable, or if it will eventually run out of resource.

highlight

Type: 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: bool
Default: true

map_grid

Type: bool
Default: true
Whether the resource should have a grid pattern on the map instead of a solid map color.

minimum

Type: uint32
Default: 0
Must be not 0 when infinite = true.

normal

Type: uint32
Default: 1
Must be not 0 when infinite = true.

infinite_depletion_amount

Type: uint32
Default: 1
Every time an infinite-type resource "ticks" lower it's lowered by that amount. -- Rseding91

resource_patch_search_radius

Type: 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).

category

Type: string
Default: "basic-solid"
The category for the resource. Available categories in vanilla can be found here: Data.raw#resource-category

walking_sound

Type: Sound
Sound played when the player walks over this resource.

stages_effect

Type: AnimationVariations
An effect that can be overlayed above the normal ore graphics. Used in the base game to make uranium ore glow.

effect_animation_period

Type: float
Default: 0.0
How long it takes stages_effect to go from min_effect_alpha to max_effect_alpha.

effect_animation_period_deviation

Type: float
Default: 0.0
How much effect_animation_period can deviate from its original value. Used to make the stages effect alpha change look less uniform.

effect_darkness_multiplier

Type: float
Default: 1.0
How much the surface darkness should affect the alpha of stages_effect.

min_effect_alpha

Type: float
Default: 0.0
Minimal alpha value of stages_effect.

max_effect_alpha

Type: float
Default: 1.0
Maximal alpha value of stages_effect.

tree_removal_probability

Type: double
Default: 0
Must be positive.

tree_removal_max_distance

Type: double
Default: 0
Must be positive when tree_removal_probability is set.

mining_visualisation_tint

Type: Color
Default: unset
Defaults to the resources map color if left unset and map color is set, otherwise defaults to white if left unset.

Example

{
    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
  }