mirror of
https://github.com/mt-mods/biome_lib.git
synced 2024-12-25 10:20:18 +01:00
add descriptive names to ABM calls
can be specified by label= in the biome table else biome_lib will try to make up something useful fix #1
This commit is contained in:
parent
6935e73994
commit
f056d6d76e
21
API.txt
21
API.txt
@ -72,6 +72,7 @@ biome = {
|
|||||||
---- most likely want to use at least some of these to limit how and
|
---- most likely want to use at least some of these to limit how and
|
||||||
---- where your objects are spawned.
|
---- where your objects are spawned.
|
||||||
|
|
||||||
|
label = string, -- set this to identify the ABM for Minetest's profiler
|
||||||
avoid_nodes = {table}, -- same meaning as savoid, above
|
avoid_nodes = {table}, -- same meaning as savoid, above
|
||||||
avoid_radius = num, -- same as sradius
|
avoid_radius = num, -- same as sradius
|
||||||
seed_diff = num, -- The Perlin seed difference value passed to the
|
seed_diff = num, -- The Perlin seed difference value passed to the
|
||||||
@ -238,7 +239,7 @@ biome = {
|
|||||||
---- Everything else is optional, but you'll definitely want to use
|
---- Everything else is optional, but you'll definitely want to use
|
||||||
---- some of these other fields to limit where and under what
|
---- some of these other fields to limit where and under what
|
||||||
---- conditions the objects are spawned.
|
---- conditions the objects are spawned.
|
||||||
|
|
||||||
below_nodes = {table}, -- List of nodes that must be below the target
|
below_nodes = {table}, -- List of nodes that must be below the target
|
||||||
-- node. Useful in snow biomes to keep objects from
|
-- node. Useful in snow biomes to keep objects from
|
||||||
-- spawning in snow that's on the wrong surface for
|
-- spawning in snow that's on the wrong surface for
|
||||||
@ -342,14 +343,18 @@ into something else over time. This function has no return value, and accepts
|
|||||||
a biome definition table as the only parameter. These are defined like so:
|
a biome definition table as the only parameter. These are defined like so:
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
grow_plant = "string", -- Name of the node to be grown into something
|
label = string, -- set this to identify the ABM for Minetest's
|
||||||
-- else. This value is passed to the ABM as the
|
-- profiler. If not set, biome_lib will set it to
|
||||||
-- "nodenames" parameter, so it is the plants
|
-- "biome_lib grow_plants(): " appended with the node
|
||||||
-- themselves that are the ABM trigger, rather than
|
-- in grow_plant (or the first item if it's a table)
|
||||||
|
grow_plant = "string" or {table}, -- Name(s) of the node(s) to be grown
|
||||||
|
-- into something else. This value is passed to the
|
||||||
|
-- ABM as the "nodenames" parameter, so the plants
|
||||||
|
-- themselves are the ABM trigger, rather than
|
||||||
-- the ground they spawned on. A plant will only grow
|
-- the ground they spawned on. A plant will only grow
|
||||||
-- if the node above it is air. Can also be a table,
|
-- if the node above it is air. If you use a table,
|
||||||
-- but note that all nodes referenced therein will be
|
-- note that all nodes referenced therein will be
|
||||||
-- grown into the same object.
|
-- grown into the same final object.
|
||||||
grow_delay = num, -- Passed as the ABM "interval" parameter, as with
|
grow_delay = num, -- Passed as the ABM "interval" parameter, as with
|
||||||
-- spawning.
|
-- spawning.
|
||||||
grow_chance = num, -- Passed as the ABM "chance" parameter.
|
grow_chance = num, -- Passed as the ABM "chance" parameter.
|
||||||
|
20
init.lua
20
init.lua
@ -501,11 +501,20 @@ function biome_lib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa)
|
|||||||
biome_lib:set_defaults(biome)
|
biome_lib:set_defaults(biome)
|
||||||
biome.spawn_plants_count = #(biome.spawn_plants)
|
biome.spawn_plants_count = #(biome.spawn_plants)
|
||||||
|
|
||||||
|
local n
|
||||||
|
if type(biome.spawn_plants) == "table" then
|
||||||
|
n = "random: "..biome.spawn_plants[1]..", ..."
|
||||||
|
else
|
||||||
|
n = biome.spawn_plants
|
||||||
|
end
|
||||||
|
biome.label = biome.label or "biome_lib spawn_on_surfaces(): "..n
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = biome.spawn_surfaces,
|
nodenames = biome.spawn_surfaces,
|
||||||
interval = biome.interval,
|
interval = biome.interval,
|
||||||
chance = biome.spawn_chance,
|
chance = biome.spawn_chance,
|
||||||
neighbors = biome.neighbors,
|
neighbors = biome.neighbors,
|
||||||
|
label = biome.label,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
|
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
local n_top = minetest.get_node(p_top)
|
local n_top = minetest.get_node(p_top)
|
||||||
@ -583,6 +592,16 @@ function biome_lib:grow_plants(opts)
|
|||||||
options.grow_nodes = options.grow_nodes or { "default:dirt_with_grass" }
|
options.grow_nodes = options.grow_nodes or { "default:dirt_with_grass" }
|
||||||
options.seed_diff = options.seed_diff or 0
|
options.seed_diff = options.seed_diff or 0
|
||||||
|
|
||||||
|
local n
|
||||||
|
|
||||||
|
if type(options.grow_plant) == "table" then
|
||||||
|
n = "multi: "..options.grow_plant[1]..", ..."
|
||||||
|
else
|
||||||
|
n = options.grow_plant
|
||||||
|
end
|
||||||
|
|
||||||
|
options.label = options.label or "biome_lib grow_plants(): "..n
|
||||||
|
|
||||||
if options.grow_delay*time_scale >= 1 then
|
if options.grow_delay*time_scale >= 1 then
|
||||||
options.interval = options.grow_delay*time_scale
|
options.interval = options.grow_delay*time_scale
|
||||||
else
|
else
|
||||||
@ -593,6 +612,7 @@ function biome_lib:grow_plants(opts)
|
|||||||
nodenames = { options.grow_plant },
|
nodenames = { options.grow_plant },
|
||||||
interval = options.interval,
|
interval = options.interval,
|
||||||
chance = options.grow_chance,
|
chance = options.grow_chance,
|
||||||
|
label = options.label,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local p_top = {x=pos.x, y=pos.y+1, z=pos.z}
|
local p_top = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
local p_bot = {x=pos.x, y=pos.y-1, z=pos.z}
|
local p_bot = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
|
Loading…
Reference in New Issue
Block a user