All item types, all entity types in data stage
All item types, all entity types in data stage
Is here easy way to get all item types and entity types by the data stage?
Almost(?) all entity prototypes have collision boxes, but is it by them only?
Almost(?) all entity prototypes have collision boxes, but is it by them only?
Re: All item types, all entity types in data stage
Do you mean the item/entity names? That could be done this way:
Code: Select all
local all = data.raw
log("Getting items:")
for _,item in pairs(all.item) do
log(item.name)
end
log("Getting entities:")
for _,x in pairs(all) do
for _, entity in pairs(x) do
log(entity.name .. ":\t" .. entity.type)
end
end
Last edited by Pi-C on Fri Jan 31, 2020 9:24 am, edited 1 time in total.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: All item types, all entity types in data stage
I would say anything which has stack_size constitutes an item (my stack changing mod has to search odd categories sometimes). Some of the "item" categories include capsules, modules... Logically, doing:
code
Should get you all the types of things which can be held in inventory:result
For entities you have to be careful: explosions, acid splashes, arrow indicators are entities. There are strange things that are entities. For practical things, a checking for a collision box sounds good. Do it and see what you get.I have mods! I guess!
Link
Link
Re: All item types, all entity types in data stage
items only exist in items YOU'D LIKE TO* THINK SO WOULDN'T YOU!?!
And that second one isn't good. It'll get you literally everything with a name. Like achievements (first category I ran into after accumulator that has a name).
I have mods! I guess!
Link
Link
Re: All item types, all entity types in data stage
What's wrong with that assumption?
See the original request:And that second one isn't good. It'll get you literally everything with a name. Like achievements (first category I ran into after accumulator that has a name).
That's just what the code does.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: All item types, all entity types in data stage
1) Items exist in other places. Yeah. The devs did that.
2) I'll assume you're being
I have mods! I guess!
Link
Link
Re: All item types, all entity types in data stage
Could you give an example? Why would the devs do that? Of course, I could imagine some mod deepcopying (parts of) item to another name so you'd find things of type = "item" somewhere below data.raw.something-not-itemβ¦
Why? Don't assume that people would want to compile a list of entity names only for processing it in their code. It may be helpful to see what entities exist during development, just for information. If you're really only interested in entities with a collision_mask, it shouldn't be too hard to check for that as well and only output the name of entities that have a collision_mask.2) I'll assume you're beingan idiotwrong on purpose.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: All item types, all entity types in data stage
Just the types? Indeed very easy. Just fucking hardcode the list, it almost never changes anyway. Every"smart" solution you try will just be a buggy mess that randomly fails on modded entities that are different than you "expect", and nobody will bother sending you bug reports about it.
Code: Select all
local hardcoded_classes = {
--A *HARDCODED* classification of all known prototype types
--
--Current Version: base-0.17.53
--
item = { --ITEMS
'item', 'armor' , 'mining-tool' , 'item-with-tags' , 'item-with-inventory' ,
'ammo', 'module' , 'repair-tool' , 'selection-tool' , 'item-with-entity-data',
'gun' , 'capsule' , 'rail-planner' , 'item-with-label' , 'copy-paste-tool' ,
'tool', 'blueprint', 'blueprint-book', 'deconstruction-item', 'upgrade-item' },
building = { --ENTITIES (BUILDINGS)
'lab' , 'inserter' , 'solar-panel' , 'rail-chain-signal' ,
'gate' , 'roboport' , 'fluid-turret' , 'assembling-machine' ,
'lamp' , 'splitter' , 'mining-drill' , 'decider-combinator' ,
'pipe' , 'container' , 'power-switch' , 'infinity-container' ,
'pump' , 'generator' , 'storage-tank' , 'logistic-container' ,
'wall' , 'heat-pipe' , 'electric-pole' , 'constant-combinator' ,
'radar' , 'land-mine' , 'offshore-pump' , 'programmable-speaker' ,
'beacon' , 'train-stop' , 'simple-entity' , 'arithmetic-combinator' ,
'boiler' , 'accumulator', 'straight-rail' , 'simple-entity-with-force' ,
'loader' , 'ammo-turret', 'pipe-to-ground' , 'simple-entity-with-owner' ,
'market' , 'curved-rail', 'transport-belt' , 'electric-energy-interface',
'turret' , 'player-port', 'electric-turret' , 'heat-interface' ,
'furnace', 'rail-signal', 'artillery-turret', 'infinity-pipe' ,
'reactor', 'rocket-silo', 'underground-belt' },
robot = { --ENTITY (ROBOTS)
'combat-robot', 'logistic-robot', 'construction-robot' },
special_entity = { --ENTITIES (SPECIAL)
'beam' , 'stream' , 'entity-ghost' , 'item-request-proxy' ,
'fire' , 'sticker' , 'unit-spawner' , 'rocket-silo-rocket' ,
'fish' , 'particle' , 'leaf-particle' , 'smoke-with-trigger' ,
'unit' , 'explosion' , 'rail-remnants' , 'artillery-projectile' ,
'arrow' , 'projectile' , 'trivial-smoke' , 'flame-thrower-explosion' ,
'smoke' , 'tile-ghost' , 'artillery-flare' , 'rocket-silo-rocket-shadow' ,
'corpse', 'flying-text', 'particle-source' , 'deconstructible-tile-proxy',
'character', 'item-entity', 'character-corpse' },
map_entity = { --ENTITIES (MAP)
'cliff', 'resource', 'tree', 'tile', 'decorative', 'optimized-decorative' },
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: All item types, all entity types in data stage
For better understanding:
Item - the thing, that can be produced or used in the recipes, but not fluid.
Entity - the thing, that can be placed on the map by the player without control.lua, but not tile.
Tile - all things in data.raw.tile.
In the data stage we have multiple item types, multiple entity types. In the control stage we can get all of them via item_prototypes and entity_prototypes.
Item - the thing, that can be produced or used in the recipes, but not fluid.
Entity - the thing, that can be placed on the map by the player without control.lua, but not tile.
Tile - all things in data.raw.tile.
In the data stage we have multiple item types, multiple entity types. In the control stage we can get all of them via item_prototypes and entity_prototypes.
Re: All item types, all entity types in data stage
Car and 1x1 loader?eradicator wrote: βFri Jan 31, 2020 11:03 amJust the types? Indeed very easy. Just fucking hardcode the list, it almost never changes anyway. Every"smart" solution you try will just be a buggy mess that randomly fails on modded entities that are different than you "expect", and nobody will bother sending you bug reports about it.
Code: Select all
local hardcoded_classes = { --A *HARDCODED* classification of all known prototype types -- --Current Version: base-0.17.53 -- item = { --ITEMS 'item', 'armor' , 'mining-tool' , 'item-with-tags' , 'item-with-inventory' , 'ammo', 'module' , 'repair-tool' , 'selection-tool' , 'item-with-entity-data', 'gun' , 'capsule' , 'rail-planner' , 'item-with-label' , 'copy-paste-tool' , 'tool', 'blueprint', 'blueprint-book', 'deconstruction-item', 'upgrade-item' }, building = { --ENTITIES (BUILDINGS) 'lab' , 'inserter' , 'solar-panel' , 'rail-chain-signal' , 'gate' , 'roboport' , 'fluid-turret' , 'assembling-machine' , 'lamp' , 'splitter' , 'mining-drill' , 'decider-combinator' , 'pipe' , 'container' , 'power-switch' , 'infinity-container' , 'pump' , 'generator' , 'storage-tank' , 'logistic-container' , 'wall' , 'heat-pipe' , 'electric-pole' , 'constant-combinator' , 'radar' , 'land-mine' , 'offshore-pump' , 'programmable-speaker' , 'beacon' , 'train-stop' , 'simple-entity' , 'arithmetic-combinator' , 'boiler' , 'accumulator', 'straight-rail' , 'simple-entity-with-force' , 'loader' , 'ammo-turret', 'pipe-to-ground' , 'simple-entity-with-owner' , 'market' , 'curved-rail', 'transport-belt' , 'electric-energy-interface', 'turret' , 'player-port', 'electric-turret' , 'heat-interface' , 'furnace', 'rail-signal', 'artillery-turret', 'infinity-pipe' , 'reactor', 'rocket-silo', 'underground-belt' }, robot = { --ENTITY (ROBOTS) 'combat-robot', 'logistic-robot', 'construction-robot' }, special_entity = { --ENTITIES (SPECIAL) 'beam' , 'stream' , 'entity-ghost' , 'item-request-proxy' , 'fire' , 'sticker' , 'unit-spawner' , 'rocket-silo-rocket' , 'fish' , 'particle' , 'leaf-particle' , 'smoke-with-trigger' , 'unit' , 'explosion' , 'rail-remnants' , 'artillery-projectile' , 'arrow' , 'projectile' , 'trivial-smoke' , 'flame-thrower-explosion' , 'smoke' , 'tile-ghost' , 'artillery-flare' , 'rocket-silo-rocket-shadow' , 'corpse', 'flying-text', 'particle-source' , 'deconstructible-tile-proxy', 'character', 'item-entity', 'character-corpse' }, map_entity = { --ENTITIES (MAP) 'cliff', 'resource', 'tree', 'tile', 'decorative', 'optimized-decorative' },
Re: All item types, all entity types in data stage
Everything has a name, unless I missed some niche category. The game will refuse to get past the data stage if the value of name in data.raw.category[name][name] isn't the same, and thing.type has to match the category.Pi-C wrote: βFri Jan 31, 2020 10:44 amWhy? Don't assume that people would want to compile a list of entity names only for processing it in their code. It may be helpful to see what entities exist during development, just for information. If you're really only interested in entities with a collision_mask, it shouldn't be too hard to check for that as well and only output the name of entities that have a collision_mask.
Code: Select all
log("Getting entities:")
for _,x in pairs(all) do
for _, entity in pairs(x) do
log(entity.name .. ":\t" .. entity.type)
end
end
I have mods! I guess!
Link
Link
Re: All item types, all entity types in data stage
cars are in item_with_entity_data, and I dunno about 1x1 loaders, but normal loaders are in item.
I have mods! I guess!
Link
Link
Re: All item types, all entity types in data stage
You can look for recipes in data.raw.recipe, and for items in data.raw.item, but as far as I know, you can't look for entities in data.raw.entity because it doesn't exist. To quote from the Factorio wiki:
Sometimes I just want to see a dump of what's available.Entity is basically everything that can be on the map (except tiles).
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: All item types, all entity types in data stage
Do you have any actual questions besides not reading the "Current Version:" comment at the top? Cos i doubt you're too stupid to add two more entries for this list that you're not even telling what you want it for.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: All item types, all entity types in data stage
Please don't be angry about my stupidity.eradicator wrote: βFri Jan 31, 2020 1:48 pmDo you have any actual questions besides not reading the "Current Version:" comment at the top? Cos i doubt you're too stupid to add two more entries for this list that you're not even telling what you want it for.
I've noticed that here at least two entities are not presented in this hardcoded entity types list. How can I sure that here are all of them?
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: All item types, all entity types in data stage
Your opening post couldn't be more vague about what you actually hope to achieve with this, so i posted a snippet i thought might be relevant, that's it. Just to give you an idea. My own code assigns a category to every key of data.raw. On startup it automatically checks if a new factorio version a) has any keys that are not in my list, or b) the list has keys that don't exist in the engine anymore. As i haven't touched 0.18 yet new stuff like 1x1-loader is obviously not included.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: ζ₯ζ¬θͺ, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: All item types, all entity types in data stage
I've collected all result item names from recipes. Than I've checked add prototype types if they have this items as subtable name.
Only some of them are entities, some are items, some have other type, not entities or items.
Code: Select all
all_types [84]:
all_types = {"noise-layer", "furnace", "transport-belt", "boiler", "container", "electric-pole", "generator", "offshore-pump", "inserter", "pipe", "radar", "lamp", "pipe-to-ground", "assembling-machine", "wall", "lab", "splitter", "underground-belt", "loader", "car", "roboport", "logistic-container", "construction-robot", "gate", "electric-energy-interface", "mining-drill", "resource", "ammo-turret", "ammo", "armor", "gun", "item", "capsule", "repair-tool", "tool", "item-with-entity-data", "item-subgroup", "recipe", "autoplace-control", "tile", "ammo-category", "fuel-category", "recipe-category", "resource-category", "technology", "projectile", "solar-panel", "locomotive", "cargo-wagon", "fluid-wagon", "artillery-wagon", "player-port", "land-mine", "train-stop", "rail-signal", "rail-chain-signal", "logistic-robot", "rocket-silo", "storage-tank", "pump", "accumulator", "beacon", "arithmetic-combinator", "decider-combinator", "constant-combinator", "power-switch", "programmable-speaker", "reactor", "heat-pipe", "burner-generator", "artillery-turret", "electric-turret", "fluid-turret", "rail-planner", "module", "night-vision-equipment", "energy-shield-equipment", "battery-equipment", "solar-panel-equipment", "generator-equipment", "active-defense-equipment", "movement-bonus-equipment", "roboport-equipment", "belt-immunity-equipment"}
Code: Select all
local all_item_types = {"ammo", "armor", "gun", "item", "capsule", "repair-tool", "tool", "item-with-entity-data", "item-subgroup", "rail-planner", "module", "night-vision-equipment", "energy-shield-equipment", "battery-equipment", "solar-panel-equipment", "generator-equipment", "active-defense-equipment", "movement-bonus-equipment", "roboport-equipment", "belt-immunity-equipment"}
Code: Select all
local all_entity_types = {"furnace", "transport-belt", "boiler", "container", "electric-pole", "generator", "offshore-pump", "inserter", "pipe", "radar", "lamp", "pipe-to-ground", "assembling-machine", "wall", "lab", "splitter", "underground-belt", "loader", "car", "roboport", "logistic-container", "construction-robot", "gate", "electric-energy-interface", "mining-drill", "resource", "ammo-turret", "solar-panel", "locomotive", "cargo-wagon", "fluid-wagon", "artillery-wagon", "land-mine", "train-stop", "rail-signal", "rail-chain-signal", "logistic-robot", "rocket-silo", "storage-tank", "pump", "accumulator", "beacon", "arithmetic-combinator", "decider-combinator", "constant-combinator", "power-switch", "programmable-speaker", "reactor", "heat-pipe", "burner-generator", "artillery-turret", "electric-turret", "fluid-turret"}