Prototype/Entity: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
(Removed old prototype docs)
Tag: Replaced
 
(98 intermediate revisions by 16 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/EntityPrototype.html https://lua-api.factorio.com/latest/prototypes/EntityPrototype.html]
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 [[Lua/Entity]]
== Extensions ==
*[[Prototype/EntityWithHealth]]
**[[Prototype/Character]]
**[[Prototype/Unit]]
**[[Prototype/PipeConnectable]]
**[[Prototype/Car]]
**[[Prototype/Market]]
*[[Prototype/Resource]]


== Properties ==
</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>
=== type ===
'''Type''': [[Types/string]]
 
Specification of the [[Prototypes/EntityPrototypeTypes|type]] of the prototype.
 
=== name ===
'''Type''': [[Types/string]]
 
Unique identification of the prototype.
 
=== collision_box ===
'''Type: [[Types/AABBbox]]
 
'''Default''': Empty={{0, 0}, {0, 0}} it means no collisions.
 
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.
 
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. and prevents stucked items on transport belt in some special casese (curves around the corner etc).
 
=== selection_box ===
'''Type''': [[Types/AABBbox]]
 
'''Default''': Empty = {{0, 0}, {0, 0}}
 
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 usualy 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/AABBbox]]
 
'''Default''': The value of selection_box
 
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}}
 
=== sticker_box ===
'''Type''': [[Types/AABBbox]]
 
'''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.
It is optional and the collision box is used when not specified.
  sticker_box = {{-0.5, -0.5}, {0.5, 0.5}}
 
=== weight ===
'''Type''': [[Types/float]]
 
'''Default''': 1
 
Weight of the entity used for physics calculation when car hits something.
    weight = 5.7
 
=== flags ===
'''Type''': [[Types/EntityPrototypeFlags]]
 
=== minable ===
'''Type''': [[Types/MinableProperties]]
 
=== emissions_per_tick ===
'''Type''': [[Types/double]]
 
Amount of emissions created (positive number) or cleaned (negative number) every tick 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_tick = -0.0005 -- cleaning effect of big tree
 
=== fast_replacable_group ===
'''Type''': [[Types/string]]
 
=== tile_width ===
'''Type''': [[Types/unsigned]]
 
'''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).
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 ===
'''Type''': [[Types/unsigned]]
 
'''Default''': calculated by the collision box height rounded up.
 
=== autoplace ===
'''Type''': [[Types/AutoplaceSpecification]]
 
== 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"},
      collision_box = {{-0.4, -0.4}, {0.4, 0.4}},
      selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
      max_health = 50,
      corpse = "small-remnants",
      fast_replaceable_group = "container",
      inventory_size = 16,
      picture =
      {
        filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
        priority = "extra-high",
        width = 46,
        height = 33,
        shift = {0.3, 0}
      }
    }

Latest revision as of 14:32, 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/EntityPrototype.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.