I'm working on my first Factorio mod but I'm having trouble figuring out the not-quite-basics of the modding system. So here's a pile of questions! Note that I'm happy to read existing mods in order to find answers, so if your answer is "Mod X does that" then I can probably untangle it from there.
I'm looking to create a chest that automatically spawns/despawns items inside it for the purpose of testing layouts. I basically want a Requester chest that, at all times, contains exactly the requested items. As near as I can tell it's not possible to add the Request chest UI easily to an existing chest (is that true?), so I was planning to just make another chest with the logistics settings of a Requester chest and let the game code take care of that. (Is that reasonable?)
However, this means I'll either need to track every time an item is removed from one of my chests (is that possible? I don't think so) or update all of my chests every once in a while. The latter seems reasonable to me, but I can't find any way to list all entities of a given type (is there one?)
It seems like the expected way to do this is to store a list of all entities of this type when they're placed, and clean them up when they're removed (is that true?) but I can't figure out how to do that, nor what exactly I should be storing in a list (positions? actual entity handles?). Also, if I do do this, I'll need some way to serialize that list on shutdown, and I'm having trouble untangling how the save/load systems work.
I'm also not 100% sure it's possible for me to retrieve the list of requested items from a chest, but I haven't even gotten that far yet; at least it seems easy to add/remove things from a chest.
So if anyone can point me at a small mod or two that do similar things, or give me the necessary keywords to look for in order to find out more, I'd be eternally grateful!
Infinite chest mod: give me some pointers please!
Re: Infinite chest mod: give me some pointers please!
trueZorbaTHut wrote: I'm looking to create a chest that automatically spawns/despawns items inside it for the purpose of testing layouts. I basically want a Requester chest that, at all times, contains exactly the requested items. As near as I can tell it's not possible to add the Request chest UI easily to an existing chest (is that true?),
This chest still will work as requester chest. If you don't care, than it's basically the only way to go.ZorbaTHut wrote:so I was planning to just make another chest with the logistics settings of a Requester chest and let the game code take care of that. (Is that reasonable?)
Yes, it's impossible atm.ZorbaTHut wrote: However, this means I'll either need to track every time an item is removed from one of my chests (is that possible? I don't think so)
No, there isn't.ZorbaTHut wrote: or update all of my chests every once in a while. The latter seems reasonable to me, but I can't find any way to list all entities of a given type (is there one?)
trueZorbaTHut wrote:It seems like the expected way to do this is to store a list of all entities of this type when they're placed, and clean them up when they're removed (is that true?)
There are game events for entities placing, mining, destruction. Look carefully at events on wiki. here.ZorbaTHut wrote:but I can't figure out how to do that, nor what exactly I should be storing in a list (positions? actual entity handles?).
IMO the best way is position (as text) as a key and entity as value.
Everything stored in 'glob' global variable is serialized on save and deserialized on load. Including entities, but only as values, not as keys.ZorbaTHut wrote: Also, if I do do this, I'll need some way to serialize that list on shutdown, and I'm having trouble untangling how the save/load systems work.
It is possible to get/set requested items of requester chest. (get|set)requestslot method of entity.here.ZorbaTHut wrote:I'm also not 100% sure it's possible for me to retrieve the list of requested items from a chest, but I haven't even gotten that far yet; at least it seems easy to add/remove things from a chest.
Re: Infinite chest mod: give me some pointers please!
Just what I needed! Thank you very muchXecutor wrote: every answer imaginable
Re: Infinite chest mod: give me some pointers please!
OS: Linux Mint 19 x64 | desktop: Awesome 4.2 | Intel Core i5 8600k | 16GB DDR4 | NVidia GTX 1050 Ti (driver version: 410.104) (2019-03)
Re: Infinite chest mod: give me some pointers please!
If you want to see how other people have solved this you can have a look at the creative mode chest mod here:
https://forums.factorio.com/forum/vie ... =14&t=8976
https://forums.factorio.com/forum/vie ... =14&t=8976