Factorissimo2


Factorissimo adds factory buildings to Factorio. Place them down, walk in, build your factories inside!

Content
3 years ago
0.14 - 1.1
222K

g Since we are at cloning....

5 years ago
(updated 5 years ago)

Hello,

would you even like to add deep copying/cloning of a factory?

i made a proof of concept to add it to your mod. It works. Even recursively.

What i did:
To copy a factory item (not placed) i create a new factory with the "createInterior" function and then circle through all entities in the sources area and cloning them to the new surface. If the nested entity is another factory, i handle that and builds its exterior too and so it also works recursively.

All the best, Gerald

5 years ago

Yes, it sounds easy to do in practice, but I'd rather make cloning move factory buildings than cause players to accidentally make a hundred UPS-hungry stealth clones of their factory buildings, because some mods use cloning as teleportation (e.g. Warptorio), because actual teleportation doesn't work on most entities. I suppose I could add a mod setting, with a warning label, that toggles between moving and cloning.

5 years ago
(updated 5 years ago)

Thank you for your answer.

One could also move the deep cloning into a separate function, which is independent from the clone-hook. Exposing this function via remote interfaces would allow other mods to use this feature, and prevent unaccounted cloning. Other mod-authors could wrap there heads around the question, how to integrate it as a balanced feature ;)

I am lazy, so i am going for the cloning-wand of opness, but there seem to be a lot more balanced options, like counting the items to clone and create some kind of dynamic recipe within a new assembling/cloning machine.

My knowledge of lua and factorio modding is quite little, so have i have another question:

What prevents you from using just a single surface by alternating the factories position. You already do something like that in "create_factory_position". what am i overlooking?

5 years ago
(updated 5 years ago)

Deep cloning is no problem, if that's what you wanted to do with it.

To maintain the teleport function, that's as simple as move the "event" function to a remote.add_interface("Factorissimo",{ teleport_factory=cmdTeleportFactory })

5 years ago
(updated 5 years ago)

yeah, its a design decision. one could also expose both methods. teleporting and deepcopy. while also accounting for given settings in the cloneevent function, like magmamcfry suggested in his comment.

edit: just realized i am talking to two different people :)

5 years ago

yeah, its a design decision.

There's also a consideration of the complexity, and how long it takes to actually get such a feature to work reliably.
I think it's important to ask, is it worth it?
Every "feature" is another place where something can go wrong.
Current implementation avoids errors for the sake of simplicity and minimization of potential problems.

Though if you really want factory recursion, it is likely you can achieve something to that effect from a 3rd party mod anyway, particularly if factorissimo has script_raise_built hooked. That way all you would need to do is write the code to do it :)

5 years ago
(updated 5 years ago)

Wouldnt this only allow to hook into an already started building generation?
One could still account for somehow clone-marked factories and create the cloned interior machines at this point.

But this narrows the possible features. you only get the factory at building/placing time. so for example, you cant determine the worth of the interior and create a dynamic recipe passed on that.
EDIT: you dont have the source factory in this scenario. cant imagine a way to make it work like this.


I would prefer a remote call to create a copy. Or even simpler just one to create a factory spot. So you dont have to place the factory as you create it.

In my proof of concept i created a single method to clone a factory within the mod. This creates the factory spot, saves it in the mods data structure , creates the inner building and recursive factories and returns the root-factorys entity.

At first for testing i triggered this at mining time. So you just got 2 factories for mining one.

But now i am setting up an external mod to call the particular function via remote and create the copy by clicking on it with an item. Only problem, i couldnt yet figure out how to hook on the leftclick of a non-placable entity. If i get this to work, i will probably be satisfied for my own playthrough. :)


LAST EDIT: Got it working for me. But its quite buggy. for example: in inner factories, one needs to rebuild the connection belt tiles, because the teleportation-thing gets thrown off if the factory is cloned. - items on belts get cloned too etc. etc. - But thats good enough for me.
Thanks for this amazing mod. All the best.

New response