No matter what I try I can't get a text centered on an entity as expected.
Example
Here's an example that creates a text rendering and a circle for comparison. The circle is centered as expected. But the text is nowhere near the center of the entity.
Code: Select all
/c
local p = game.player
local target = p.selected.position
p.teleport(target)
rendering.clear()
for scale=1, 4 do
rendering.draw_text {
text = '42',
surface = p.surface,
color = {r=1},
scale = scale,
scale_with_zoom = true,
alignment = 'center',
target = target,
}
rendering.draw_circle{
color = {g=1},
radius = scale,
width = 2,
filled = false,
target = target,
surface = p.surface,
}
end
The larger I set the scale the further the text moves away from the center. It's approximately one text-height away from the center.
It gets even weirder: When scale_with_zoom = true is set the text seems to be locked to an absolute *screen* position instead of an absolute world position.
I even found an old post by Bilka according to which this *should* work: