doc updates / replacements
This commit is contained in:
parent
44d1aa1c44
commit
fbb5cb5649
@ -117,9 +117,9 @@ function building_lib.create_mapgen(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mapblock_pos = { x=x, y=y, z=z }
|
local mapblock_pos = { x=x, y=y, z=z }
|
||||||
local temperature, humidity = get_temperature_humidity(mapblock_pos)
|
|
||||||
local height = get_height(mapblock_pos)
|
local height = get_height(mapblock_pos)
|
||||||
|
|
||||||
|
local temperature, humidity = get_temperature_humidity(mapblock_pos)
|
||||||
local biome = select_biome(opts.biomes, temperature, humidity)
|
local biome = select_biome(opts.biomes, temperature, humidity)
|
||||||
|
|
||||||
if mapblock_pos.y == opts.water_level and height <= mapblock_pos.y then
|
if mapblock_pos.y == opts.water_level and height <= mapblock_pos.y then
|
||||||
@ -183,5 +183,12 @@ function building_lib.create_mapgen(opts)
|
|||||||
end --z
|
end --z
|
||||||
end --y
|
end --y
|
||||||
end --x
|
end --x
|
||||||
|
end, {
|
||||||
|
get_height = get_height,
|
||||||
|
get_temperature_humidity = get_temperature_humidity,
|
||||||
|
get_biome = function(mapblock_pos)
|
||||||
|
local temperature, humidity = get_temperature_humidity(mapblock_pos)
|
||||||
|
return select_biome(opts.biomes, temperature, humidity)
|
||||||
end
|
end
|
||||||
|
}
|
||||||
end
|
end
|
@ -46,6 +46,10 @@ building_lib.register_placement("default", {
|
|||||||
|
|
||||||
-- translate to world-coords
|
-- translate to world-coords
|
||||||
local world_pos = vector.add(mapblock_pos, rotated_rel_catalog_pos)
|
local world_pos = vector.add(mapblock_pos, rotated_rel_catalog_pos)
|
||||||
|
local replace = building_def.replace
|
||||||
|
if type(building_def.replace) == "function" then
|
||||||
|
replace = building_def.replace(mapblock_pos, building_def)
|
||||||
|
end
|
||||||
|
|
||||||
local place_fn = catalog:prepare(catalog_pos, {
|
local place_fn = catalog:prepare(catalog_pos, {
|
||||||
transform = {
|
transform = {
|
||||||
@ -54,7 +58,7 @@ building_lib.register_placement("default", {
|
|||||||
angle = rotation,
|
angle = rotation,
|
||||||
disable_orientation = building_def.disable_orientation
|
disable_orientation = building_def.disable_orientation
|
||||||
},
|
},
|
||||||
replace = building_def.replace
|
replace = replace
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
27
readme.md
27
readme.md
@ -10,6 +10,12 @@ local success, message = building_lib.can_build(mapblock_pos, playername, buildi
|
|||||||
-- build it there
|
-- build it there
|
||||||
local success, message = building_lib.do_build(mapblock_pos, playername, building_name, rotation, callback)
|
local success, message = building_lib.do_build(mapblock_pos, playername, building_name, rotation, callback)
|
||||||
|
|
||||||
|
-- check if it can be removed
|
||||||
|
local success, message = building_lib.can_remove(mapblock_pos)
|
||||||
|
|
||||||
|
-- remove it
|
||||||
|
local success, message = building_lib.do_remove(mapblock_pos)
|
||||||
|
|
||||||
-- registers a placeable building
|
-- registers a placeable building
|
||||||
building_lib.register_building("buildings:my_building", {
|
building_lib.register_building("buildings:my_building", {
|
||||||
placement = "default",
|
placement = "default",
|
||||||
@ -21,11 +27,32 @@ building_lib.register_building("buildings:my_building", {
|
|||||||
{ on_slope = true, on_biome = "grass" },
|
{ on_slope = true, on_biome = "grass" },
|
||||||
{ on_flat_surface = true, on_biome = "water" },
|
{ on_flat_surface = true, on_biome = "water" },
|
||||||
},
|
},
|
||||||
|
-- simple catalog
|
||||||
catalog = "my.zip",
|
catalog = "my.zip",
|
||||||
|
-- more catalog options
|
||||||
|
catalog = {
|
||||||
|
filename = "my.zip",
|
||||||
|
-- offset in the catalog
|
||||||
|
offset = {x=0, y=2, z=0},
|
||||||
|
-- size
|
||||||
|
size = {x=1, y=1, z=1},
|
||||||
|
-- enable cache (only for 1x1x1 sized buildings, for mapgens)
|
||||||
|
cache = true
|
||||||
|
},
|
||||||
-- optional groups attribute
|
-- optional groups attribute
|
||||||
groups = {
|
groups = {
|
||||||
building = true
|
building = true
|
||||||
|
},
|
||||||
|
-- replacements
|
||||||
|
replace = {
|
||||||
|
["old_mod:node"] = "new_mod:node"
|
||||||
|
},
|
||||||
|
-- replacements as a function, can be used for biome-replacements
|
||||||
|
replace = function(mapblock_pos, building_def)
|
||||||
|
return {
|
||||||
|
["old_mod:node"] = "new_mod:node"
|
||||||
}
|
}
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- registers a placement type (connected, simple, etc)
|
-- registers a placement type (connected, simple, etc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user