Page 1 of 1

Best way to add notes that can persist through blueprints

Posted: Wed Jan 25, 2017 6:31 pm
by NiftyManiac
StickyNotes is a great mod, but I really want to be able to annotate my combinators with notes, and have those notes persist through blueprint creation/deployment. Since StickyNotes uses a global table to link entities to notes, it cannot know where to put the notes when a blueprint is placed, since a newly-placed entity has no reference to the original annotated entity.

So far my best idea is:
Create an invisible non-operable entity based on constant-combinator;
When the user wants to create a note, the text is encoded in the contents of the invisible combinator. 4 bytes per signal*15 slots is enough characters for me, and signal types can add a few more bits to each slot. The invisible combinator is placed at the same coordinates as the entity to be annotated;
When a blueprint is made the invisible note should come with it by virtue of it's location;
When entities are created/destroyed the corresponding note entity if it exists is shown/destroyed/etc.

Can someone tell me that this is crazy and there's a simpler solution? I'm new to modding factorio, so I'm hoping I overlooked a more sane approach. Or else, if there's something about my approach that won't work.

Re: Best way to add notes that can persist through blueprints

Posted: Wed Jan 25, 2017 7:01 pm
by Adil
It's good. If you can come up with encoding\decoding algorithm.

Though you don't need to actually encode the message, you can encode a simple unique id under which the message would be stored in global. table.
(And when another note is built with the signal already existing, you can look up that id and copy the message to a new position.)

You'll probably have to keep the global table anyway as you'd need to track associations between various entities. (the text entity, the hidden combinator and whatever is that you put it on)

Re: Best way to add notes that can persist through blueprints

Posted: Wed Jan 25, 2017 9:35 pm
by DaveMcW
Yes, constant combinator is the best way to store data in blueprints.

I would avoid encoding bits in item types, because any item change in future Factorio versions would break your scheme.

Re: Best way to add notes that can persist through blueprints

Posted: Thu Jan 26, 2017 4:44 am
by NiftyManiac
Adil wrote:It's good. If you can come up with encoding\decoding algorithm.
That's the easy part :)
Adil wrote:Though you don't need to actually encode the message, you can encode a simple unique id under which the message would be stored in global. table.
True, but I'd also like to be able to use the blueprints between games or share them online, and that would require that everything be encoded in the blueprint itself.
DaveMcW wrote: I would avoid encoding bits in item types, because any item change in future Factorio versions would break your scheme.
Good point. I think the virtual signals, at least letters/numbers, can be relied on. So that'd give me a nice extra 5 bits per cell.

Re: Best way to add notes that can persist through blueprints

Posted: Thu Jan 26, 2017 8:14 pm
by NiftyManiac
The bit-optimization I was thinking about is silly, I didn't realize I could just increase the item-slot-count of my constant combinator.

Seems to be working well so far, I'll publish it when I fix the graphics.