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!
How to use the LuaRendering
-
- Inserter
- Posts: 22
- Joined: Mon Jun 27, 2016 4:20 pm
- Contact:
Re: How to use the LuaRendering
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:
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}
})
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
-
- Inserter
- Posts: 22
- Joined: Mon Jun 27, 2016 4:20 pm
- Contact:
Re: How to use the LuaRendering
Thank You! That worked nicely. I just needed an example to understand how its used.Bilka wrote: ↑Wed Mar 27, 2019 6:30 pmMoved 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} })