Created
December 16, 2019 21:31
-
-
Save Nercury/f67e8456edffe55715b10090880988d0 to your computer and use it in GitHub Desktop.
Transport Fever 2 circle on a map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local halfX = params.mapSizeX / 2 | |
local halfY = params.mapSizeY / 2 | |
result.layers:Constant(result.heightmapLayer, -10) | |
local pi = 3.1415923 | |
local mapEdge = 10 | |
local p = {} | |
local radius = math.min(halfX, halfY) - mapEdge | |
local circleSteps = 50 | |
for a = 0, circleSteps do | |
local angle = pi * 2 / circleSteps * a | |
p[#p + 1] = {halfX + radius * math.cos(angle), halfY + radius * math.sin(angle)} | |
end | |
-- local data = | |
local blob = {} | |
for x = 0, params.mapSizeX - 1 do | |
for y = 0, params.mapSizeY - 1 do | |
if polygonutil.contains(p, {x, y}) then | |
blob[#blob + 1] = {x, y} | |
end | |
end | |
end | |
result.layers:Points(result.heightmapLayer, blob, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment