I'm having issues when trying to grab a mining-drill entity's mining target whenever it is created. It seems to only get it on the first tick it runs, even though it's a pump jack. I tried using find_entities_filtered on the area where it spawns, but it doesn't return what I need. It seems to return a userdata block thing that appears as a luaentity but isn't useful at all for table matching with pre-existing LuaEntity objects.
What should I do about this?
Grabbing mining_target for an entity on creation
-
- Inserter
- Posts: 20
- Joined: Fri Sep 15, 2023 12:01 pm
- Contact:
- Stringweasel
- Filter Inserter
- Posts: 416
- Joined: Thu Apr 27, 2017 8:22 pm
- Contact:
Re: Grabbing mining_target for an entity on creation
I think here is the issue. If you can't get mining_target immediatelly then finding it manually as you did seems like the right approach. And you seem to have done it correctly, and just missinterpreted the results.redplasticstraw wrote: ↑Wed Aug 21, 2024 4:52 am I tried using find_entities_filtered on the area where it spawns, but it doesn't return what I need. It seems to return a userdata block thing that appears as a luaentity but isn't useful at all for table matching with pre-existing LuaEntity objects.
find_entities_filtered returns an array of LuaEntity, which is what you want. If you try to print or log this though then it shoes user-data-something, beause it's not a real table.
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock |Weasel's Demolition Derby
Official Contributor to Space Exploration
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock |
Official Contributor to Space Exploration
-
- Inserter
- Posts: 20
- Joined: Fri Sep 15, 2023 12:01 pm
- Contact:
Re: Grabbing mining_target for an entity on creation
It only becomes an issue because I have two separate scripts, one to store mining patches and one to store the machines that go on those mining patches. The way I had the patches indexed was by entity so I could use mining_target on the machines and just grab the associated patch, but it just looks like I'll have to use the filtered for both indexes instead of the actual entity itself.
Thanks!
Thanks!
- Stringweasel
- Filter Inserter
- Posts: 416
- Joined: Thu Apr 27, 2017 8:22 pm
- Contact:
Re: Grabbing mining_target for an entity on creation
I see. What modders usually use is unit_number.
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock |Weasel's Demolition Derby
Official Contributor to Space Exploration
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock |
Official Contributor to Space Exploration