option for LuaForce.clear_chart to not remove tags

Things that we aren't going to implement
thesixthroc
Inserter
Inserter
Posts: 47
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: 14678
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: 421
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
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
curiosity
Filter Inserter
Filter Inserter
Posts: 521
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: 421
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
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
BenSeidel
Filter Inserter
Filter Inserter
Posts: 591
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: 47
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: 521
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: 2164
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.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Post Reply

Return to “Won't implement”