1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/shape/donut.lua

36 lines
928 B
Lua
Raw Normal View History

--Donut script by Neko_Baron - tested on RedMew
--change these to mess with ring/shape
local donut_radius = 1600
local donut_width = 128
--dont touch these
local donut_half = donut_width * 0.5
local x_offset = donut_radius - donut_half
local donut_low = x_offset^2
local donut_high = (x_offset+donut_width)^2
function run_shape_module(event)
2017-07-18 21:29:12 +02:00
local area = event.area
local surface = event.surface
local tiles = {}
2017-07-18 21:29:12 +02:00
local top_left = area.left_top --make a more direct reference
2017-07-18 21:29:12 +02:00
for x = top_left.x-1, top_left.x + 32 do
2017-07-18 21:29:12 +02:00
for y = top_left.y-1, top_left.y + 32 do
local x_off = x - donut_radius
local distance = x_off^2 + y^2 -- we dont bother to get sqr of it, because we just want the cubed answer to compare to donut_low/high
if distance > donut_high or distance < donut_low then
2017-07-18 21:29:12 +02:00
table.insert(tiles, {name = "out-of-map", position = {x,y}})
end
end
end
surface.set_tiles(tiles)
2017-07-18 21:29:12 +02:00
return true
2017-07-18 21:29:12 +02:00
end