option for LuaForce.clear_chart to not remove tags

Things that we aren't going to implement
Post Reply
thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

option for LuaForce.clear_chart to not remove tags

Post by thesixthroc »

For a mod I'm making, I'd like to be able to clear the chart without tags disappearing. I assume that clear_chart just nils the chart, but would it be possible to provide a way to clear the chart but leaving the tags?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13175
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by Rseding91 »

Unfortunately; no. The tags are stored directly on the chart itself so if the chart is removed so are the tags.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 310
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by Stringweasel »

You could always work around it. Use find_chart_tags to find all the tags in the area you want to clear and remember them, and after you cleared the chart you add_chart_tag them all back in.
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

curiosity
Filter Inserter
Filter Inserter
Posts: 315
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by curiosity »

Stringweasel wrote:
Tue Mar 15, 2022 7:58 am
You could always work around it. Use find_chart_tags to find all the tags in the area you want to clear and remember them, and after you cleared the chart you add_chart_tag them all back in.
It's more complicated than that:
add_chart_tag wrote:Note
The chunk must be charted for a tag to be valid at that location.

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 310
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by Stringweasel »

curiosity wrote:
Tue Mar 15, 2022 10:55 am
It's more complicated than that:
Ahh, thought there might be something like that lurking with Rseding said that tags are stored in the chart. Thanks for clarifying :)
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

BenSeidel
Filter Inserter
Filter Inserter
Posts: 584
Joined: Tue Jun 28, 2016 1:44 am
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by BenSeidel »

Stringweasel wrote:
Tue Mar 15, 2022 7:58 am
could always work around it. Use find_chart_tags to find all the tags in the area you want to clear and remember them, and after you cleared the chart you add_chart_tag them all back in.
This would work if you store the tags when the chunk is cleared, but restore them in the on_chunk_charted event

thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by thesixthroc »

There is a subtle reason I haven't tried; I want to perform this action every tick, on multiplayer. Ne pas.

curiosity
Filter Inserter
Filter Inserter
Posts: 315
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by curiosity »

thesixthroc wrote:
Fri Mar 18, 2022 9:07 pm
There is a subtle reason I haven't tried; I want to perform this action every tick, on multiplayer. Ne pas.
If you just want to get rid of the mapping of terrain, you can set map size to something very small and generate the actual map during runtime.

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: option for LuaForce.clear_chart to not remove tags

Post by Qon »

thesixthroc wrote:
Fri Mar 18, 2022 9:07 pm
There is a subtle reason I haven't tried; I want to perform this action every tick, on multiplayer. Ne pas.
Setting a chart tag shouldn't be extremely expensive. It should be very cheap even if it's done in lua compared to chunk generation. Restoring chart tags every tick is possible to do quickly if you use tables with chunk location as index.

Post Reply

Return to “Won't implement”