Saving entity custom data to blueprint

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
thelordodin
Fast Inserter
Fast Inserter
Posts: 113
Joined: Fri Jan 06, 2017 1:54 am
Contact:

Saving entity custom data to blueprint

Post by thelordodin » Tue Jun 13, 2017 7:02 am

I'm wtiring a ComplexCombinator mod (viewtopic.php?f=97&t=49691). This entity have many settings which is set with custom gui.
I bind this data to the entity by position key, this way I can read and write it inside the game, but, it can't handle blueprints...

So, is there a way to save some custom data with my entity into blueprint?

If there is no way I suggest adding a lua table property "mod_data" to LuaEntity class.

(No answer on "Modding help" forum, so I post it here...)

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1164
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Saving entity custom data to blueprint

Post by Mooncat » Tue Jun 13, 2017 8:22 am

You can create a combinator that can actually stores circuit signals, so your custom data can be stored in blueprint in the form of signals. But you will need to convert the signals from and to your data. It is not easy.

+1 for the request for adding custom entity data support in blueprint.

The request was also made long time ago: viewtopic.php?f=28&t=14898&p=213571

Hopefully we can set custom table in entity, and such table can be stored in blueprint.
(My 1000th post. :P )

thelordodin
Fast Inserter
Fast Inserter
Posts: 113
Joined: Fri Jan 06, 2017 1:54 am
Contact:

Re: Saving entity custom data to blueprint

Post by thelordodin » Tue Jun 13, 2017 10:43 am

Mooncat wrote:You can create a combinator that can actually stores circuit signals, so your custom data can be stored in blueprint in the form of signals. But you will need to convert the signals from and to your data. It is not easy.
Have anyone done this before me? Do you know of any mods implementing this?

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1164
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Saving entity custom data to blueprint

Post by Mooncat » Tue Jun 13, 2017 12:50 pm

thelordodin wrote:
Mooncat wrote:You can create a combinator that can actually stores circuit signals, so your custom data can be stored in blueprint in the form of signals. But you will need to convert the signals from and to your data. It is not easy.
Have anyone done this before me? Do you know of any mods implementing this?
https://mods.factorio.com/mods/NiftyManiac/StickyNotes
https://mods.factorio.com/mods/Earendel/textplates

thelordodin
Fast Inserter
Fast Inserter
Posts: 113
Joined: Fri Jan 06, 2017 1:54 am
Contact:

Re: Saving entity custom data to blueprint

Post by thelordodin » Tue Jun 13, 2017 3:59 pm

Mooncat, thank you very much !

I've made a library for this problem. Haven't runned it yet (i can't run factorio now), so its untested for the moment.

--------------------------------------------------------------------------------------------------------------------------------
-- Author: thelordodin
-- Special thanks to Mooncat - who guided me how to do this.
-- License: free to copy, change, and use in any projects. No warranty.
--------------------------------------------------------------------------------------------------------------------------------
This library allows you to save custom data to combinator entiry.
Custom data must be in lua table format.

Data is stored as values of signals in combinator.

To save data to combinator use:
write_to_combinator(combinator, data)

To load:
data = read_from_combinator(combinator)

This library uses MessagePack to pack the table, so it'll be stored in quite compact format, hovewer
be warned that data size is still very limited and is determinated by item_slot_count parameter of combinator.

Not deeply tested lib, but works somehow.
Attachments
blueprint_custom_data.zip
(7.14 KiB) Downloaded 35 times

thelordodin
Fast Inserter
Fast Inserter
Posts: 113
Joined: Fri Jan 06, 2017 1:54 am
Contact:

Re: Saving entity custom data to blueprint

Post by thelordodin » Tue Jun 13, 2017 8:11 pm

After testing I've changed lib in previous post to working one.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: No registered users