Prototype/Technology: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (Bilka moved page Prototype/technology to Prototype/Technology: same os the other prototypes)
(→‎Technology data: added interaction between formula_count and levels)
 
(31 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Basics==
{{Prototype parent|PrototypeBase}}
More in [[Research]]
A [[technologies|technology]].


== Mandatory properties ==
{{Prototype TOC|technology}}
=== unit ===
 
It contains
== General properties ==
* count - How many units are needed
Inherits all properties from [[PrototypeBase]].
* time - how much time is needed per one unit, in standard laboratory without upgrades it is is count of seconds
 
* ingredients - list of ingredients needed for one units
{{Prototype property|icons, icon, icon_size (IconSpecification)|[[Types/IconSpecification|IconSpecification]]}}
   unit =
 
=== name ===
:''See [[PrototypeBase#name ]]''
 
Inherited from [[PrototypeBase]]. If the name ends with <code>-number</code>, the number is ignored for localization purposes. E. g. if the name is <code>whatever-name-3</code>, the game looks for the <code>technology-name.whatever-name</code> localization. The technology tree will also show the number on the technology icon.
 
== Technology data ==
<!--
Anchor and property for the TOC at the top --><span id="normal">{{#subobject:normal
|Prototype property name=normal
|Prototype property type=[[Prototype/Technology#Technology_data|Technology data]] or [[Types/bool|bool]]
|Prototype property optional=true
|Prototype property pagename={{FULLPAGENAME}}
}}</span><!--
Anchor and property for the TOC at the top --><span id="expensive">{{#subobject:expensive
|Prototype property name=expensive
|Prototype property type=[[Prototype/Technology#Technology_data|Technology data]] or [[Types/bool|bool]]
|Prototype property optional=true
|Prototype property pagename={{FULLPAGENAME}}
}}</span><!--
-->
If the technology does not have a difficulty, this is located directly in the prototype. Otherwise, if the "normal" or "expensive" property exists, the technology has difficulty. Then, the technology data has to be specified for each difficulty instead of directly in the prototype. If at least one difficulty has technology data defined, the other difficulty can be set to <code>false</code>. This will disable the technology for the difficulty, same as setting it <code>enabled = false</code>. If it is enabled (by script etc), it will use the data from the other difficulty. Not setting a difficulty, e.g. <code>normal = nil</code>, is possible and gives that difficulty the exact same properties as the difficulty that is defined.
 
{{Prototype property|upgrade|[[Types/bool|bool]]|false|optional=true}}
When set to true, and the technology contains several levels, only the relevant one is displayed in the technology screen.
<syntaxhighlight lang="lua">  {
    type = "technology",
    name = "physical-projectile-damage-2",
    ...
    upgrade = "true"
  }</syntaxhighlight>
 
{{Prototype property|enabled|[[Types/bool|bool]]|true|optional=true}}
 
{{Prototype property|hidden|[[Types/bool|bool]]|false|optional=true}}
Hides the technology from the tech screen.
 
{{Prototype property|visible_when_disabled|[[Types/bool|bool]]|false|optional=true}}
Controls whether the technology is shown in the tech GUI when it is disabled (enabled = false).
 
{{Prototype property|ignore_tech_cost_multiplier|[[Types/bool|bool]]|false|optional=true}}
Controls whether the technology cost ignores the tech cost multiplier set in the [https://lua-api.factorio.com/latest/Concepts.html#DifficultySettings DifficultySettings], e.g. 4 for the default expensive difficulty.
 
{{Prototype property|unit|[[Types/table|table]]}}
[[Types/table|table]] with the following key/value pairs:
* count — [[Types/uint64|uint64]] — How many units are needed. Must be larger than 0. May not be specified if count_formula is specified.
* count_formula — [[Types/string|string]] — Formula that specifies how many units are needed per level of the technology. May not be specified if count is specified.
: If the last characters of the prototype name are "-digits", the level is taken to be the digits. e.g. physical-projectile-damage-2 -> 2. The unspecified default is 1. There does not need to be lower-level technologies for a technology to be detected as having a level. (a technology or sequence of upgrade technologies can begin at any number)
: For an infinite technology, the level begins at the suffix (or 1) and gains +1 level upon being researched, or is completed when the max_level is completed. The initial level of a technology cannot be greater than the max_level.
: The formula is executed following the BODMAS order (also known as PEMDAS).
 
: Supported operators & characters:
: {| class="wikitable"
|-
! Operator !! meaning
|-
| +  || Addition
|-
| -  || Subtraction
|-
| * || Multiplication
|-
| ^ || Power, raise the preceding base number by the following exponent number
|-
| () || Brackets for order, supported nested brackets
|-
| l or L || The current level of the technology
|-
| Digits || Are treated as numbers
|-
| . || Decimal point in number
|-
| SPACE || Space characters are ignored
|}
* time — [[Types/double|double]] — How much time is needed per one unit, in lab with crafting speed 1 it is the number of seconds.
* ingredients — [[Types/table|table]] of [[Types/IngredientPrototype|IngredientPrototype]] — list of ingredients needed for one unit of research. The item types must all be [[Prototype/Tool|tools]].
 
:<syntaxhighlight lang="lua">
unit =
{
  count_formula = "2^(L-6)*1000",
   ingredients =
   {
   {
     count = 20,
     {"automation-science-pack", 1},
     time = 5,
     {"logistic-science-pack", 1},
     ingredients = { ["science-pack-1"] = 1 }
     {"chemical-science-pack", 1},
   }
    {"production-science-pack", 1},
=== prerequisites ===
    {"utility-science-pack", 1},
    {"space-science-pack", 1}
   },
  time = 60
}</syntaxhighlight>
 
Note: The count formula can also be used in the [https://lua-api.factorio.com/latest/LuaGameScript.html#LuaGameScript.evaluate_expression runtime api].
{{Prototype property|max_level|[[Types/uint32|uint32]] or [[Types/string|string]]|Same as the level of the technology, which is 0 for non-upgrades, and the level of the upgrade for upgrades.|optional=true}}
"infinite" for infinite technologies, otherwise uint.
 
{{Prototype property|prerequisites|[[Types/table|table]] of [[Types/string|string]]|optional=true}}
List of technologies needed to be researched before this one can be researched.
List of technologies needed to be researched before this one can be researched.
   prerequisites = {"explosives", "military-2"}
   prerequisites = {"explosives", "military-2"}
=== effects ===
 
'''Type''': [http://lua-api.factorio.com/latest/Concepts.html#Modifier Modifier]
{{Prototype property|effects|[[Types/table|table]] of [[Types/ModifierPrototype]]|optional=true}}
List of effects of the technology (applied when the technology is researched).
List of effects of the technology (applied when the technology is researched).


<syntaxhighlight lang="lua">
{
   {
   {
     type  = "unlock-recipe",
     type  = "unlock-recipe",
     recipe = "land-mine"
     recipe = "land-mine"
   }
   }
}
</syntaxhighlight>


== Optional properties ==
== Example ==
=== upgrade ===
<syntaxhighlight lang="lua">{
When set to true, and the technology contains several levels, only the relevant one is displayed in the technology screen.
  type = "technology",
<pre>  {
  name = "steel-processing",
     type = "technology",
  icon_size = 256,
    name = "rocket-damage-2",
  icon_mipmaps = 4,
     ...
  icon = "__base__/graphics/technology/steel-processing.png",
    upgrade = "true"
  effects =
     }</pre>
  {
Default value is false
     {
 
      type = "unlock-recipe",
note from FreeER, it is possible that I am wrong so I figured I'd put my name and that this senctence could mislead you first lol, I believe that all except for the first unresearched technology in the series are hidden, for factorio to know which technologies are in that series the technology names must be the same except for the number at the end
      recipe = "steel-plate"
 
    },
note from Matjojo, It is currently not possible to have more than one descriptions for a line of upgrades.
     {
      type = "unlock-recipe",
      recipe = "steel-chest"
     }
  },
  unit =
  {
    count = 50,
    ingredients = {{"automation-science-pack", 1}},
    time = 5
  },
  order = "c-a"
}</syntaxhighlight>

Latest revision as of 01:55, 6 June 2022

Prototype definitions » PrototypeBase » Prototype/Technology


A technology.


Prototype/Technology — technology
icons, icon, icon_size (IconSpecification)::IconSpecification
unit::table
effects::table of Types/ModifierPrototype (optional)
enabled::bool (optional)
expensive::Technology data or bool (optional)
hidden::bool (optional)
ignore_tech_cost_multiplier::bool (optional)
max_level::uint32 or string (optional)
normal::Technology data or bool (optional)
prerequisites::table of string (optional)
upgrade::bool (optional)
visible_when_disabled::bool (optional)
Inherited from PrototypeBase
name::string
type::string
localised_description::LocalisedString (optional)
localised_name::LocalisedString (optional)
order::Order (optional)

General properties

Inherits all properties from PrototypeBase.

icons, icon, icon_size (IconSpecification)

Type: IconSpecification

name

See PrototypeBase#name

Inherited from PrototypeBase. If the name ends with -number, the number is ignored for localization purposes. E. g. if the name is whatever-name-3, the game looks for the technology-name.whatever-name localization. The technology tree will also show the number on the technology icon.

Technology data

If the technology does not have a difficulty, this is located directly in the prototype. Otherwise, if the "normal" or "expensive" property exists, the technology has difficulty. Then, the technology data has to be specified for each difficulty instead of directly in the prototype. If at least one difficulty has technology data defined, the other difficulty can be set to false. This will disable the technology for the difficulty, same as setting it enabled = false. If it is enabled (by script etc), it will use the data from the other difficulty. Not setting a difficulty, e.g. normal = nil, is possible and gives that difficulty the exact same properties as the difficulty that is defined.

upgrade

Type: bool
Default: false
When set to true, and the technology contains several levels, only the relevant one is displayed in the technology screen.

  {
    type = "technology",
    name = "physical-projectile-damage-2",
    ...
    upgrade = "true"
  }

enabled

Type: bool
Default: true

hidden

Type: bool
Default: false
Hides the technology from the tech screen.

visible_when_disabled

Type: bool
Default: false
Controls whether the technology is shown in the tech GUI when it is disabled (enabled = false).

ignore_tech_cost_multiplier

Type: bool
Default: false
Controls whether the technology cost ignores the tech cost multiplier set in the DifficultySettings, e.g. 4 for the default expensive difficulty.

unit

Type: table
table with the following key/value pairs:

  • count — uint64 — How many units are needed. Must be larger than 0. May not be specified if count_formula is specified.
  • count_formula — string — Formula that specifies how many units are needed per level of the technology. May not be specified if count is specified.
If the last characters of the prototype name are "-digits", the level is taken to be the digits. e.g. physical-projectile-damage-2 -> 2. The unspecified default is 1. There does not need to be lower-level technologies for a technology to be detected as having a level. (a technology or sequence of upgrade technologies can begin at any number)
For an infinite technology, the level begins at the suffix (or 1) and gains +1 level upon being researched, or is completed when the max_level is completed. The initial level of a technology cannot be greater than the max_level.
The formula is executed following the BODMAS order (also known as PEMDAS).
Supported operators & characters:
Operator meaning
+ Addition
- Subtraction
* Multiplication
^ Power, raise the preceding base number by the following exponent number
() Brackets for order, supported nested brackets
l or L The current level of the technology
Digits Are treated as numbers
. Decimal point in number
SPACE Space characters are ignored
  • time — double — How much time is needed per one unit, in lab with crafting speed 1 it is the number of seconds.
  • ingredients — table of IngredientPrototype — list of ingredients needed for one unit of research. The item types must all be tools.
unit =
{
  count_formula = "2^(L-6)*1000",
  ingredients =
  {
    {"automation-science-pack", 1},
    {"logistic-science-pack", 1},
    {"chemical-science-pack", 1},
    {"production-science-pack", 1},
    {"utility-science-pack", 1},
    {"space-science-pack", 1}
  },
  time = 60
}

Note: The count formula can also be used in the runtime api.

max_level

Type: uint32 or string
Default: Same as the level of the technology, which is 0 for non-upgrades, and the level of the upgrade for upgrades.
"infinite" for infinite technologies, otherwise uint.

prerequisites

Type: table of string
List of technologies needed to be researched before this one can be researched.

 prerequisites = {"explosives", "military-2"}

effects

Type: table of Types/ModifierPrototype
List of effects of the technology (applied when the technology is researched).

{
  {
    type  = "unlock-recipe",
    recipe = "land-mine"
  }
}

Example

{
  type = "technology",
  name = "steel-processing",
  icon_size = 256,
  icon_mipmaps = 4,
  icon = "__base__/graphics/technology/steel-processing.png",
  effects =
  {
    {
      type = "unlock-recipe",
      recipe = "steel-plate"
    },
    {
      type = "unlock-recipe",
      recipe = "steel-chest"
    }
  },
  unit =
  {
    count = 50,
    ingredients = {{"automation-science-pack", 1}},
    time = 5
  },
  order = "c-a"
}