Page 1 of 1

Make surface optional by the LuaRendering

Posted: Sun May 24, 2020 12:32 pm
by darkfrei
Hi devs!

Here is the example:

Code: Select all

/c
local entity = game.player.selected
rendering.draw_light {sprite = "utility/light_medium", surface = entity.surface, target = entity}
https://lua-api.factorio.com/latest/Lua ... draw_light
2020-05-24T14_36_18-Window.png
2020-05-24T14_36_18-Window.png (43.63 KiB) Viewed 937 times
Why the surface is not optional here? The entity already defines rendering surface, why it cannot be optional? The same for sprite and geometry for situations, where the target is an entity.

https://lua-api.factorio.com/latest/LuaRendering.html

Re: Make surface optional by the LuaRendering

Posted: Sun May 24, 2020 2:42 pm
by Rseding91
The target being an entity does not mean the sprite renders on that surface or as that sprite. All it does is make the light go away when the target does, and make it render with the orientation of that target.

Re: Make surface optional by the LuaRendering

Posted: Sun May 24, 2020 3:05 pm
by darkfrei
Rseding91 wrote:
Sun May 24, 2020 2:42 pm
The target being an entity does not mean the sprite renders on that surface or as that sprite. All it does is make the light go away when the target does, and make it render with the orientation of that target.
But if surface was not defined, can it be rendered on the defined entity's surface?

Pseudocode:

Code: Select all

local surface = surface or target.entity and target.entity.surface