Prototype/CraftingMachine: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (formatting)
(Moved note on extremely fast machine speed from Types/EffectTypeLimitation to allowed_effects)
 
(36 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Basics ==
{{Prototype parent|Prototype/EntityWithOwner}}
The abstract basis of the assembling machines and furnaces. Contains the properties that both of them have.
The abstract basis of the assembling machines and furnaces. Contains the properties that both of them have.
Note that a crafting machine cannot be rotated unless it has at least one of the following: a fluid box, a heat energy source, a fluid energy source, or a non-square collision box. Crafting machines with non-square collision boxes can only be rotated before placement, not after.
{{Prototype TOC|''abstract''}}


== Extensions ==
== Extensions ==
Line 9: Line 13:


== Mandatory properties ==
== Mandatory properties ==
This prototype inherits all the properties from [[Prototype/EntityWithHealth]].
This prototype inherits all the properties from [[Prototype/EntityWithOwner]].
 
=== energy_usage ===
'''Type''': [[Types/Energy]]


{{Prototype property|energy_usage|[[Types/Energy|Energy]]}}
Sets how much energy this machine uses while crafting. Energy usage has to be positive.
Sets how much energy this machine uses while crafting. Energy usage has to be positive.


=== crafting_speed ===
{{Prototype property|crafting_speed|[[Types/double|double]]}}
'''Type''': [[Types/double]]
 
How fast this crafting machine can craft. 1 means that for example a 1 second long recipe take 1 second to craft. 0.5 means it takes 2 seconds, and 2 means it takes 0.5 seconds.
How fast this crafting machine can craft. 1 means that for example a 1 second long recipe take 1 second to craft. 0.5 means it takes 2 seconds, and 2 means it takes 0.5 seconds.


Crafting speed has to be positive.
Crafting speed has to be positive.


=== crafting_categories ===
{{Prototype property|crafting_categories|[[Types/table|table]] of [[Types/string|string]]s}}
'''Type''': [[Types/table]] of [[Types/string]]s
 
A list of [[Prototype/RecipeCategory|recipe categories]] this crafting machine can use.
A list of [[Prototype/RecipeCategory|recipe categories]] this crafting machine can use.


Line 33: Line 31:
</pre>
</pre>


=== energy_source ===
{{Prototype property|energy_source|[[Types/EnergySource|EnergySource]]}}
'''Type''': [[Types/EnergySource]]
 
Defines how the crafting machine is powered.
Defines how the crafting machine is powered.


=== animation ===
When using an electric energy source and <code>drain</code> is not specified, it will be set to <code>energy_usage ÷ 30</code> automatically.
'''Type''': [[Types/Animation4Way]]
 
The animation played when crafting. When the crafting machine is idle, the animation will be paused.
 
=== idle_animation ===
'''Type''': [[Types/Animation4Way]]
 
The animation played when idle. Idle animation must have the same frame count as animation.


== Optional properties ==
== Optional properties ==


=== fluid_boxes ===
{{Prototype property|fluid_boxes|[[Types/table|table]] of [[Types/FluidBox|FluidBox]]|optional=true}}
'''Type''': [[Types/table]] of [[Types/FluidBox]]
Can have off_when_no_fluid_recipe key that has a [[Types/bool|bool]] value. off_when_no_fluid_recipe defaults to false. off_when_no_fluid_recipe is ignored by [[Prototype/Furnace]]s and considered to always be false.


Can have off_when_no_fluid_recipe key that has a [[Types/bool]] value.
If a crafting machine has fluid boxes ''and'' off_when_no_fluid_recipe is true, the crafting machine can only be rotated when a recipe consuming or producing fluid is set, or it has one of the other properties listed at the top of the page.


<syntaxhighlight lang="lua">fluid_boxes =
<syntaxhighlight lang="lua">fluid_boxes =
Line 78: Line 66:
     },</syntaxhighlight>
     },</syntaxhighlight>


=== allowed_effects ===
{{Prototype property|allowed_effects|[[Types/EffectTypeLimitation|EffectTypeLimitation]]|No effects are allowed|optional=true}}
'''Type''': [[Types/EffectTypeLimitation]]
Sets the module effects that are allowed to be used on this machine.
 
Note: If the time to complete a recipe is shorter than one tick, only one craft can be completed per tick, but productivity bonus is applied to the non-limited ''completable'' work. For a simple example, if a recipe were to take half a tick, only one recipe would be completed, but twice the productivity bonus would occur. The surplus production from productivity is '''not''' limited to one craft per tick.


Sets the module effects that are allowed to be used on this machine.
{{Prototype property|scale_entity_info_icon|[[Types/bool|bool]]|false|optional=true}}
Whether the "alt-mode icon" should be scaled to the size of the machine.
 
{{Prototype property|show_recipe_icon|[[Types/bool|bool]]|true|optional=true}}
Whether the "alt-mode icon" should be drawn at all.
 
{{Prototype property|return_ingredients_on_change|[[Types/bool|bool]]|true|optional=true}}
Controls whether the ingredients of an in-progress recipe are destroyed when mining the machine/changing the recipe. If set to true, the ingredients do not get destroyed. This affects only the ingredients of the recipe that is currently in progress, so those that visually have already been consumed while their resulting product has not yet been produced.
 
{{Prototype property|animation|[[Types/Animation4Way|Animation4Way]]|optional=true}}
The animation played when crafting. When the crafting machine is idle, the animation will be paused.
 
When a crafting machine cannot be rotated, only the north rotation of the animation will be used.
 
The <code>animation_speed</code> of the animation is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.
 
{{Prototype property|idle_animation|[[Types/Animation4Way|Animation4Way]]|optional=true}}
Idle animation must have the same frame count as animation. It is used for drawing the machine in idle state, but the is animation frozen on a single frame when the machine is idle.<br>
This is an animation and not just sprite to make it possible for idle state and working state to match their visuals when the machine switches from one state to another.
 
When a crafting machine cannot be rotated, only the north rotation of the idle animation will be used.
 
The <code>animation_speed</code> of the animation is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.
 
{{Prototype property|always_draw_idle_animation|[[Types/bool|bool]]|false|optional=true}}
Only loaded if <code>idle_animation</code> is present.
 
{{Prototype property|default_recipe_tint|[[Types/table|table]] of [[Types/Color|Color]]|optional=true}}
Format:
<syntaxhighlight lang="lua">default_recipe_tint = { primary = {r=1,g=1,b=1,a=1}, secondary = {r=1,g=1,b=1,a=1}, tertiary = {r=1,g=1,b=1,a=1}, quaternary = {r=1,g=1,b=1,a=1}}</syntaxhighlight>
Each key/value pair is optional and defaults to the above value.
 
{{Prototype property|shift_animation_waypoints|[[Types/table|table]] of [[Types/table|table]] (array) of [[Types/vector|vector]]|optional=true}}
Table with the following optional key/value pairs:
* north - [[Types/table|array]] of [[Types/vector|vector]]
* east - [[Types/table|array]] of [[Types/vector|vector]]
* south - [[Types/table|array]] of [[Types/vector|vector]]
* west - [[Types/table|array]] of [[Types/vector|vector]]
 
Only loaded if one of <code>shift_animation_waypoint_stop_duration</code> or <code>shift_animation_transition_duration</code> is not 0.
 
{{Prototype property|shift_animation_waypoint_stop_duration|[[Types/uint16|uint16]]|0|optional=true}}
Only loaded if <code>shift_animation_waypoints</code> is present.
 
{{Prototype property|shift_animation_transition_duration |[[Types/uint16|uint16]]|0|optional=true}}
Only loaded if <code>shift_animation_waypoints</code> is present.


=== has_backer_name ===
{{Prototype property|status_colors|[[Types/table|table]] of [[Types/Color|Color]]|optional=true}}
'''Type''': [[Types/bool]]
Table with the following optional key/value pairs:
* idle - [[Types/Color|Color]] - Default: White
* no_minable_resources - [[Types/Color|Color]] - Default: <code>idle</code>
* full_output - [[Types/Color|Color]] - Default: <code>idle</code>
* insufficient_input - [[Types/Color|Color]] - Default: <code>idle</code>
* disabled - [[Types/Color|Color]] - Default: <code>idle</code>
* no_power - [[Types/Color|Color]] - Default: No color
* working - [[Types/Color|Color]] - Default: White
* low_power - [[Types/Color|Color]] - Default: <code>working</code>


'''Default''': false
Used by [[Types/WorkingVisualisation#apply_tint]].


=== scale_entity_info_icon ===
{{Prototype property|entity_info_icon_shift|[[Types/vector|vector]]|<nowiki>{0, -0.3}</nowiki> for [[Prototype/AssemblingMachine]] and <nowiki>{0, -0.1}</nowiki> for [[Prototype/Furnace]]|optional=true}}
'''Type''': [[Types/bool]]
Shift of the "alt-mode icon" relative to the machine's center.


'''Default''': false
{{Prototype property|draw_entity_info_icon_background|[[Types/bool|bool]]|true|optional=true}}
Whether the "alt-mode icon" should have a black background.


=== always_draw_idle_animation ===
{{Prototype property|match_animation_speed_to_activity|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/bool]]
Whether the speed of the animation and working visualization should be based on the machine's speed (boosted or slowed by modules).


'''Default''': false
{{Prototype property|show_recipe_icon_on_map|[[Types/bool|bool]]|true|optional=true}}
Whether the recipe icon should be shown on the map.


=== module_specification ===
{{Prototype property|base_productivity|[[Types/float|float]]|0|optional=true}}
'''Type''': [[Types/ModuleSpecification]]
Productivity bonus that this machine always has.


{{Prototype property|module_specification|[[Types/ModuleSpecification|ModuleSpecification]]|optional=true}}
The number of module slots in this machine, and their icon positions.
The number of module slots in this machine, and their icon positions.


Line 111: Line 157:
},</syntaxhighlight>
},</syntaxhighlight>


=== working_visualisations ===
{{Prototype property|working_visualisations|[[Types/table|table]] of [[Types/WorkingVisualisation|WorkingVisualisation]]|optional=true}}
'''Type''': [[Types/table]] of [[Types/WorkingVisualisation]]
Used to display different animations when the machine is running, for example tinted based on the current recipe.
 
The <code>animation_speed</code> of the animations is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.

Latest revision as of 16:18, 17 June 2022

Prototype definitions » PrototypeBase » Prototype/Entity » Prototype/EntityWithHealth » Prototype/EntityWithOwner » Prototype/CraftingMachine


The abstract basis of the assembling machines and furnaces. Contains the properties that both of them have.

Note that a crafting machine cannot be rotated unless it has at least one of the following: a fluid box, a heat energy source, a fluid energy source, or a non-square collision box. Crafting machines with non-square collision boxes can only be rotated before placement, not after.


Prototype/CraftingMachine — abstract
crafting_categories::table of strings
crafting_speed::double
energy_source::EnergySource
energy_usage::Energy
allowed_effects::EffectTypeLimitation (optional)
always_draw_idle_animation::bool (optional)
animation::Animation4Way (optional)
base_productivity::float (optional)
default_recipe_tint::table of Color (optional)
draw_entity_info_icon_background::bool (optional)
entity_info_icon_shift::vector (optional)
fluid_boxes::table of FluidBox (optional)
idle_animation::Animation4Way (optional)
match_animation_speed_to_activity::bool (optional)
module_specification::ModuleSpecification (optional)
return_ingredients_on_change::bool (optional)
scale_entity_info_icon::bool (optional)
shift_animation_transition_duration::uint16 (optional)
shift_animation_waypoint_stop_duration::uint16 (optional)
shift_animation_waypoints::table of table (array) of vector (optional)
show_recipe_icon::bool (optional)
show_recipe_icon_on_map::bool (optional)
status_colors::table of Color (optional)
working_visualisations::table of WorkingVisualisation (optional)
Inherited from Prototype/EntityWithOwner
allow_run_time_change_of_is_military_target::bool (optional)
is_military_target::bool (optional)
Inherited from Prototype/EntityWithHealth
alert_when_damaged::bool (optional)
attack_reaction::AttackReaction (optional)
corpse::string or table of strings (optional)
create_ghost_on_death::bool (optional)
damaged_trigger_effect::TriggerEffect (optional)
dying_explosion::ExplosionDefinition or table of ExplosionDefinition (optional)
dying_trigger_effect::TriggerEffect (optional)
healing_per_tick::float (optional)
hide_resistances::bool (optional)
integration_patch::Sprite4Way (optional)
integration_patch_render_layer::RenderLayer (optional)
loot::Loot (optional)
max_health::float (optional)
random_corpse_variation::bool (optional)
repair_sound::Sound (optional)
repair_speed_modifier::float (optional)
resistances::Resistances (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)

Extensions

Mandatory properties

This prototype inherits all the properties from Prototype/EntityWithOwner.

energy_usage

Type: Energy
Sets how much energy this machine uses while crafting. Energy usage has to be positive.

crafting_speed

Type: double
How fast this crafting machine can craft. 1 means that for example a 1 second long recipe take 1 second to craft. 0.5 means it takes 2 seconds, and 2 means it takes 0.5 seconds.

Crafting speed has to be positive.

crafting_categories

Type: table of strings
A list of recipe categories this crafting machine can use.

Example:

crafting_categories = {"crafting", "smelting"}

energy_source

Type: EnergySource
Defines how the crafting machine is powered.

When using an electric energy source and drain is not specified, it will be set to energy_usage ÷ 30 automatically.

Optional properties

fluid_boxes

Type: table of FluidBox
Can have off_when_no_fluid_recipe key that has a bool value. off_when_no_fluid_recipe defaults to false. off_when_no_fluid_recipe is ignored by Prototype/Furnaces and considered to always be false.

If a crafting machine has fluid boxes and off_when_no_fluid_recipe is true, the crafting machine can only be rotated when a recipe consuming or producing fluid is set, or it has one of the other properties listed at the top of the page.

fluid_boxes =
    {
      {
        production_type = "input",
        pipe_picture = assembler2pipepictures(),
        pipe_covers = pipecoverspictures(),
        base_area = 10,
        base_level = -1,
        pipe_connections = {{ type="input", position = {0, -2} }},
        secondary_draw_orders = { north = -1 }
      },
      {
        production_type = "output",
        pipe_picture = assembler2pipepictures(),
        pipe_covers = pipecoverspictures(),
        base_area = 10,
        base_level = 1,
        pipe_connections = {{ type="output", position = {0, 2} }},
        secondary_draw_orders = { north = -1 }
      },
      off_when_no_fluid_recipe = true
    },

allowed_effects

Type: EffectTypeLimitation
Default: No effects are allowed
Sets the module effects that are allowed to be used on this machine.

Note: If the time to complete a recipe is shorter than one tick, only one craft can be completed per tick, but productivity bonus is applied to the non-limited completable work. For a simple example, if a recipe were to take half a tick, only one recipe would be completed, but twice the productivity bonus would occur. The surplus production from productivity is not limited to one craft per tick.

scale_entity_info_icon

Type: bool
Default: false
Whether the "alt-mode icon" should be scaled to the size of the machine.

show_recipe_icon

Type: bool
Default: true
Whether the "alt-mode icon" should be drawn at all.

return_ingredients_on_change

Type: bool
Default: true
Controls whether the ingredients of an in-progress recipe are destroyed when mining the machine/changing the recipe. If set to true, the ingredients do not get destroyed. This affects only the ingredients of the recipe that is currently in progress, so those that visually have already been consumed while their resulting product has not yet been produced.

animation

Type: Animation4Way
The animation played when crafting. When the crafting machine is idle, the animation will be paused.

When a crafting machine cannot be rotated, only the north rotation of the animation will be used.

The animation_speed of the animation is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.

idle_animation

Type: Animation4Way
Idle animation must have the same frame count as animation. It is used for drawing the machine in idle state, but the is animation frozen on a single frame when the machine is idle.
This is an animation and not just sprite to make it possible for idle state and working state to match their visuals when the machine switches from one state to another.

When a crafting machine cannot be rotated, only the north rotation of the idle animation will be used.

The animation_speed of the animation is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.

always_draw_idle_animation

Type: bool
Default: false
Only loaded if idle_animation is present.

default_recipe_tint

Type: table of Color
Format:

default_recipe_tint = { primary = {r=1,g=1,b=1,a=1}, secondary = {r=1,g=1,b=1,a=1}, tertiary = {r=1,g=1,b=1,a=1}, quaternary = {r=1,g=1,b=1,a=1}}

Each key/value pair is optional and defaults to the above value.

shift_animation_waypoints

Type: table of table (array) of vector
Table with the following optional key/value pairs:

Only loaded if one of shift_animation_waypoint_stop_duration or shift_animation_transition_duration is not 0.

shift_animation_waypoint_stop_duration

Type: uint16
Default: 0
Only loaded if shift_animation_waypoints is present.

shift_animation_transition_duration

Type: uint16
Default: 0
Only loaded if shift_animation_waypoints is present.

status_colors

Type: table of Color
Table with the following optional key/value pairs:

  • idle - Color - Default: White
  • no_minable_resources - Color - Default: idle
  • full_output - Color - Default: idle
  • insufficient_input - Color - Default: idle
  • disabled - Color - Default: idle
  • no_power - Color - Default: No color
  • working - Color - Default: White
  • low_power - Color - Default: working

Used by Types/WorkingVisualisation#apply_tint.

entity_info_icon_shift

Type: vector
Default: {0, -0.3} for Prototype/AssemblingMachine and {0, -0.1} for Prototype/Furnace
Shift of the "alt-mode icon" relative to the machine's center.

draw_entity_info_icon_background

Type: bool
Default: true
Whether the "alt-mode icon" should have a black background.

match_animation_speed_to_activity

Type: bool
Default: true
Whether the speed of the animation and working visualization should be based on the machine's speed (boosted or slowed by modules).

show_recipe_icon_on_map

Type: bool
Default: true
Whether the recipe icon should be shown on the map.

base_productivity

Type: float
Default: 0
Productivity bonus that this machine always has.

module_specification

Type: ModuleSpecification
The number of module slots in this machine, and their icon positions.

module_specification = {
  module_info_icon_shift = {
    0,
    0.8
  },
  module_slots = 2
},

working_visualisations

Type: table of WorkingVisualisation
Used to display different animations when the machine is running, for example tinted based on the current recipe.

The animation_speed of the animations is divided by 2 by the game. For example, the default animation speed of 1 means one animation frame per 2 ticks (30 fps) instead of the usual 60 fps.