Types/bool: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (formatting)
(Removed old prototype docs)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
A variable type which can have one of two values: <code>true</code> or <code>false</code>. Wikipedia has a comprehensive article on [[wikipedia:Boolean|Booleans]].
<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/types/bool.html https://lua-api.factorio.com/latest/types/bool.html]


== Advanced ==
</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>
Booleans used in prototypes can also be be defined by other variable types which are then coerced to boolean values by the game. This type coercion differs from the [https://www.lua.org/manual/5.2/manual.html#2.1 standard Lua truthy/falsy] coercion.
 
It is recommended to only use <code>true</code> and <code>false</code>, not the options listed below.
 
{| class="wikitable"
|-
! Value !! Factorio prototype loading<br>type coercion to boolean !! Lua<br>type coercion to boolean
|-
| <code>""</code> || false || true
|-
| <code>"true"</code> || true || true
|-
| <code>"false"</code> || false || true
|-
| <code>"0"</code> || false || true
|-
| <code>"<any number besides 0 (inside a string)>"</code> || true || true
|-
| <code>"<some random string>"</code> || not coerced, treated as a string || true
|-
| <code>0</code> || false || true
|-
| <code><any number besides 0></code> || true || true
|-
|}

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/types/bool.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.