Best way to add notes that can persist through blueprints

Place to get help with not working mods / modding interface.
NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

Best way to add notes that can persist through blueprints

Post 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.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

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

Post 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)
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

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

Post 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.
NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

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

Post 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.
Last edited by NiftyManiac on Thu Jan 26, 2017 8:15 pm, edited 1 time in total.
NiftyManiac
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Jan 21, 2017 12:01 am
Contact:

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

Post 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.
Post Reply

Return to “Modding help”