https://lua-api.factorio.com/latest/Lua ... rtTag.html shows:
Code: Select all
class LuaCustomChartTag
...
position :: Position [R] The position of this tag.
...
So I can imagine of the following ways to achieve this:
- API allows write to "position". So I can simply change that on event "on_chart_tag_added".
- API adds a new event "on_pre_chart_tag_added", so I can modify that before it is read-only.
- Within event "on_chart_tag_added", I will clone the tag, modify the value, then use "force.add_chart_tag(surface, newtag)". Then destroy the "old" tag.
Method 3 has the problem of recursive calling... Using "force.add_chart_tag(surface, newtag)" will trigger another event "on_chart_tag_added". There seems to be no way to distinguish if the tag is created by script or by actual player clicking on map.
Method 1 and 2 both require API changes.
TL;DR
So if there are other workarounds, may I request either of these API changes:
- LuaCustomChartTag::position is also writable. (Thus [RW].)
- New event "on_pre_chart_tag_added", which is executed before a tag is really added to the map. Most importantly, "position" can be modified in this event.
Schall