list of buildings...
list of buildings...
I want to write a mod that slightly differently displays the recipe for creating an item. To do this, it is necessary to display information about the building in which this recipe can be made.
In Factorio Api -> LuaEntityPrototype, I found the field "crafting_categories :: the dictionary string → Boolean [R]" which returns a boolean instead of the list crafting_categories.
Can I get a list of "assembling-machine" in which i can execute the required recipe?
Sorry for my english.
In Factorio Api -> LuaEntityPrototype, I found the field "crafting_categories :: the dictionary string → Boolean [R]" which returns a boolean instead of the list crafting_categories.
Can I get a list of "assembling-machine" in which i can execute the required recipe?
Sorry for my english.
Re: list of buildings...
Read the full description of crafting_categories:
http://lua-api.factorio.com/latest/LuaE ... categories
http://lua-api.factorio.com/latest/LuaE ... categories
The dictionary keys are the categories.Factorio Lua docs wrote:crafting_categories :: dictionary string → boolean [Read-only]
The crafting categories this entity supports. Only meaningful when this is a crafting-machine or player entity type.
Note: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup.
If you want to get ahold of me I'm almost always on Discord.
Re: list of buildings...
This field always returns a boolean value and not a dictionary key. How to get the key when calling this field?Rseding91 wrote:Read the full description of crafting_categories:
http://lua-api.factorio.com/latest/LuaE ... categoriesThe dictionary keys are the categories.Factorio Lua docs wrote:crafting_categories :: dictionary string → boolean [Read-only]
The crafting categories this entity supports. Only meaningful when this is a crafting-machine or player entity type.
Note: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup.
Apparently I do not understand what it means "dictionary string → boolean".
-
- Fast Inserter
- Posts: 127
- Joined: Fri May 08, 2015 2:25 pm
- Contact:
Re: list of buildings...
It means that when you use .crafting_categories, it will return a map of "dictionary string"s to "boolean"s. So when you iterate over crafting_categories, you will want the keys, not the values._npo6ka_ wrote:This field always returns a boolean value and not a dictionary key. How to get the key when calling this field?Rseding91 wrote:Read the full description of crafting_categories:
http://lua-api.factorio.com/latest/LuaE ... categoriesThe dictionary keys are the categories.Factorio Lua docs wrote:crafting_categories :: dictionary string → boolean [Read-only]
The crafting categories this entity supports. Only meaningful when this is a crafting-machine or player entity type.
Note: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup.
Apparently I do not understand what it means "dictionary string → boolean".
I.e.
Code: Select all
for k,v in pairs(path_to.crafting_categories) do
print k --this prints my crafting categories!
end
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
Mods (current): Resource Labels
Mods (old): Biter Spires
Re: list of buildings...
Thank you so much!Pandemoneus wrote:It means that when you use .crafting_categories, it will return a map of "dictionary string"s to "boolean"s. So when you iterate over crafting_categories, you will want the keys, not the values._npo6ka_ wrote:This field always returns a boolean value and not a dictionary key. How to get the key when calling this field?Rseding91 wrote:Read the full description of crafting_categories:
http://lua-api.factorio.com/latest/LuaE ... categoriesThe dictionary keys are the categories.Factorio Lua docs wrote:crafting_categories :: dictionary string → boolean [Read-only]
The crafting categories this entity supports. Only meaningful when this is a crafting-machine or player entity type.
Note: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup.
Apparently I do not understand what it means "dictionary string → boolean".
I.e.Code: Select all
for k,v in pairs(path_to.crafting_categories) do print k --this prints my crafting categories! end
Problem solved.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: list of buildings...
I see.
so it returns something like:
That makes sense. Kinda.
so it returns something like:
Code: Select all
{
crafting = true,
crafting-with-fluid = true,
chemistry = false,
...
}
Re: list of buildings...
No the values are meaningless. The key existing in the dictionary is what's useful. If it exists, then it supports it.bobingabout wrote:I see.
so it returns something like:That makes sense. Kinda.Code: Select all
{ crafting = true, crafting-with-fluid = true, chemistry = false, ... }
If you want to get ahold of me I'm almost always on Discord.
Re: list of buildings...
Code: Select all
for k, category in pairs(path_to.crafting_categories) do
If category then
Function ()
End
end
Re: list of buildings...
What?darkfrei wrote:Why we are need to iterate category=false?Code: Select all
for k, category in pairs(path_to.crafting_categories) do If category then Function () End end
If you want to get ahold of me I'm almost always on Discord.
Re: list of buildings...
I mean, why we are need the list with booleans, but not just list of positive elements.bobingabout wrote:so it returns something like:Code: Select all
{ crafting = true, crafting-with-fluid = true, chemistry = false, ... }
Re: list of buildings...
Because there is no set in lua - and table requires key-value pairs.darkfrei wrote:I mean, why we are need the list with booleans, but not just list of positive elements.bobingabout wrote:so it returns something like:Code: Select all
{ crafting = true, crafting-with-fluid = true, chemistry = false, ... }
I'd be curious why they are not all true but thats developer in me
Re: list of buildings...
this mod already exist viewtopic.php?f=92&t=30465
Re: list of buildings...
We can have only
Code: Select all
{
"crafting",
"crafting-with-fluid",
-- "chemistry", -- it was false
...
}
Re: list of buildings...
There are no false values, only a list of true values. It is done this way so you don't have to iterate the whole table to see if the machine supports it.darkfrei wrote:We can have onlyCode: Select all
{ "crafting", "crafting-with-fluid", -- "chemistry", -- it was false ... }