-
Notifications
You must be signed in to change notification settings - Fork 79
Using the Builders
This wiki entry is under construction.
Currently our builders module contains 83 functions assisting our map creation. This wiki entry strives to document the usage of these.
This guide might not be enough information, but it sure beats no information at all. If you need any assistance please visit www.redmew.com/discord we'll be happy to assist in #devtalk or #mapgen
Basic map generation using our map_gen/shared/generate module consists of the usage of functions returning true or false for a given coordinate. Notice that factorios map generation works before the scenarios', the true or false only determines whether to keep the current map or remove it entirely, leaving void in its place.
Example 1.1 (20 x 20 square)
This example generates a 20 x 20 square and leaves everything else as void. Notice how the usage of the boolean true and false affects the map generation.
local function createVoid(x, y)
if (math.abs(x) <= 10 and math.abs(y) <= 10) then
return true
end
return false
end
return createVoid
Result:
Since the function returns false (translated into void) for all coordinates except -10 <= x <= 10 | -10 <= y <= 10
the result is a 20 x 20 square shape
Example 1.2 (20 x 20 square using builder)
local b = require 'map_gen.shared.builders'
local shape = b.rectangle(20,20)
return shape
Useful for testing:
/c local x = 256 game.forces.player.chart(game.player.surface, {lefttop = {x = -x, y = -x}, rightbottom = {x = x, y = x}})
--and
/c global.task_queue_speed = 10 --Threaded work
--or
/c game.speed = 3 --Non-threaded work
The generate module works after the charting has been executed! Wait a while for it to apply
Go take a look at https://github.com/Refactorio/RedMew/wiki/Creating-a-new-map
Getting started with the builder you need to understand how to create a new map. Take this example:
local b = require 'map_gen.shared.builders'
local map = b.rectangle(200, 200)
return map
It creates a 200 x 200 square of land and the rest of the map is void.
The important part of this is that a new map should always return a function that takes the following parameters:
@param x number
x-coordinate
@param y number
y-coordinate
@param world table
containing a x
and y
coordinate for the world (Not affected by any manipulation)
Using the builders functions will always return a function that satisfies this.
In the function section you'll notice the use of the variables shape and map. They are interchangeable and affects nothing. Best pratice is to combine shapes and then add any entites to a function called map
before returning it.
Every shape is a function with the format function(x, y, world), during map generation the shape function is called with the current x and y coordinate. These coordinates are from the center of a tile resulting in always ending with .5 (eg. 10.5 instead of 10) to get the correct coordinate you can use world.x
or world.y
(eg. x
= 10.5 world.x
= 10)
Another usage of world
is when manipulating a shape (eg. by translation) this changes the x and y coordinates while world.x
and world.y
will return the true coordinates
Function | Description |
---|---|
Rectangle | Creates a rectangular shape |
Line x | Creates a infinite vertical line |
Line y | Creates a infinite horizontal line |
Path | Creates an infinite cross |
Square Diamond | Creates a square diamond |
Rectangle Diamond | Creates a rectangular diamond |
Circle | Creates a circle |
Oval | Creates an oval |
Sine wave fill | Creates a sine wave and fills the gaps |
Sine wave | Creates a sine wave with a thickness |
Rectangular spiral | Creates an infinite rectangular spiral |
Circular spiral | Creates an infinite circular spiral |
Circular growing spiral | Creates an infinite growing circular spiral |
Circular spiral with n threads | Creates a number of threads of infinite circular spirals |
Circular growing spiral with n threads | Creates a number of infinite growing circular spirals |
Creates a rectangular shape
@param width int
@param height int
Example
local shape = b.rectangle(16, 8)
Creates a infinite vertical line
@param tickness int
Example
local shape = b.line_x(10)
Creates a infinite horizontal line
@param tickness int
Example
local shape = b.line_y(10)
Creates a infinite cross
Equivalent to combining line_x
and line_y
@param tickness int
width of the vertical line
@param optional_thickness_height int --optional
width of the horizontal line
Example
local shape = b.path(10, 5)
Creates a diamond where width is equal to height
Equivalent to creating a square and rotating it 45 degrees
@param size int
Example
local shape = b.square_diamond(50)
Like square_diamond but with configurable width and height
Equivalent to creating a rectangle and rotating it 45 degrees
@param width int
@param height int
Example
local shape = b.rectangle_diamond(32, 16)
Creates a circle
@param radius int
Example
local shape = b.circle(10)
Like circle but with configurable width and height
@param radius_x int
@param radius_y int
Example
local shape = b.oval(10, 20)
Creates a sine wave and fills it out
@param width int
@param height int
the amplitude
@see sine_wave for comparison
Example
local shape = b.sine_fill(20, 10)
Creates a sine wave with a thickness
@param width int --the wave lenght
@param height int --the amplitude
@param thickness int
@see sine_fill for comparison
Example
local shape = b.sine_wave(20, 10, 2)
Creates an infinite rectangular spiral
@param x_size int
@param optional_y_size int
optional otherwise equal to x_size
Example
local shape = b.rectangular_spiral(10, 10)
--equals b.rectangular_spiral(10)
Creates an infinite circular spiral
@param in_thickness int
defines the number of land tiles the spiral contains
@param total_thickness int
defines the number of total tiles the spiral spans over (The gap is total_thickness - in_thickness
)
@see circular_spiral_grow for comparison
Example
local shape = b.circular_spiral(5, 10)
Creates an infinite growing circular spiral
@param in_thickness int
defines the number of land tiles the spiral contains
@param total_thickness int
defines the number of total tiles the spiral spans over (The gap is total_thickness - in_thickness
)
@param grow_factor int
defines how quickly the spiral grow. (Lower numbers result in faster growth, larger number in slower.)
@see circular_spiral for comparison
Example
local shape = b.circular_spiral(5, 10, 50)
Creates a number of threads of infinite circular spirals
@param in_thickness int
defines the number of land tiles the spiral contains
@param total_thickness int
defines the number of total tiles the spiral spans over (The gap is total_thickness - in_thickness
)
@param n_threads int
defines the number of threads/spirals
@see circular_spiral for comparison
@see circular_spiral_grow_n_threads for comparison
Example
local shape = b.circular_spiral_n_threads(5, 10, 2)
Creates a number of infinite growing circular spirals
@param in_thickness int
defines the number of land tiles the spiral contains
@param total_thickness int
defines the number of total tiles the spiral spans over (The gap is total_thickness - in_thickness
)
@param grow_factor int
defines how quickly the spiral grow. (Lower numbers result in faster growth, larger number in slower.)
@param n_threads int
defines the number of threads/spirals
@see circular_spiral_grow for comparison
@see circular_spiral_n_threads for comparison
Example
local shape = b.circular_spiral_grow_n_threads(5, 10, 50, 2)
TBC
TBC
Function | Description |
---|---|
Translate | Translates a shapes position |
Scale | Scales a shapes |
Rotate | Rotates a shape counter clockwise |
Flip along x | Flips a shape along the x-axis |
Flip along y | Flips a shape along the y-axis |
Flip both x and y | Flips a shape along the xy-axis |
Combine Any | OR combine |
Combine All | AND combine |
Unused : No Docs | |
Add | OR combine. Only two shapes |
Subtract | Subtracts a shape from the other. |
Invert | Inverts a shape |
Throttle along x | Cuts horizontal lines in a shape |
Throttle along y | Cuts vertical lines in a shape |
Throttle along x and y | Applies Builders.throttle_x and Builders.throttle_y to a shape |
Throttle along world.x and world.y | Preferred over Builders.throttle_xy
|
Choose | Applying one of two shapes based on output of another shape |
If else | Applying one shape based on the output of another shape |
Linear grow | No Docs |
Grow | No Docs |
Project | No Docs |
Project pattern | No Docs |
Project overlap | No Docs |
Translates a shapes position
@param shape function
the function of a shape to be translated (Must have format function(x, y, world) where world is optional)
@param x_offset int
@param y_offset int
Example
Using a rectangle shape
local shape = b.translate(b.rectangle(16, 8), 8, 4)
Player is at position (0, 0)
Without translation (Water added for illustrational purposes)
With translation (Water added for illustrational purposes)
Scales a shapes
@param shape function
the function of a shape to be scaled (Must have format function(x, y, world) where world is optional)
@param x_scale int
@param y_scale int
Example
Using a rectangle shape
local shape = b.scale(b.rectangle(16, 8), 1, 2)
Player is at position (0, 0)
Without scaling (Water added for illustrational purposes)
With scaling (Water added for illustrational purposes)
Rotates a shape counter clockwise
@param shape function
the function of a shape to be rotated (Must have format function(x, y, world) where world is optional)
@param angle int
specified in radians (NOT degrees)
Example
Using a rectangle shape
local shape = b.rotate(b.rectangle(16, 8), math.pi/2)
Player is at position (0, 0)
Without rotation (Water added for illustrational purposes)
With rotation (Water added for illustrational purposes)
Flips a shape along the x-axis Equivalent to rotate by pi
@param shape function
the function of a shape to be flipped (Must have format function(x, y, world) where world is optional)
Example
Using a L shape
-- creating the L shape
local pre_shape = b.translate(b.rectangle(16, 8), 4, 0)
pre_shape = b.add(pre_shape, b.rotate(pre_shape, math.pi/2))
--applying flip_x
local shape = b.flip_x(pre_shape)
Player is at position (0, 0)
Without flipping along x (Water added for illustrational purposes)
With flipping along x (Water added for illustrational purposes)
Flips a shape along the y-axis Equivalent to rotate by -pi
@param shape function
the function of a shape to be flipped (Must have format function(x, y, world) where world is optional)
Example
Using a rectangle rotated shape
-- creating the L shape
local pre_shape = b.translate(b.rectangle(16, 8), 4, 0)
pre_shape = b.add(pre_shape, b.rotate(pre_shape, math.pi/2))
--applying flip_y
local shape = b.flip_y(pre_shape)
Player is at position (0, 0)
Without flipping along y (Water added for illustrational purposes)
With flipping along y (Water added for illustrational purposes)
Flips a shape along the xy-axis Equivalent to rotate by 2pi
@param shape function
the function of a shape to be flipped (Must have format function(x, y, world) where world is optional)
Example
Using a rectangle rotated shape
-- creating the L shape
local pre_shape = b.translate(b.rectangle(16, 8), 4, 0)
pre_shape = b.add(pre_shape, b.rotate(pre_shape), math.pi/2)
--applying flip_y
local shape = b.flip_xy(pre_shape)
Player is at position (0, 0)
Without flipping along xy (Water added for illustrational purposes)
With flipping along xy (Water added for illustrational purposes)
Combines all shapes in supplied array as if it where evaluated as an OR operation. If any shape returns true for a coordinate, the resulting shape returns true
@param shapes table of functions
table/array of all shapes to be combined (Must have format function(x, y, world) where world is optional)
@see Builders.all for comparison
Example
Using 4 rectangles which have been rotated
-- creating the 4 shapes
local shape1 = b.translate(b.rectangle(16, 8), 4, 0)
local shape2 = b.rotate(shape1), math.pi/2)
local shape3 = b.rotate(shape2), math.pi/2)
local shape4 = b.rotate(shape3), math.pi/2)
--Combining using any
local shape = b.any({shape1, shape2, shape3, shape4})
Player is at position (0, 0)
Base shape (Water added for illustrational purposes)
Resulting shape (Water added for illustrational purposes)
Combines all shapes in supplied array as if it where evaluated as an AND operation If, and only if, all shapes returns true for a coordinate, the resulting shape returns true.
@param shapes table of functions
table/array of all shapes to be combined (Must have format function(x, y, world) where world is optional)
@see Builders.any for comparison
Example
Using 4 rectangles which have been rotated
-- creating the 4 shapes
local shape1 = b.translate(b.rectangle(16, 8), 4, 0)
local shape2 = b.rotate(shape1), math.pi/2)
local shape3 = b.rotate(shape2), math.pi/2)
local shape4 = b.rotate(shape3), math.pi/2)
--Combining using all
local shape = b.all({shape1, shape2, shape3, shape4})
Player is at position (0, 0)
Base shape (Water added for illustrational purposes)
(Water added for illustrational purposes)
TBC
No map currently uses Builders.combine
Expected behavior:
Works like Builders.any but keeps any entities that have been added to a shape.
Builders.any is using a lazy evaluation and thus terminates at first true
.
Alternative usage: Use Builders.any and apply entities after using Builders.apply_entity or Builders.apply_entities
Combines two shapes as if it where evaluated as an OR operation.
Equivalent to Builders.any({shape1, shape2})
@param shape1 function
the function of the first shape to be combined (Must have format function(x, y, world) where world is optional)
@param shape2 function
the function of the second shape to be combined (Must have format function(x, y, world) where world is optional)
@see Builders.any for comparison
Example
Using 2 rectangles to form an L shape
-- creating the L shape
local shape1 = b.translate(b.rectangle(16, 8), 4, 0)
local shape2 = b.rotate(shape1, math.pi/2)
--applying flip_x
local shape = b.add(shape1, shape2)
Result: (Water added for illustrational purposes)
Subtracts a shape from the other.
@param shape function
the function of the shape to be subtracted from (Must have format function(x, y, world) where world is optional)
@param minus_shape function
the function of the subtracting shape (Must have format function(x, y, world) where world is optional)
Example
Using 2 rectangles
-- creating the 2 rectangles
local shape1 = b.rectangle(10, 10)
local shape2 = b.rectangle(5, 5)
--applying subtract
local shape = b.subtract(shape1, shape2)
Result: (Water added for illustrational purposes)
Inverts a shape (true becomes false and vice versa)
@param shape function
the function of the shape to be inverted (Must have format function(x, y, world) where world is optional)
Example
Using 2 rectangles subtracted (see Builders.subtract example)
-- creating the 2 rectangles
local shape1 = b.rectangle(10, 10)
local shape2 = b.rectangle(5, 5)
--applying subtract
local pre_shape = b.subtract(shape1, shape2)
--applying invert
local shape = b.invert(pre_shape)
Before inversion (Water added for illustrational purposes, acts as false)
After inversion (Water added for illustrational purposes, acts as false)
Cuts horizontal lines in a shape
@param shape function
the function of the shape to be throttled (Must have format function(x, y, world) where world is optional)
@param x_in int
width of tiles unaffected
@param x_size int
total width of a single part of the throttled shape (affected tiles width equals (x_size - x_in)/2
)
Example
Using a rectangle
-- creating the rectangle
local rectangle = b.rectangle(20, 20)
--applying throttle_x
local shape = b.throttle_x(rectangle, 2, 4)
Before throttle_x (Water added for illustrational purposes, acts as false)
After throttle_x (Water added for illustrational purposes, acts as false)
Elaboration
Calling builders.throttle_x
with x_in
as 2
and x_size
as 4
results in the rectangle being cut into 20 / x_size <=> 5
pieces each with width x_size <=> 4
. Since x_in
is 2
, two tiles in the width are kept as land (true), while (x_size - x_in) / 2 <=> 1
tile on either side is discarded as water/void (false).
Cuts vertical lines in a shape
@param shape function
the function of the shape to be throttled (Must have format function(x, y, world) where world is optional)
@param y_in int
height of tiles unaffected
@param y_size int
total height of a single part of the throttled shape (affected tiles height equals (y_size - y_in)/2
)
Example
Using a rectangle
-- creating the rectangle
local rectangle = b.rectangle(20, 20)
--applying throttle_y
local shape = b.throttle_y(rectangle, 2, 4)
Before throttle_y (Water added for illustrational purposes, acts as false)
After throttle_y (Water added for illustrational purposes, acts as false)
Elaboration
Calling builders.throttle_y
with y_in
as 2
and y_size
as 4
results in the rectangle being cut into 20 / y_size <=> 5
pieces each with width y_size <=> 4
. Since y_in
is 2
, two tiles in the height are kept as land (true), while (y_size - y_in) / 2 <=> 1
tile above and below is discarded as water/void (false).
Applies Builders.throttle_x
and Builders.throttle_y
to a shape
@param shape function
the function of the shape to be throttled (Must have format function(x, y, world) where world is optional)
@param x_in int
width of tiles unaffected
@param x_size int
total width of a single part of the throttled shape (affected tiles width equals (x_size - x_in)/2
)
@param y_in int
height of tiles unaffected
@param y_size int
total height of a single part of the throttled shape (affected tiles height equals (y_size - y_in)/2
)
Example
Using a rectangle
-- creating the rectangle
local rectangle = b.rectangle(20, 20)
--applying throttle_y
local shape = b.throttle_xy(rectangle, 2, 4, 2, 4)
Before throttle_xy (Water added for illustrational purposes, acts as false)
After throttle_xy (Water added for illustrational purposes, acts as false)
TBC
Almost equivalent to Builders.throttle_xy
but preferred
TBC
Given three shapes if first shape returns true apply true_shape if it returns false apply false_shape
Given two shapes if first shape returns false apply else_shape
TBC
No map currently uses Builders.linear_grow
TBC
The hearts map uses Builders.grow
TBC
TBC
TBC
Function | Description |
---|---|
Entity | Applying a single entity |
Entity_function | Applying entities based on a custom function |
Resource | Fills a shape with a resource |
Apply entity | No Docs |
Apply entities | No Docs |
Returns a table with one entry named name
whose value is @param name string
if the supplied shape returns true
Use case: Used to apply trees or rocks
local tree = b.entity(b.throttle_world_xy(b.rectangle(20, 10), 1, 3, 1, 3), 'tree-01')
Executes function func
if the supplied shape returns true
Use case: Used to apply a random rock or tree instead of a static one.
local rock_names = {'rock-big', 'rock-huge', 'sand-rock-big'}
local function rocks_func()
local rock = rock_names[math.random(#rock_names)]
return {name = rock}
end
local rocks = b.entity_func(b.throttle_world_xy(b.rectangle(20, 10), 1, 6, 1, 6), rocks_func)
Fills a shape with a resource
@param shape function
shape to fill with resource
@param resource_type string
prototype name of resource. Available types listed below
@param amount_function function --optional
function in the format function(x, y), if nil
value is set to 404
@param always_place boolean --optional
overrides surface.can_place_entity check
Valid resource_type
:
iron-ore
, copper-ore
, stone
, coal
, uranium-ore
, crude-oil
Effect of always_place
Example
Simple resource generation using Builders.manhattan_value
-- creating a 100 x 100 square of land
local shape = b.rectangle(100, 100)
-- creating a circular shape with radius 10, to be filled with iron-ore
local ore_shape = b.circle(10)
-- creating the resource entity from the ore_shape using manhattan distance to increase ore count with distance from (0, 0)
local iron_ore = b.resource(ore_shape), 'iron-ore', b.manhattan_value(500, 1), false)
-- applying resource entity to shape
local map = b.apply_entity(shape, iron_ore)
Example
Advanced resource generation with amount function
-- creates value function that returns a fixed amount
local function value(num)
return function(x, y) -- the parameter x and y can be omitted in this case
return num
end
end
-- creating a 100 x 100 square of land
local shape = b.rectangle(100, 100)
-- creating a circular shape with radius 10, to be filled with iron-ore
local ore_shape = b.circle(10)
-- creating the resource entity from the ore_shape using a custom value function
local iron_ore = b.resource(ore_shape), 'iron-ore', value(500), false)
-- applying resource entity to shape
local map = b.apply_entity(shape, iron_ore)
Other amount_function
s:
Builders.manhattan_value
, Builders.euclidean_value
, Builders.exponential_value
Removes map gen entities by filter
@param shape function
@param filter table
see https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.find_entities_filtered for valid filters. (Area has no effect)
Example
local shape = b.rectangle(10, 10)
shape = b.remove_map_gen_entities_by_filter(shape, {name = 'cliff'})
Removes all cliffs from the shape (In this example a 10 by 10 rectangle)
Removes entities previously added by using one of the builders entity functions
@param shape function
@param names table or string
of entity names to remove, if only one entity it can be a string.
Removes map gen decoratives
@param shape function
@param optional_filter table --optional
see https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.destroy_decoratives for valid filters (Area has no effect). If no filter, it will remove all decoratives
Example
local shape = b.rectangle(10, 10)
shape = b.remove_map_gen_decoratives_by_filter(shape)
Removes all decoratives from the shape (In this example a 10 by 10 rectangle)
Removes decoratives previously added by using one of the builders decorative functions
@param shape function
@param names table or string
of decorative names to remove, if only one decorative it can be a string.
Removes all resources from a shape
@param shape function
Example
local shape = b.rectangle(10, 10)
shape = b.remove_map_gen_resources(shape)
Removes all resources from the shape (In this example a 10 by 10 rectangle)
Removes all trees from a shape
@param shape function
Example
local shape = b.rectangle(10, 10)
shape = b.remove_map_gen_trees(shape)
Removes all trees from the shape (In this example a 10 by 10 rectangle)
Removes all entities belonging to the enemy
force from a shape
Used to remove biters, spitters, worms and spawners from a shape
@param shape function
Example
local shape = b.rectangle(10, 10)
shape = b.remove_map_gen_enemies(shape)
Removes all entities belonging to the enemy
force from the shape (In this example a 10 by 10 rectangle)
Function | Description |
---|---|
Single pattern | Applies a single shape infinite |
Single pattern overlap | Applies a single shape infinite while allowing overlaps |
Single x pattern | Applies a single shape infinite along the x-axis |
Single y pattern | Applies a single shape infinite along the y-axis |
Depricated No Docs | |
Pattern building | How to create shape patterns |
Grid x pattern | No Docs |
Grid y pattern | No Docs |
Grid pattern | No Docs |
Applies a single shape infinite
@param shape function
the function of a shape to be duplicated in a pattern (Must have format function(x, y, world) where world is optional)
@param width int
width of one unit of the base shape
@param height int --optional
height of one unit of the base shape. If nil
it equals to width
Example Using a square
local shape = b.rectangle(10, 10)
local map = b.single_pattern(shape, 15, 15)
Since the shape's dimentions are 10 by 10 and the base pattern is 15 by 15 we end up with some void.
Applies a single shape infinite while allowing overlaps
@param shape function
the function of a shape to be duplicated in a pattern (Must have format function(x, y, world) where world is optional)
@param width int
width of one unit of the base shape
@param height int
height of one unit of the base shape
@see Builders.single_pattern
for comparison
Example (Better example wanted!) Using an L-shape
local pre_shape = b.translate(b.rectangle(16, 8), 4, 0)
local shape = b.add(pre_shape, b.rotate(pre_shape, math.pi/2))
local map = b.single_pattern_overlap(shape, 25, 12)
With overlap
Without overlap
Applies a single shape infinite along the x-axis
@param shape function
the function of a shape to be duplicated in a pattern (Must have format function(x, y, world) where world is optional)
@param width int
width of one unit of the base shape
@see Builders.single_pattern
for comparison
Example Using a square
local shape = b.rectangle(10, 10)
local map = b.single_x_pattern(shape, 11)
Since the shape's dimentions are 10 by 10 and the base pattern is 11 by 11 we end up with some void.
Applies a single shape infinite along the y-axis
@param shape function
the function of a shape to be duplicated in a pattern (Must have format function(x, y, world) where world is optional)
@param height int
height of one unit of the base shape
@see Builders.single_pattern
for comparison
Example Using a square
local shape = b.rectangle(10, 10)
local map = b.single_y_pattern(shape, 11)
Since the shape's dimentions are 10 by 10 and the base pattern is 11 by 11 we end up with some void.
Depricated
Do not use, will be removed
Equivalent to Builders.single_pattern
except:
Must specify both width and height parameters
The grid functions requires a new type of input a pattern. This pattern is a table containing the shapes in a grid like structure.
Example Single row with three colomns
local pattern = {
{shape1, shape2, shape3}
}
1 | 2 | 3 | |
---|---|---|---|
1 | shape1 | shape2 | shape3 |
Example Two row with two colomns
local pattern = {
{shape1, shape2},
{shape2, shape1}
}
1 | 2 | |
---|---|---|
1 | shape1 | shape2 |
2 | shape2 | shape1 |
You can build the patterns just as you'd like, each row is a new table inside the pattern table, and each column is a new value inside the nested table. For structual purposes it's advised to have a consistent amount of rows and colomns, like all of these examples.
Example Five row with four colomns
local pattern = {
{shape1, shape2, shape1, shape2},
{shape2, shape1, shape2, shape1},
{shape1, shape2, shape1, shape2},
{shape2, shape1, shape2, shape1},
{shape1, shape2, shape1, shape2}
}
1 | 2 | 3 | 4 | |
---|---|---|---|---|
1 | shape1 | shape2 | shape1 | shape2 |
2 | shape2 | shape1 | shape2 | shape1 |
3 | shape1 | shape2 | shape1 | shape2 |
4 | shape2 | shape1 | shape2 | shape1 |
5 | shape1 | shape2 | shape1 | shape2 |
TBC
Example
local b = require 'map_gen.shared.builders'
local water = b.tile('water')
local normal = b.full_shape
local pattern = {
{normal, water},
{normal, normal}
}
local map = b.grid_pattern(pattern, 2, 2, 1, 1)
map = b.scale(map, 32, 32)
return map
Returns the product of the manhattan distance of the current coordinates from origin and a multiplier. A base number is added to this value
Formula: multiplier * (|x| + |y|) + base_value
Laymans' term: the horizontal and vertical distances, between (0, 0) and a given point, added together
The red line is the manhattan distance between the two points. This distance is equivalent to the blue and yellow line. The green line is the euclidean distance.
@param base number
the base value or minimum value returned
@param mult number
a number signifying the multiplication of the manhattan distance
Example
Usage of the manhattan_value
-- returns the base for all coordinates
b.manhattan_value(500, 0) -- Always returns 500
-- returns the base + manhattan distance
b.manhattan_value(500, 1) -- Always returns >= 500 | eg. coordinate (10, 10) gives the manhattan distance of 20, resulting in the manhattan_value of 520.
-- returns the base + mult(manhattan distance)
b.manhattan_value(500, 2) -- Always returns >= 500 | eg. coordinate (10, 10) gives the manhattan distance of 20 (which needs to be multiplied by 2), resulting in the manhattan_value of 540
TBC
Return the product of the euclidean distance of the current coordinates from origin and a multiplier. A base number is added to this value
Formula: multiplier * sqrt(x^2 + y^2) + base_value
Laymans' term: the diagonal distance from point (0, 0) to a given coordinate
The red line is the manhattan distance between the two points. This distance is equivalent to the blue and yellow line. The green line is the euclidean distance.
@param base number
the base value or minimum value returned
@param mult number
a number signifying the multiplication of the euclidean distance
TBC
Formula: base_value + multiplier * (x^2 + y^2)^(exponent/2)
@param base number
the base value or minimum value returned
@param mult number
a number signifying the multiplication of the exponential value
@param pow number
Having issues? Reach out on discord
Got a bug report, feature request or map idea? Open an issue
Looking to download maps? See releases or the public save directory
Interested in Localization? Check out the progress at Crowdin