Last active
June 11, 2022 03:35
-
-
Save Drumsin/efe8e18c0933fdf374c88ba1964b67c4 to your computer and use it in GitHub Desktop.
AoE4 Generated Map Function: Draw Box
This file contains 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
--draws a box starting from top left coordinates and expands down and to the right | |
--copy and paste code to preview at https://aoe4.app/ | |
--rowCoord is the top left row of where your box draw begins | |
--colCoord is the top left col of where your box draw begins | |
--rowSize how far down do you want to draw your box | |
--colSize how far across do you want to draw your box | |
--pickedTerrain the terrainType e.g. tt_lake_shallow | |
function drawBox(rowCoord, colCoord, rowSize, colSize, pickedTerrain) | |
--checks to see if coords exist in table | |
--used to prevent out of bounds areas from being set | |
local function isInTable(searchTable, row, col) | |
if (searchTable[row] ~= nil and searchTable[col] ~= nil) then | |
result = true | |
else | |
result = false | |
end | |
return result | |
end | |
drawRowSize = rowCoord + rowSize - 1 | |
drawColSize = colCoord + colSize - 1 | |
for row = rowCoord, drawRowSize do | |
for col = colCoord, drawColSize do | |
if (isInTable(terrainLayoutResult, row, col)) then | |
terrainLayoutResult[row][col].terrainType = pickedTerrain | |
end | |
end | |
end | |
end | |
--example | |
drawBox(mapQuarterSize, mapQuarterSize, mapHalfSize, mapHalfSize, tt_lake_shallow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment