Page 1 of 1
How to use the LuaRendering
Posted: Wed Mar 27, 2019 6:11 pm
by ProfoundDisputes
I am looking at this LuaRendering api and I have no idea where to start to do anything. All I want to do is draw a rectangle centered around the player. I am essentially trying to replicate the personal roboport range visualization.
If anyone could help me figure this out that would be great! Thank You!
Re: How to use the LuaRendering
Posted: Wed Mar 27, 2019 6:30 pm
by Bilka
Moved to modding help.
Drawing a rectangle is pretty straight forward.
https://lua-api.factorio.com/latest/Lua ... _rectangle is used for that, so you can now figure out the properties that you want. Since you say you want it like the radius visualization, you will want it to be filled, drawn on ground and some color. Drawing around the player can be done using the targets + offsets. Here is a console command that does what you want:
Code: Select all
/c local radius = 5
rendering.draw_rectangle({
surface= game.player.surface,
filled = true,
draw_on_ground = true,
color = {r=0.2,g=0.2,b=0,a=0.5},
left_top = game.player.character,
left_top_offset = {-radius,-radius},
right_bottom = game.player.character,
right_bottom_offset = {radius,radius}
})
Re: How to use the LuaRendering
Posted: Fri Mar 29, 2019 7:45 pm
by ProfoundDisputes
Bilka wrote: ↑Wed Mar 27, 2019 6:30 pm
Moved to modding help.
Drawing a rectangle is pretty straight forward.
https://lua-api.factorio.com/latest/Lua ... _rectangle is used for that, so you can now figure out the properties that you want. Since you say you want it like the radius visualization, you will want it to be filled, drawn on ground and some color. Drawing around the player can be done using the targets + offsets. Here is a console command that does what you want:
Code: Select all
/c local radius = 5
rendering.draw_rectangle({
surface= game.player.surface,
filled = true,
draw_on_ground = true,
color = {r=0.2,g=0.2,b=0,a=0.5},
left_top = game.player.character,
left_top_offset = {-radius,-radius},
right_bottom = game.player.character,
right_bottom_offset = {radius,radius}
})
Thank You! That worked nicely. I just needed an example to understand how its used.