Prototype/Entity: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Set prototype parent)
(Converted to SMW format)
Line 1: Line 1:
{{Prototype parent|PrototypeBase}}
{{Prototype parent|PrototypeBase}}
==Basics==
This type is abstract and cannot be created directly.
The common properties of all entities in the game.
The common properties of all entities in the game.
Entity is basically everything that can be on the map (except tiles).
Entity is basically everything that can be on the map (except tiles).
For in game script access to entity, take a look at [http://lua-api.factorio.com/latest/LuaEntity.html LuaEntity]
For in game script access to entity, take a look at [http://lua-api.factorio.com/latest/LuaEntity.html LuaEntity]
{{Prototype TOC|''abstract''}}


== Extensions ==
== Extensions ==
Line 129: Line 127:
Inherited from [[PrototypeBase]]. It is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.
Inherited from [[PrototypeBase]]. It is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.


=== icons, icon,  icon_size (IconSpecification) ===
{{Prototype property|icons, icon,  icon_size (IconSpecification)|[[Types/IconSpecification|IconSpecification]]}}
'''Type''': [[Types/IconSpecification]]
 
An icon is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.
An icon is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.


Line 138: Line 134:


== Optional properties ==
== Optional properties ==
=== collision_box ===
'''Type''': [[Types/BoundingBox]]
'''Default''': Empty={{0, 0}, {0, 0}} it means no collisions.


{{Prototype property|collision_box|[[Types/BoundingBox|BoundingBox]]|Empty=<nowiki>{{0, 0}, {0, 0}} means no collisions.</nowiki>|optional=true}}
Specification of the entity collision boundaries.
Specification of the entity collision boundaries.


Line 153: Line 146:
Note, that for buildings, it is custom to leave 0.1 wide border between the edge of the tile and the edge of the building, this lets the player move between the building and electric poles/inserters etc.
Note, that for buildings, it is custom to leave 0.1 wide border between the edge of the tile and the edge of the building, this lets the player move between the building and electric poles/inserters etc.


=== collision_mask ===
{{Prototype property|collision_mask|[[Types/CollisionMask|CollisionMask]]|<nowiki>{"item-layer", "object-layer", "player-layer", "water-tile"}</nowiki>|optional=true}}
'''type''': [[Types/CollisionMask]]
 
'''Default''': {"item-layer", "object-layer", "player-layer", "water-tile"}


Two entities can collide only if they share a layer from the collision mask.
Two entities can collide only if they share a layer from the collision mask.
Line 206: Line 196:
</div></div>
</div></div>


=== map_generator_bounding_box ===
{{Prototype property|map_generator_bounding_box|[[Types/BoundingBox|BoundingBox]]|The value of collision box.|optional=true}}
'''Type''': [[Types/BoundingBox]]
Used instead of the collision box during map generation. Allows space entities differently during map generation, for example if the box is bigger, the entities will be placed farther apart.
 
'''Default''': The value of collision box.
 
=== selection_box ===
'''Type''': [[Types/BoundingBox]]
 
'''Default''': Empty = {{0, 0}, {0, 0}}


{{Prototype property|selection_box|[[Types/BoundingBox|BoundingBox]]|<nowiki>Empty = {{0, 0}, {0, 0}}</nowiki>|optional=true}}
Specification of the entity selection area.
Specification of the entity selection area.
When empty  the entity will have no selection area (and thus is not selectable).
When empty  the entity will have no selection area (and thus is not selectable).
<syntaxhighlight lang="lua">selection_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>
<syntaxhighlight lang="lua">selection_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>
The selection box is usualy a little bit bigger than the collision box, for tilable entities (like buildings) it should match the tile size of the building.
The selection box is usually a little bit bigger than the collision box, for tilable entities (like buildings) it should match the tile size of the building.
 
=== drawing_box ===
'''Type''': [[Types/BoundingBox]]
 
'''Default''': Empty = {{0, 0}, {0, 0}} (selection_box is used instead)


{{Prototype property|drawing_box|[[Types/BoundingBox|BoundingBox]]|<nowiki>Empty = {{0, 0}, {0, 0}} (selection_box is used instead)</nowiki>|optional=true}}
Specification of space needed to see the whole entity.  
Specification of space needed to see the whole entity.  


Line 231: Line 211:
<syntaxhighlight lang="lua">drawing_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>
<syntaxhighlight lang="lua">drawing_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>


=== sticker_box ===
{{Prototype property|sticker_box|[[Types/BoundingBox|BoundingBox]]|The value of collision box.|optional=true}}
'''Type''': [[Types/BoundingBox]]
 
'''Default''': The value of collision box.
 
Used to set the area of the entity that can have stickers on it, currently only used for units to specify the area where the green slow down stickers can appear.
Used to set the area of the entity that can have stickers on it, currently only used for units to specify the area where the green slow down stickers can appear.
It is optional and the collision box is used when not specified.
It is optional and the collision box is used when not specified.
<syntaxhighlight lang="lua">sticker_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>
<syntaxhighlight lang="lua">sticker_box = {{-0.5, -0.5}, {0.5, 0.5}}</syntaxhighlight>


=== hit_visualization_box ===
{{Prototype property|hit_visualization_box|[[Types/BoundingBox|BoundingBox]]|<nowiki>Empty = {{0, 0}, {0, 0}}</nowiki>|optional=true}}
'''Type''': [[Types/BoundingBox]]
Where beams should hit the entity. Useful if the bounding box only covers part of the entity (e.g. feet of the character) and beams only hitting there would look weird.
 
'''Default''': Empty = {{0, 0}, {0, 0}}
 
=== flags ===
'''Type''': [[Types/EntityPrototypeFlags]]
 
'''Default''': nil
 
=== minable ===
'''Type''': [[Types/MinableProperties]]


'''Default''': {minable = false, mining_time = 0}
{{Prototype property|flags|[[Types/EntityPrototypeFlags|EntityPrototypeFlags]]|optional=true}}


=== subgroup ===
{{Prototype property|minable|[[Types/MinableProperties|MinableProperties]]|<nowiki>{minable = false, mining_time = 0}</nowiki>|optional=true}}
'''Type''': [[Types/string]]


{{Prototype property|subgroup|[[Types/string|string]]|optional=true}}
The name of the subgroup this entity should be sorted into in the map editor building selection.
The name of the subgroup this entity should be sorted into in the map editor building selection.


=== allow_copy_paste ===
{{Prototype property|allow_copy_paste|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/bool]]
 
'''Default''': true
 
=== selectable_in_game ===
'''Type''': [[Types/bool]]
 
'''Default''': true
 
=== selection_priority ===
'''Type''': [[Types/uint8]]


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


{{Prototype property|selection_priority|[[Types/uint8|uint8]]|50|optional=true}}
The entity with the higher number is selectable before the entity with the lower number.
The entity with the higher number is selectable before the entity with the lower number.


=== emissions_per_second ===
{{Prototype property|emissions_per_second|[[Types/double|double]]|0|optional=true}}
'''Type''': [[Types/double]]
 
'''Default''': 0
 
Amount of emissions created (positive number) or cleaned (negative number) every second by the entity.
Amount of emissions created (positive number) or cleaned (negative number) every second by the entity.
This is passive, and it is independent concept of the emissions of machines, these are created actively depending on the power consumption.
This is passive, and it is independent concept of the emissions of machines, these are created actively depending on the power consumption.
Line 288: Line 240:
<syntaxhighlight lang="lua">emissions_per_second = -0.0005 -- cleaning effect of big tree</syntaxhighlight>
<syntaxhighlight lang="lua">emissions_per_second = -0.0005 -- cleaning effect of big tree</syntaxhighlight>


=== emissions_per_tick ===
{{Prototype property|emissions_per_tick|[[Types/double|double]]|0|optional=true}}
'''Type''': [[Types/double]]
 
'''Default''': 0
 
[[#emissions_per_second]], but per tick. Deprecated.
[[#emissions_per_second]], but per tick. Deprecated.


=== shooting_cursor_size ===
{{Prototype property|shooting_cursor_size|[[Types/double|double]]|optional=true}}
'''Type''': [[Types/double]]
 
The cursor size used when shooting at this entity.
The cursor size used when shooting at this entity.


=== created_smoke ===
{{Prototype property|created_smoke|[[Types/CreateTrivialSmokeEffectItem|CreateTrivialSmokeEffectItem]]|optional=true}}
'''Type''': [[Types/CreateTrivialSmokeEffectItem]]
 
The smoke that is shown when the entity is placed. Default is using the "smoke-building" smoke.
The smoke that is shown when the entity is placed. Default is using the "smoke-building" smoke.


=== autoplace ===
{{Prototype property|autoplace|[[Types/AutoplaceSpecification|AutoplaceSpecification]]|nil (entity is not autoplacable)|optional=true}}
'''Type''': [[Types/AutoplaceSpecification]]
 
'''Default''': nil (entity is not autoplacable)
 
Used to specify the rules for placing this entity during map generation.
Used to specify the rules for placing this entity during map generation.


=== working_sound ===
{{Prototype property|working_sound|[[Types/WorkingSound|WorkingSound]]|optional=true}}
'''Type''': [[Types/WorkingSound]]
 
'''Default''': nil
 
Will also work on entities that don't actually do work.
Will also work on entities that don't actually do work.


=== created_effect ===
{{Prototype property|created_effect|[[Types/Trigger|Trigger]]|optional=true}}
'''Type''': [[Types/Trigger]]
 
'''Default''': nil
 
The effect/trigger that happens when the entity is placed.
The effect/trigger that happens when the entity is placed.


=== build_sound ===
{{Prototype property|build_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/Sound]]


=== mined_sound ===
{{Prototype property|mined_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/Sound]]


=== vehicle_impact_sound ===
{{Prototype property|vehicle_impact_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/Sound]]


=== open_sound ===
{{Prototype property|open_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/Sound]]


=== close_sound ===
{{Prototype property|close_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/Sound]]


=== build_base_evolution_requirement ===
{{Prototype property|build_base_evolution_requirement|[[Types/double|double]]|0|optional=true}}
'''Type''': [[Types/double]]


'''Default''': 0
{{Prototype property|alert_icon_shift|[[Types/vector|vector]]|optional=true}}


=== alert_icon_shift ===
{{Prototype property|alert_icon_scale|[[Types/float|float]]|optional=true}}
'''Type''': [[Types/vector]]
 
=== alert_icon_scale ===
'''Type''': [[Types/float]]
 
=== fast_replaceable_group ===
'''Type''': [[Types/string]]


{{Prototype property|fast_replaceable_group|[[Types/string|string]]|optional=true}}
This allows you to replace an entity that's already placed, with a different one in your inventory. For example, replacing a burner drill with an electric drill.
This allows you to replace an entity that's already placed, with a different one in your inventory. For example, replacing a burner drill with an electric drill.


Line 376: Line 296:
   "steam-engine"
   "steam-engine"


=== next_upgrade ===
{{Prototype property|next_upgrade|[[Types/string|string]]|optional=true}}
'''Type''': [[Types/string]]
Name of the entity that will be automatically selected as the upgrade of this entity when using the [[upgrade planner]] without configuration.
 
Name of the entity that will be automatically selected as the upgrade of this entity when using the [[upgrade planner]].
 
=== placeable_by ===
'''Type''': [[Types/ItemToPlace]] or [[Types/table]] of [[Types/ItemToPlace]]


{{Prototype property|placeable_by|[[Types/ItemToPlace|ItemToPlace]] or [[Types/table|table]] of [[Types/ItemToPlace|ItemToPlace]]|optional=true}}
Item that when placed creates this entity. Also determines which item is picked when "Q" (smart pipette) is used on the entity.
Item that when placed creates this entity. Also determines which item is picked when "Q" (smart pipette) is used on the entity.


=== remains_when_mined ===
{{Prototype property|remains_when_mined|[[Types/string|string]] or [[Types/table|table]] of [[Types/string|string]]|optional=true}}
'''Type''': [[Types/string]] or [[Types/table]] of [[Types/string]]
 
The entity that remains when this one is mined, deconstructed or fast-replaced. The entity wont actually be spawned if it would collide with the entity that is in the process of being mined.
The entity that remains when this one is mined, deconstructed or fast-replaced. The entity wont actually be spawned if it would collide with the entity that is in the process of being mined.


=== additional_pastable_entities ===
{{Prototype property|additional_pastable_entities|[[Types/string|string]] or [[Types/table|table]] of [[Types/string|string]]|optional=true}}
'''Type''': [[Types/string]] or [[Types/table]] of [[Types/string]]
 
Entities this entity prototype can be pasted on to in addition to the standard supported types.
Entities this entity prototype can be pasted on to in addition to the standard supported types.
This is used to allow copying between types that aren't compatible on the C++ code side.
This is used to allow copying between types that aren't compatible on the C++ code side.


=== tile_width ===
{{Prototype property|tile_width|[[Types/uint32|uint32]]|calculated by the collision box width rounded up.|optional=true}}
'''Type''': [[Types/uint32]]
 
'''Default''': calculated by the collision box width rounded up.
 
Used to determine how the center of the entity should be positioned when building (unless the offgrid [[Types/EntityPrototypeFlags|flag]] is specified).
Used to determine how the center of the entity should be positioned when building (unless the offgrid [[Types/EntityPrototypeFlags|flag]] is specified).
When the tile width is odd, the center will be in the center of the tile, when it is even, the center is on the tile transition.
When the tile width is odd, the center will be in the center of the tile, when it is even, the center is on the tile transition.


=== tile_height ===
{{Prototype property|tile_height|[[Types/uint32|uint32]]|calculated by the collision box height rounded up.|optional=true}}
'''Type''': [[Types/uint32]]
 
'''Default''': calculated by the collision box height rounded up.


=== map_color ===
{{Prototype property|map_color|[[Types/Color|Color]]|optional=true}}
'''Type''': [[Types/Color]]


=== friendly_map_color ===
{{Prototype property|friendly_map_color|[[Types/Color|Color]]|optional=true}}
'''Type''': [[Types/Color]]


=== enemy_map_color ===
{{Prototype property|enemy_map_color|[[Types/Color|Color]]|optional=true}}
'''Type''': [[Types/Color]]


== Example ==
== Example ==

Revision as of 11:27, 28 July 2019

Template:Prototype parent The common properties of all entities in the game. Entity is basically everything that can be on the map (except tiles). For in game script access to entity, take a look at LuaEntity

Template:Prototype TOC

Extensions

Mandatory properties

Inherits all properties from PrototypeBase.

order

See PrototypeBase#order

Inherited from PrototypeBase. It is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.

Template:Prototype property An icon is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.

The icon will be used in the editor building selection and the bonus gui.

icon = "__base__/graphics/icons/wooden-chest.png"

Optional properties

Template:Prototype property Specification of the entity collision boundaries.

Empty collision box is used for smoke, projectiles, particles, explosions etc.

collision_box = {{-0.4, -0.4}, {0.4, 0.4}}

The {0,0} coordinate in the collision box will match the entity position.

It should be near the center of the collision box, to keep correct entity drawing order. It must include the {0,0} coordinate.

Note, that for buildings, it is custom to leave 0.1 wide border between the edge of the tile and the edge of the building, this lets the player move between the building and electric poles/inserters etc.

Template:Prototype property

Two entities can collide only if they share a layer from the collision mask.

NOTE: Some entity types have their own default that differs from the above default. They are listed here:

Template:Prototype property Used instead of the collision box during map generation. Allows space entities differently during map generation, for example if the box is bigger, the entities will be placed farther apart.

Template:Prototype property Specification of the entity selection area. When empty the entity will have no selection area (and thus is not selectable).

selection_box = {{-0.5, -0.5}, {0.5, 0.5}}

The selection box is usually a little bit bigger than the collision box, for tilable entities (like buildings) it should match the tile size of the building.

Template:Prototype property Specification of space needed to see the whole entity.

This is used to calculate the correct zoom and positioning in the entity info gui.

drawing_box = {{-0.5, -0.5}, {0.5, 0.5}}

Template:Prototype property Used to set the area of the entity that can have stickers on it, currently only used for units to specify the area where the green slow down stickers can appear. It is optional and the collision box is used when not specified.

sticker_box = {{-0.5, -0.5}, {0.5, 0.5}}

Template:Prototype property Where beams should hit the entity. Useful if the bounding box only covers part of the entity (e.g. feet of the character) and beams only hitting there would look weird.

Template:Prototype property

Template:Prototype property

Template:Prototype property The name of the subgroup this entity should be sorted into in the map editor building selection.

Template:Prototype property

Template:Prototype property

Template:Prototype property The entity with the higher number is selectable before the entity with the lower number.

Template:Prototype property Amount of emissions created (positive number) or cleaned (negative number) every second by the entity. This is passive, and it is independent concept of the emissions of machines, these are created actively depending on the power consumption. Currently used just for trees.

emissions_per_second = -0.0005 -- cleaning effect of big tree

Template:Prototype property #emissions_per_second, but per tick. Deprecated.

Template:Prototype property The cursor size used when shooting at this entity.

Template:Prototype property The smoke that is shown when the entity is placed. Default is using the "smoke-building" smoke.

Template:Prototype property Used to specify the rules for placing this entity during map generation.

Template:Prototype property Will also work on entities that don't actually do work.

Template:Prototype property The effect/trigger that happens when the entity is placed.

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property This allows you to replace an entity that's already placed, with a different one in your inventory. For example, replacing a burner drill with an electric drill.

This is simply a string, so any string can be used here. The entity that should be replaced simply has to use the same string here.

The ones the game uses are:

 "underground-belt"
 "loader"
 "splitter"
 "transport-belt"
 "assembling-machine"
 "container"
 "long-handed-inserter"
 "inserter"
 "wall"
 "rail-signal"
 "container"
 "pipe"
 "furnace"
 "steam-engine"

Template:Prototype property Name of the entity that will be automatically selected as the upgrade of this entity when using the upgrade planner without configuration.

Template:Prototype property Item that when placed creates this entity. Also determines which item is picked when "Q" (smart pipette) is used on the entity.

Template:Prototype property The entity that remains when this one is mined, deconstructed or fast-replaced. The entity wont actually be spawned if it would collide with the entity that is in the process of being mined.

Template:Prototype property Entities this entity prototype can be pasted on to in addition to the standard supported types. This is used to allow copying between types that aren't compatible on the C++ code side.

Template:Prototype property Used to determine how the center of the entity should be positioned when building (unless the offgrid flag is specified). When the tile width is odd, the center will be in the center of the tile, when it is even, the center is on the tile transition.

Template:Prototype property

Template:Prototype property

Template:Prototype property

Template:Prototype property

Example

{
    type = "container",
    name = "wooden-chest",
    icon = "__base__/graphics/icons/wooden-chest.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {mining_time = 1, result = "wooden-chest"},
    max_health = 100,
    corpse = "small-remnants",
    collision_box = {{-0.35, -0.35}, {0.35, 0.35}},
    fast_replaceable_group = "container",
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    inventory_size = 16,
    open_sound = { filename = "__base__/sound/wooden-chest-open.ogg" },
    close_sound = { filename = "__base__/sound/wooden-chest-close.ogg" },
    vehicle_impact_sound =  { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
    picture =
    {
      filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
      priority = "extra-high",
      width = 46,
      height = 33,
      shift = {0.25, 0.015625}
    },
    circuit_wire_connection_point =
    {
      shadow =
      {
        red = {0.734375, 0.453125},
        green = {0.609375, 0.515625},
      },
      wire =
      {
        red = {0.40625, 0.21875},
        green = {0.40625, 0.375},
      }
    },
    circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.15625}, nil, 18),
    circuit_wire_max_distance = 9
  }