Factorissimo2


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

Content
2 years ago
0.14 - 1.1
208K

b Why does factorissimo not support cloning?

4 years ago
(updated 4 years ago)

Hi, this has compatability issues with my mod and it's on you.

https://mods.factorio.com/mod/warptorio2/discussion/5d4c69100f9321000c7830d5

Basically, this mod, warptorio, teleports all structures and machines and such on a small platform between randomized factorio surfaces periodically.
It does this through the use of cloning.

Basically, you just need to hook the event
https://lua-api.factorio.com/latest/events.html#on_entity_cloned
and update your warehouse data accordingly to the destination entity (probably destroying the old one in the process just for cleanliness?)

Please & thankyou.

4 years ago
(updated 4 years ago)

There are two ways Factorissimo could support cloning: One way would be to just move the factory building to the new location, removing it from the old location, another way would be to create a clone of the entire interior (possibly recursively cloning subfactories in the process) and create a real clone according to the intended meaning of the LuaEntity.clone method.

Should I implement cloning like you want it to work, or should I do it "correctly"? If I do it properly, then your mod will basically cause a "factory leak" in which the clone survives, but the original is rendered inaccessible while still existing and taking up UPS, once per factory per warp. If I do it like you want it to work, then any mod or player that wants to use cloning as intended will be sad.

4 years ago
(updated 4 years ago)

Heya, thankyou for quick response!

Whichever route you decide to take, neither is currently possible.
I think the method i have suggested is the cleanest and simplest, but how it is done is not of any real concern.
Heck even if there was only a remote call i could use, as an exception for the factories can be expected.
Though... when you say cloning the factories and surfaces recursively, yes that's a factory leak and i've been told there's a limit of 100 or 255 surfaces or something, hence why i don't think any actual cloning needs to take place.
It is primarily just to teleport the factory entrance to a different surface.
Might you have other suggestions?

My suggestion simply accounts for the potential errors and would blindly "correct" them, and without my needing to learn up on whatever caching and whatnot you've got going on with your mod. It's huge! (And well done too btw <3)

I was thinking maybe i missed entity.teleport() by your suggestion.
So i tried it and:

Given the size of your mod i think it's fair to say people are willing to make an exception for factorissimo, as long as the goal is possible.
Case in point example: https://mods.factorio.com/mod/Dirt_Path

4 years ago
(updated 4 years ago)

Fine.

I've found a way to fool your mod into working properly, but it's a very dodgy way to do it.
1. Order deconstruction, forcing factorissimo to destroy the warehouse, save factory data and spawn the entity i actually need to copy. (would be nice if there were remote commands to do this)
2. copy the entity [factory-1-s10]
3. cancel deconstruction of all "factory-" named entities.

While going through your events i also found a "factory leak" that you speak of by doing:
1. Order deconstruction of a factory
2. Destroy it
3. lol this isn't checked in your on_entity_died hook.
Incidentally, if you fix this bug you'll break my work-around.

Please give remote commands to properly interface with factorissimo so i don't have to resort to very glitchy and hacky methods. Thankyou.

4 years ago
(updated 4 years ago)

Here is a patch for Warptorio compatibility. In theory it should work, unfortunately there seems to be a bug in Factorio's clone_entities method:

If you run surface.clone_entities{entities={e1, e2, e3}, ...}, and the clone events are in order e1, e2, e3, but the on_entity_cloned event of e2 deletes e1 and e3, then clones of e1, e2, e3 will all be created, but there will be no on_entity_cloned event for e3.

This is probably worth an official bug report, but if you want to work around that in the meantime, you'll need to call clone for each entity in etbl individually, checking whether the entity is valid right before cloning it.

(The effect of this bug in practice is that a bunch of disconnected auxiliary entities appear beneath the cloned factory building, causing all sorts of trouble, e.g. messing with pipe connectivity, and persisting after the factory building is moved.)

4 years ago
(updated 4 years ago)

This doesn't seem to be the only bug with cloning: https://forums.factorio.com/viewtopic.php?f=7&t=74363
I suspect individual cloning may also be more reliable, and doing so actually returns the clone that was created where doing it on the surface does not. I'm not very experienced with the factorio api, but i know my luas :)

Thank you!! <3

4 years ago

fyi the cloning seems to duplicate the "external overlay" for the factory buildings and thus,
if you pick up the factory building after warping, the overlay will stay, and you can use an inserters to pull the items out of (or put into) it like a chest, allowing for item duping, 4 stack of items, per chest, per factory, per warp.

Thankfully doesn't seem to duplicate exponentially.

side note: interesting thing happens when you get the warptorio "mirror world" as well,
it makes a fake building that has no collision or interior, similar to what happens when you try to use PIcker Dollies on a factory building.

4 years ago

I figured i would need to add some entities to the blacklist. i'll check it out later.

mirror world - i guess it's mirroring player built entities? it probably shouldn't be doing that lol.

4 years ago
(updated 4 years ago)

so uh, the item duping i described doesn't even need to warp for that to happen, you can just do that "normally" with factorisimo
https://gyazo.com/ec80a77e326d21657d760f5e414d130b
and even if the box wasn't right on the edge so that inserter couldn't reach, bob's inserters could reach like half way across it

New response