Allows rendering of geometric shapes, text and sprites in the game world. Each render object is identified by an id that is universally unique for the lifetime of a whole game.
draw_line{color = …, width = …, gap_length = …, dash_length = …, from = …, from_offset = …, to = …, to_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, only_in_alt_mode = …} → uint64 | Create a line. |
draw_text{text = …, surface = …, target = …, target_offset = …, color = …, scale = …, font = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, orientation = …, alignment = …, vertical_alignment = …, scale_with_zoom = …, only_in_alt_mode = …} → uint64 | Create a text. |
draw_circle{color = …, radius = …, width = …, filled = …, target = …, target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, only_in_alt_mode = …} → uint64 | Create a circle. |
draw_rectangle{color = …, width = …, filled = …, left_top = …, left_top_offset = …, right_bottom = …, right_bottom_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, only_in_alt_mode = …} → uint64 | Create a rectangle. |
draw_arc{color = …, max_radius = …, min_radius = …, start_angle = …, angle = …, target = …, target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, only_in_alt_mode = …} → uint64 | Create an arc. |
draw_polygon{color = …, vertices = …, target = …, target_offset = …, orientation = …, orientation_target = …, orientation_target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, draw_on_ground = …, only_in_alt_mode = …} → uint64 | Create a triangle mesh defined by a triangle strip. |
draw_sprite{sprite = …, orientation = …, x_scale = …, y_scale = …, tint = …, render_layer = …, orientation_target = …, orientation_target_offset = …, oriented_offset = …, target = …, target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, only_in_alt_mode = …} → uint64 | Create a sprite. |
draw_light{sprite = …, orientation = …, scale = …, intensity = …, minimum_darkness = …, oriented = …, color = …, target = …, target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, only_in_alt_mode = …} → uint64 | Create a light. |
draw_animation{animation = …, orientation = …, x_scale = …, y_scale = …, tint = …, render_layer = …, animation_speed = …, animation_offset = …, orientation_target = …, orientation_target_offset = …, oriented_offset = …, target = …, target_offset = …, surface = …, time_to_live = …, forces = …, players = …, visible = …, only_in_alt_mode = …} → uint64 | Create an animation. |
destroy(id) | Destroy the object with the given id. |
is_font_valid(font_name) → boolean | Does a font with this name exist? |
is_valid(id) → boolean | Does a valid object with this id exist? |
get_all_ids(mod_name) → array[uint64] | Gets an array of all valid object ids. |
clear(mod_name) | Destroys all render objects. |
get_type(id) → string | Gets the type of the given object. |
bring_to_front(id) | Reorder this object so that it is drawn in front of the already existing objects. |
get_surface(id) → LuaSurface | The surface the object with this id is rendered on. |
get_time_to_live(id) → uint | Get the time to live of the object with this id. |
set_time_to_live(id, time_to_live) | Set the time to live of the object with this id. |
get_forces(id) → array[LuaForce] | Get the forces that the object with this id is rendered to or nil if visible to all forces. |
set_forces(id, forces) | Set the forces that the object with this id is rendered to. |
get_players(id) → array[LuaPlayer] | Get the players that the object with this id is rendered to or nil if visible to all players. |
set_players(id, players) | Set the players that the object with this id is rendered to. |
get_visible(id) → boolean | Get whether this is rendered to anyone at all. |
set_visible(id, visible) | Set whether this is rendered to anyone at all. |
get_draw_on_ground(id) → boolean | Get whether this is being drawn on the ground, under most entities and sprites. |
set_draw_on_ground(id, draw_on_ground) | Set whether this is being drawn on the ground, under most entities and sprites. |
get_only_in_alt_mode(id) → boolean | Get whether this is only rendered in alt-mode. |
set_only_in_alt_mode(id, only_in_alt_mode) | Set whether this is only rendered in alt-mode. |
get_color(id) → Color | Get the color or tint of the object with this id. |
set_color(id, color) | Set the color or tint of the object with this id. |
get_width(id) → float | Get the width of the object with this id. |
set_width(id, width) | Set the width of the object with this id. |
get_from(id) → ScriptRenderTarget | Get from where the line with this id is drawn or nil if this object is not a line. |
set_from(id, from, from_offset) | Set from where the line with this id is drawn. |
get_to(id) → ScriptRenderTarget | Get where the line with this id is drawn to or nil if the object is not a line. |
set_to(id, to, to_offset) | Set where the line with this id is drawn to. |
get_dash_length(id) → double | Get the dash length of the line with this id or nil if the object is not a line. |
set_dash_length(id, dash_length) | Set the dash length of the line with this id. |
get_gap_length(id) → double | Get the length of the gaps in the line with this id or nil if the object is not a line. |
set_gap_length(id, gap_length) | Set the length of the gaps in the line with this id. |
set_dashes(id, dash_length, gap_length) | Set the length of the dashes and the length of the gaps in the line with this id. |
get_target(id) → ScriptRenderTarget | Get where the object with this id is drawn or nil if the object does not support target. |
set_target(id, target, target_offset) | Set where the object with this id is drawn. |
get_orientation(id) → RealOrientation | Get the orientation of the object with this id or nil if the object is not a text, polygon, sprite, light or animation. |
set_orientation(id, orientation) | Set the orientation of the object with this id. |
get_scale(id) → double | Get the scale of the text or light with this id or nil if the object is not a text or light. |
set_scale(id, scale) | Set the scale of the text or light with this id. |
get_text(id) → LocalisedString | Get the text that is displayed by the text with this id or nil if the object is not a text. |
set_text(id, text) | Set the text that is displayed by the text with this id. |
get_font(id) → string | Get the font of the text with this id or nil if the object is not a text. |
set_font(id, font) | Set the font of the text with this id. |
get_alignment(id) → string | Get the alignment of the text with this id or nil if the object is not a text. |
set_alignment(id, alignment) | Set the alignment of the text with this id. |
get_vertical_alignment(id) → string | Get the vertical alignment of the text with this id or nil if the object is not a text. |
set_vertical_alignment(id, alignment) | Set the vertical alignment of the text with this id. |
get_scale_with_zoom(id) → boolean | Get if the text with this id scales with player zoom or nil if the object is not a text. |
set_scale_with_zoom(id, scale_with_zoom) | Set if the text with this id scales with player zoom, resulting in it always being the same size on screen, and the size compared to the game world changes. |
get_filled(id) → boolean | Get if the circle or rectangle with this id is filled or nil if the object is not a circle or rectangle. |
set_filled(id, filled) | Set if the circle or rectangle with this id is filled. |
get_radius(id) → double | Get the radius of the circle with this id or nil if the object is not a circle. |
set_radius(id, radius) | Set the radius of the circle with this id. |
get_left_top(id) → ScriptRenderTarget | Get where top left corner of the rectangle with this id is drawn or nil if the object is not a rectangle. |
set_left_top(id, left_top, left_top_offset) | Set where top left corner of the rectangle with this id is drawn. |
get_right_bottom(id) → ScriptRenderTarget | Get where bottom right corner of the rectangle with this id is drawn or nil if the object is not a rectangle. |
set_right_bottom(id, right_bottom, right_bottom_offset) | Set where top bottom right of the rectangle with this id is drawn. |
set_corners(id, left_top, left_top_offset, right_bottom, right_bottom_offset) | Set the corners of the rectangle with this id. |
get_max_radius(id) → double | Get the radius of the outer edge of the arc with this id or nil if the object is not a arc. |
set_max_radius(id, max_radius) | Set the radius of the outer edge of the arc with this id. |
get_min_radius(id) → double | Get the radius of the inner edge of the arc with this id or nil if the object is not a arc. |
set_min_radius(id, min_radius) | Set the radius of the inner edge of the arc with this id. |
get_start_angle(id) → float | Get where the arc with this id starts or nil if the object is not a arc. |
set_start_angle(id, start_angle) | Set where the arc with this id starts. |
get_angle(id) → float | Get the angle of the arc with this id or nil if the object is not a arc. |
set_angle(id, angle) | Set the angle of the arc with this id. |
get_vertices(id) → array[ScriptRenderTarget] | Get the vertices of the polygon with this id or nil if the object is not a polygon. |
set_vertices(id, vertices) | Set the vertices of the polygon with this id. |
get_sprite(id) → SpritePath | Get the sprite of the sprite or light with this id or nil if the object is not a sprite or light. |
set_sprite(id, sprite) | Set the sprite of the sprite or light with this id. |
get_x_scale(id) → double | Get the horizontal scale of the sprite or animation with this id or nil if the object is not a sprite or animation. |
set_x_scale(id, x_scale) | Set the horizontal scale of the sprite or animation with this id. |
get_y_scale(id) → double | Get the vertical scale of the sprite or animation with this id or nil if the object is not a sprite or animation. |
set_y_scale(id, y_scale) | Set the vertical scale of the sprite or animation with this id. |
get_render_layer(id) → RenderLayer | Get the render layer of the sprite or animation with this id or nil if the object is not a sprite or animation. |
set_render_layer(id, render_layer) | Set the render layer of the sprite or animation with this id. |
get_orientation_target(id) → ScriptRenderTarget | The object rotates so that it faces this target. |
set_orientation_target(id, orientation_target, orientation_target_offset) | The object rotates so that it faces this target. |
get_oriented_offset(id) → Vector | Offsets the center of the sprite or animation if orientation_target is given. |
set_oriented_offset(id, oriented_offset) | Offsets the center of the sprite or animation if orientation_target is given. |
get_intensity(id) → float | Get the intensity of the light with this id or nil if the object is not a light. |
set_intensity(id, intensity) | Set the intensity of the light with this id. |
get_minimum_darkness(id) → float | Get the minimum darkness at which the light with this id is rendered or nil if the object is not a light. |
set_minimum_darkness(id, minimum_darkness) | Set the minimum darkness at which the light with this id is rendered. |
get_oriented(id) → boolean | Get if the light with this id is rendered has the same orientation as the target entity or nil if the object is not a light. |
set_oriented(id, oriented) | Set if the light with this id is rendered has the same orientation as the target entity. |
get_animation(id) → string | Get the animation prototype name of the animation with this id or nil if the object is not an animation. |
set_animation(id, animation) | Set the animation prototype name of the animation with this id. |
get_animation_speed(id) → double | Get the animation speed of the animation with this id or nil if the object is not an animation. |
set_animation_speed(id, animation_speed) | Set the animation speed of the animation with this id. |
get_animation_offset(id) → double | Get the animation offset of the animation with this id or nil if the object is not an animation. |
set_animation_offset(id, animation_offset) | Set the animation offset of the animation with this id. |
object_name :: string [R] | This object's name. |
Create a line.
from
is a LuaEntity.to
is a LuaEntity.rendering.draw_line{surface = game.player.surface, from = {0, 0}, to = {2, 2}, color = {1, 1, 1}, width = 2}
rendering.draw_line{surface = game.player.surface, from = {0, 0}, to = {0, 5}, color = {r = 1}, width = 3, gap_length = 1, dash_length = 1}
Create a text.
target
is a LuaEntity.Create a circle.
target
is a LuaEntity.Create a rectangle.
left_top
is a LuaEntity.right_bottom
is a LuaEntity.Create an arc.
target
is a LuaEntity.Create a triangle mesh defined by a triangle strip.
target
is a LuaEntity.orientation
is still applied.orientation_target
is a LuaEntity.Create a sprite.
orientation
is still applied to the sprite.orientation_target
is a LuaEntity.orientation_target
is given. This offset will rotate together with the sprite.target
is a LuaEntity.rendering.draw_sprite{sprite = "item.iron-plate", target = game.player.character, surface = game.player.surface}
rendering.draw_sprite{sprite = "item.iron-plate", target = game.player.character, target_offset = {0, -2}, surface = game.player.surface}
Create a light.
orientation
is still applied to the sprite.target
is a LuaEntity.light_medium
and light_small
for lights.Create an animation.
orientation
is still applied to the animation.orientation_target
is a LuaEntity.orientation_target
is given. This offset will rotate together with the animation.target
is a LuaEntity.Destroy the object with the given id.
Gets an array of all valid object ids.
Destroys all render objects.
Gets the type of the given object. The types are "text", "line", "circle", "rectangle", "arc", "polygon", "sprite", "light" and "animation".
Reorder this object so that it is drawn in front of the already existing objects.
Get the time to live of the object with this id. This will be 0 if the object does not expire.
Get the forces that the object with this id is rendered to or nil
if visible to all forces.
Set the forces that the object with this id is rendered to.
Get the players that the object with this id is rendered to or nil
if visible to all players.
Set the players that the object with this id is rendered to.
Get whether this is being drawn on the ground, under most entities and sprites.
Get the color or tint of the object with this id.
nil
if the object does not support color.Get the width of the object with this id. Value is in pixels (32 per tile).
nil
if the object does not support width. Get from where the line with this id is drawn or nil
if this object is not a line.
Get where the line with this id is drawn to or nil
if the object is not a line.
Get the dash length of the line with this id or nil
if the object is not a line.
Get the length of the gaps in the line with this id or nil
if the object is not a line.
Get where the object with this id is drawn or nil
if the object does not support target.
Set where the object with this id is drawn. Does nothing if this object does not support target.
Get the orientation of the object with this id or nil
if the object is not a text, polygon, sprite, light or animation.
Set the orientation of the object with this id. Does nothing if this object is not a text, polygon, sprite, light or animation.
Get the scale of the text or light with this id or nil
if the object is not a text or light.
Get the text that is displayed by the text with this id or nil
if the object is not a text.
Set the text that is displayed by the text with this id. Does nothing if this object is not a text.
Get the font of the text with this id or nil
if the object is not a text.
Get the alignment of the text with this id or nil
if the object is not a text.
Get the vertical alignment of the text with this id or nil
if the object is not a text.
Get if the text with this id scales with player zoom or nil
if the object is not a text.
Get if the circle or rectangle with this id is filled or nil
if the object is not a circle or rectangle.
Get the radius of the circle with this id or nil
if the object is not a circle.
Get where top left corner of the rectangle with this id is drawn or nil
if the object is not a rectangle.
Get where bottom right corner of the rectangle with this id is drawn or nil
if the object is not a rectangle.
Get the radius of the outer edge of the arc with this id or nil
if the object is not a arc.
Get the radius of the inner edge of the arc with this id or nil
if the object is not a arc.
Get where the arc with this id starts or nil
if the object is not a arc.
Get the angle of the arc with this id or nil
if the object is not a arc.
Get the vertices of the polygon with this id or nil
if the object is not a polygon.
Set the vertices of the polygon with this id. Does nothing if this object is not a polygon.
Get the sprite of the sprite or light with this id or nil
if the object is not a sprite or light.
Set the sprite of the sprite or light with this id. Does nothing if this object is not a sprite or light.
Get the horizontal scale of the sprite or animation with this id or nil
if the object is not a sprite or animation.
Get the vertical scale of the sprite or animation with this id or nil
if the object is not a sprite or animation.
Get the render layer of the sprite or animation with this id or nil
if the object is not a sprite or animation.
Set the render layer of the sprite or animation with this id. Does nothing if this object is not a sprite or animation.
The object rotates so that it faces this target. Note that orientation
is still applied to the object.
Get the orientation_target of the object with this id or nil
if no target or if this object is not a polygon, sprite, or animation.
The object rotates so that it faces this target. Note that orientation
is still applied to the object.
Set the orientation_target of the object with this id. Does nothing if this object is not a polygon, sprite, or animation.
Set to nil
if the object should not have an orientation_target.
Offsets the center of the sprite or animation if orientation_target
is given. This offset will rotate together with the sprite or animation.
Get the oriented_offset of the sprite or animation with this id or nil
if this object is not a sprite or animation.
Offsets the center of the sprite or animation if orientation_target
is given. This offset will rotate together with the sprite or animation.
Set the oriented_offset of the sprite or animation with this id. Does nothing if this object is not a sprite or animation.
Get the intensity of the light with this id or nil
if the object is not a light.
Get the minimum darkness at which the light with this id is rendered or nil
if the object is not a light.
Get if the light with this id is rendered has the same orientation as the target entity or nil
if the object is not a light.
Note that orientation
is still applied to the sprite.
Get the animation prototype name of the animation with this id or nil
if the object is not an animation.
Get the animation speed of the animation with this id or nil
if the object is not an animation.
Get the animation offset of the animation with this id or nil
if the object is not an animation.
This object's name.