mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2025-01-12 03:00:26 +01:00
initial work for restricted plant growth. split out growth conditions for trees, and reworked torchspine to not use ABMs while I was at it.
This commit is contained in:
parent
f23d4115bd
commit
46765df3ef
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local wheat_grow_time = df_farming.config.plant_growth_time * df_farming.config.cave_wheat_delay_multiplier / 8
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local register_cooking_recipes = function(def)
|
||||
local prefix = def.prefix
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local dimple_grow_time = df_farming.config.plant_growth_time * df_farming.config.dimple_cup_delay_multiplier / 4
|
||||
|
||||
|
@ -4,7 +4,7 @@ if not minetest.get_modpath("doc") then
|
||||
return
|
||||
end
|
||||
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
df_farming.doc.simple_meal_desc = S("A meal made from the admixture of two ingredients, it keeps well but are not a rich source of nutrients.")
|
||||
df_farming.doc.simple_meal_usage = nil
|
||||
|
0
df_farming/growth_conditions.lua
Normal file
0
df_farming/growth_conditions.lua
Normal file
@ -1,7 +1,6 @@
|
||||
df_farming = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
df_farming.S = minetest.get_translator(modname)
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
--load companion lua files
|
||||
@ -18,3 +17,4 @@ dofile(modpath.."/plump_helmet.lua")
|
||||
dofile(modpath.."/quarry_bush.lua")
|
||||
dofile(modpath.."/sweet_pod.lua")
|
||||
dofile(modpath.."/cooking.lua")
|
||||
dofile(modpath.."/growth_conditions.lua")
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local pig_tail_grow_time = df_farming.config.plant_growth_time * df_farming.config.pig_tail_delay_multiplier / 8
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Plants
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local displace_x = 0.125
|
||||
local displace_z = 0.125
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local quarry_grow_time = df_farming.config.plant_growth_time * df_farming.config.quarry_bush_delay_multiplier / 5
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_farming.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local sweet_pod_grow_time = df_farming.config.plant_growth_time * df_farming.config.sweet_pod_delay_multiplier / 6
|
||||
|
||||
|
@ -183,7 +183,7 @@ minetest.register_node("df_mapitems:cobble_with_floor_fungus", {
|
||||
drop = cobble_node,
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
groups = {cracky = 3, stone = 2, slippery = 1, light_sensitive_fungus = 8},
|
||||
groups = {cracky = 3, stone = 2, slippery = 1, light_sensitive_fungus = 8, df_caverns_floor_fungus = 1},
|
||||
_dfcaverns_dead_node = df_mapitems.node_name.cobble,
|
||||
sounds = df_mapitems.sounds.floor_fungus,
|
||||
})
|
||||
@ -196,30 +196,32 @@ minetest.register_node("df_mapitems:cobble_with_floor_fungus_fine", {
|
||||
drop = cobble_node,
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
groups = {cracky = 3, stone = 2, slippery = 1, light_sensitive_fungus = 8},
|
||||
groups = {cracky = 3, stone = 2, slippery = 1, light_sensitive_fungus = 8, df_caverns_floor_fungus = 1},
|
||||
_dfcaverns_dead_node = df_mapitems.node_name.cobble,
|
||||
df_mapitems.sounds.floor_fungus,
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.swap_node(pos, {name="df_mapitems:cobble_with_floor_fungus"})
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm{
|
||||
label = "df_mapitems:floor_fungus_spread",
|
||||
nodenames = {cobble_node},
|
||||
neighbors = {"df_mapitems:cobble_with_floor_fungus"},
|
||||
neighbors = {"group:df_caverns_floor_fungus"},
|
||||
interval = 60,
|
||||
chance = 10,
|
||||
catch_up = true,
|
||||
action = function(pos)
|
||||
minetest.swap_node(pos, {name="df_mapitems:cobble_with_floor_fungus_fine"})
|
||||
end,
|
||||
}
|
||||
minetest.register_abm{
|
||||
label = "df_mapitems:floor_fungus_thickening",
|
||||
nodenames = {"df_mapitems:cobble_with_floor_fungus_fine"},
|
||||
interval = 59,
|
||||
chance = 10,
|
||||
catch_up = true,
|
||||
action = function(pos)
|
||||
minetest.swap_node(pos, {name="df_mapitems:cobble_with_floor_fungus"})
|
||||
local above_def = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name]
|
||||
if above_def and (above_def.buildable_to == true or above_def.walkable == false) then
|
||||
minetest.swap_node(pos, {name="df_mapitems:cobble_with_floor_fungus_fine"})
|
||||
if math.random() > 0.5 then
|
||||
minetest.get_node_timer(pos):start(math.random(100, 1000))
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
-- Glownode and stalk
|
||||
|
@ -2,7 +2,7 @@ if not minetest.get_modpath("doc") then
|
||||
return
|
||||
end
|
||||
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
df_primordial_items.doc.big_mushroom_desc = S("Compared to the behemoths found elsewhere in the deep places of the world, the giant mushrooms of the primordial jungles are on the smaller side - often overwhelmed by the green plants that grow in the mysterious light below. Still, they can become substantial resources.")
|
||||
df_primordial_items.doc.big_mushroom_usage = S("The soft flesh of these large mushrooms is much less woody than other giant mushrooms, making it ill-suited to structural use. This makes it rather more nutritious, however.")
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
minetest.register_craftitem("df_primordial_items:primordial_fruit", {
|
||||
description = S("Primordial Fruit"),
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- Plants
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
-- Nodes
|
||||
@ -307,12 +307,11 @@ minetest.register_node("df_primordial_items:fern_sapling", {
|
||||
use_texture_alpha = "clip",
|
||||
sunlight_propagates = true,
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_primordial_items.giant_fern_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- This file defines a type of root-like growth that spreads over the surface of the ground in a random web-like pattern
|
||||
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-- hub_thickness -- the bit in the middle that's seen at the ends and corners of long hypha runs
|
||||
-- connector_thickness
|
||||
@ -320,7 +320,9 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_meristem", {
|
||||
_dfcaverns_dead_node = "df_primordial_items:giant_hypha_root",
|
||||
sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(min_growth_delay, max_growth_delay))
|
||||
if df_primordial_items.giant_mycelium_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(min_growth_delay, max_growth_delay))
|
||||
end
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -2,7 +2,6 @@ df_primordial_items = {}
|
||||
df_primordial_items.doc = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
df_primordial_items.S = minetest.get_translator(modname)
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
dofile(modpath.."/dependencies.lua")
|
||||
@ -15,4 +14,5 @@ dofile(modpath.."/fungal_nodes.lua")
|
||||
dofile(modpath.."/ceiling_fungus.lua")
|
||||
dofile(modpath.."/primordial_mushroom.lua")
|
||||
dofile(modpath.."/giant_mycelium.lua")
|
||||
dofile(modpath.."/edibles.lua")
|
||||
dofile(modpath.."/edibles.lua")
|
||||
dofile(modpath.."/sapling_growth_conditions.lua")
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
-- Big jungle mushroom
|
||||
@ -109,12 +109,11 @@ minetest.register_node("df_primordial_items:jungle_mushroom_sapling", {
|
||||
sunlight_propagates = true,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_primordial_items.jungle_mushroom_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
----------------------------------------------------
|
||||
-- Ferns
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-- Leaves
|
||||
minetest.register_node("df_primordial_items:jungle_leaves", {
|
||||
@ -237,12 +237,11 @@ minetest.register_node("df_primordial_items:jungletree_sapling", {
|
||||
use_texture_alpha = "clip",
|
||||
sunlight_propagates = true,
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_primordial_items.jungletree_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_primordial_items.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
minetest.register_node("df_primordial_items:mushroom_trunk", {
|
||||
description = S("Primordial Mushroom Trunk"),
|
||||
@ -750,12 +750,11 @@ minetest.register_node("df_primordial_items:mush_sapling", {
|
||||
use_texture_alpha = "clip",
|
||||
sunlight_propagates = true,
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_primordial_items.primordial_mushroom_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
22
df_primordial_items/sapling_growth_conditions.lua
Normal file
22
df_primordial_items/sapling_growth_conditions.lua
Normal file
@ -0,0 +1,22 @@
|
||||
-- these methods should indicate whether a sapling placed at pos should bother attempting to grow.
|
||||
-- check soil conditions and biome here, for example.
|
||||
|
||||
df_primordial_items.giant_fern_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_primordial_items.giant_mycelium_growth_permitted = function(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
df_primordial_items.jungle_mushroom_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_primordial_items.jungletree_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_primordial_items.primordial_mushroom_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
--stem
|
||||
minetest.register_node("df_trees:black_cap_stem", {
|
||||
@ -151,8 +151,7 @@ minetest.register_node("df_trees:black_cap_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
local below_node_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
if minetest.get_item_group(below_node_name, "soil") > 0 or minetest.get_item_group(below_node_name, "coal") > 0 then
|
||||
if df_trees.black_cap_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
@ -163,6 +162,9 @@ minetest.register_node("df_trees:black_cap_sapling", {
|
||||
end,
|
||||
|
||||
on_timer = function(pos)
|
||||
if df_farming and df_farming.kill_if_sunlit(pos) then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, {name="air"})
|
||||
df_trees.spawn_black_cap(pos)
|
||||
end,
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- High density wood
|
||||
-- Depth 3
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local spike_directions = {
|
||||
{dir={x=0,y=0,z=1}, facedir=2},
|
||||
@ -224,11 +224,11 @@ function df_trees.grow_blood_thorn(pos, node)
|
||||
if node.param2 >= 4 then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y - 1
|
||||
if minetest.get_item_group(minetest.get_node(pos).name, "sand") == 0 then
|
||||
|
||||
if not df_trees.blood_thorn_growth_permitted(pos) then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
|
||||
local height = 0
|
||||
local max_height = max_bloodthorn_height(pos)
|
||||
while node.name == "df_trees:blood_thorn" and height < max_height do
|
||||
|
@ -13,7 +13,7 @@ local function deep_copy(table_in)
|
||||
return table_out
|
||||
end
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
df_trees.sounds = {}
|
||||
|
||||
|
@ -4,7 +4,7 @@ if not minetest.get_modpath("doc") then
|
||||
return
|
||||
end
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-- Trees
|
||||
df_trees.doc.black_cap_desc = S("The dense black wood of these mushrooms is heavy and hard to work with, and has few remarkable properties.")
|
||||
|
@ -5,7 +5,7 @@
|
||||
-- Max trunk height 8
|
||||
-- depth 1-2
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
minetest.register_node("df_trees:fungiwood", {
|
||||
description = S("Fungiwood Stem"),
|
||||
@ -123,12 +123,11 @@ minetest.register_node("df_trees:fungiwood_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.fungiwood_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,5 +1,5 @@
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
--stem
|
||||
minetest.register_node("df_trees:goblin_cap_stem", {
|
||||
@ -210,12 +210,11 @@ minetest.register_node("df_trees:goblin_cap_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.goblin_cap_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,7 +1,6 @@
|
||||
df_trees = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
df_trees.S = minetest.get_translator(modname)
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
--load companion lua files
|
||||
@ -10,8 +9,6 @@ dofile(modpath.."/dependencies.lua")
|
||||
dofile(modpath.."/doc.lua")
|
||||
dofile(modpath.."/aliases.lua")
|
||||
|
||||
local S = df_trees.S
|
||||
|
||||
dofile(modpath.."/blood_thorn.lua")
|
||||
dofile(modpath.."/fungiwood.lua")
|
||||
dofile(modpath.."/tunnel_tube.lua")
|
||||
@ -24,3 +21,4 @@ dofile(modpath.."/tower_cap.lua")
|
||||
dofile(modpath.."/torchspine.lua")
|
||||
dofile(modpath.."/spindlestem.lua")
|
||||
|
||||
dofile(modpath.."/sapling_growth_conditions.lua")
|
@ -1,4 +1,4 @@
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
--stem
|
||||
minetest.register_node("df_trees:nether_cap_stem", {
|
||||
@ -109,14 +109,11 @@ minetest.register_node("df_trees:nether_cap_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
local node_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
if minetest.get_item_group(node_below_name, "cools_lava") == 0 or minetest.get_item_group(node_below_name, "nether_cap") > 0 then
|
||||
return
|
||||
if df_trees.nether_cap_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
51
df_trees/sapling_growth_conditions.lua
Normal file
51
df_trees/sapling_growth_conditions.lua
Normal file
@ -0,0 +1,51 @@
|
||||
-- these methods should indicate whether a sapling placed at pos should bother attempting to grow.
|
||||
-- check soil conditions and biome here, for example.
|
||||
|
||||
local stone_with_coal = df_trees.node_names.stone_with_coal
|
||||
local coalblock = df_trees.node_names.coalblock
|
||||
local is_coal = function(name)
|
||||
return name == stone_with_coal or name == coalblock
|
||||
end
|
||||
|
||||
df_trees.black_cap_growth_permitted = function(pos)
|
||||
local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
return minetest.get_item_group(below_name, "soil") > 0 or is_coal(below_name)
|
||||
end
|
||||
|
||||
df_trees.blood_thorn_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "sand") > 0
|
||||
end
|
||||
|
||||
df_trees.fungiwood_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_trees.goblin_cap_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_trees.nether_cap_growth_permitted = function(pos)
|
||||
local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
return minetest.get_item_group(below_name, "cools_lava") > 0 and minetest.get_item_group(below_name, "nether_cap") == 0
|
||||
end
|
||||
|
||||
df_trees.spindlestem_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_trees.spore_tree_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_trees.torchspine_growth_permitted = function(pos)
|
||||
local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
return minetest.get_item_group(below_name, "flammable") > 0 or is_coal(below_name)
|
||||
end
|
||||
|
||||
df_trees.tower_cap_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
||||
|
||||
df_trees.tunnel_tube_growth_permitted = function(pos)
|
||||
return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local vessels = minetest.get_modpath("vessels")
|
||||
|
||||
@ -274,10 +274,9 @@ minetest.register_node("df_trees:spindlestem_seedling", {
|
||||
|
||||
on_place = stem_on_place,
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.spindlestem_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(growth_delay())
|
||||
end
|
||||
minetest.get_node_timer(pos):start(growth_delay())
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- Max trunk height 5
|
||||
-- depth 2-3
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
minetest.register_node("df_trees:spore_tree", {
|
||||
description = S("Spore Tree Stem"),
|
||||
@ -165,12 +165,11 @@ minetest.register_node("df_trees:spore_tree_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.spore_tree_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -1,4 +1,8 @@
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local torchspine_min_delay = df_trees.config.blood_thorn_delay_multiplier*df_trees.config.tree_min_growth_delay
|
||||
local torchspine_max_delay = df_trees.config.blood_thorn_delay_multiplier*df_trees.config.tree_max_growth_delay
|
||||
|
||||
|
||||
-- Rather than make this whole mod depend on subterrane just for this, I copied and pasted a chunk of stalactite code.
|
||||
local x_disp = 0.125
|
||||
@ -52,6 +56,49 @@ local stal_box_2 = {{-0.125+x_disp, -0.5, -0.125+z_disp, 0.125+x_disp, 0.5, 0.12
|
||||
local stal_box_3 = {{-0.25+x_disp, -0.5, -0.25+z_disp, 0.25+x_disp, 0.5, 0.25+z_disp}}
|
||||
local stal_box_4 = {{-0.375+x_disp, -0.5, -0.375+z_disp, 0.375+x_disp, 0.5, 0.375+z_disp}}
|
||||
|
||||
local torchspine_list = {"df_trees:torchspine_1","df_trees:torchspine_2","df_trees:torchspine_3","df_trees:torchspine_4"}
|
||||
local grow_torchspine = function(pos)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
|
||||
if param2 > 3 then
|
||||
return -- tipped over, don't grow
|
||||
end
|
||||
|
||||
local node_above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
local node_above_def = minetest.registered_nodes[node_above.name]
|
||||
if not node_above_def.buildable_to then
|
||||
-- don't grow, but do continue cycling the torch state
|
||||
minetest.swap_node(pos, {name = "df_trees:torchspine_1", param2 = node.param2})
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
return
|
||||
end
|
||||
|
||||
local pos_base = vector.new(pos)
|
||||
local height = 1
|
||||
for i = 1,3 do
|
||||
pos_base.y = pos_base.y-1
|
||||
if minetest.get_item_group(minetest.get_node(pos_base).name, "df_trees_torchspine") > 0 then
|
||||
height = height + 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if height >= 4 then
|
||||
-- don't grow, but do continue cycling the torch state
|
||||
minetest.swap_node(pos, {name = "df_trees:torchspine_1", param2 = node.param2})
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
return
|
||||
end
|
||||
|
||||
-- place a taller torchspine
|
||||
pos.y = pos.y + 1
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
for i = 1, height+1 do
|
||||
minetest.swap_node(pos, {name=torchspine_list[i], param2=param2})
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
end
|
||||
|
||||
local torch_node = df_trees.node_names.torch
|
||||
|
||||
minetest.register_node("df_trees:torchspine_1", {
|
||||
@ -59,7 +106,7 @@ minetest.register_node("df_trees:torchspine_1", {
|
||||
_doc_items_longdesc = df_trees.doc.torchspine_desc,
|
||||
_doc_items_usagehelp = df_trees.doc.torchspine_usage,
|
||||
tiles = {"dfcaverns_torchspine_0.5.png", "dfcaverns_torchspine_1.5.png", "dfcaverns_torchspine_1.png"},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, fall_damage_add_percent = 100},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, fall_damage_add_percent = 100, df_trees_torchspine = 1},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -75,6 +122,18 @@ minetest.register_node("df_trees:torchspine_1", {
|
||||
minetest.swap_node(pos, {name = "df_trees:torchspine_1_lit", param2 = node.param2})
|
||||
end
|
||||
end,
|
||||
|
||||
on_timer = function(pos)
|
||||
local above_def = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name]
|
||||
if above_def and above_def.buildable_to then
|
||||
minetest.swap_node(pos, {name="df_trees:torchspine_1_lit", param2=minetest.get_node(pos).param2})
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("df_trees:torchspine_1_lit", {
|
||||
@ -82,7 +141,7 @@ minetest.register_node("df_trees:torchspine_1_lit", {
|
||||
_doc_items_longdesc = df_trees.doc.torchspine_desc,
|
||||
_doc_items_usagehelp = df_trees.doc.torchspine_usage,
|
||||
tiles = {df_trees.textures.gold_block, "dfcaverns_torchspine_1.5.png", "dfcaverns_torchspine_1_lit.png"},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, torch = 1, fall_damage_add_percent = 150, smokey = 4},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, torch = 1, fall_damage_add_percent = 150, smokey = 4, df_trees_torchspine = 1},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -94,6 +153,14 @@ minetest.register_node("df_trees:torchspine_1_lit", {
|
||||
fixed = stal_box_1,
|
||||
},
|
||||
on_place = stal_on_place,
|
||||
|
||||
on_timer = function(pos)
|
||||
grow_torchspine(pos)
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("df_trees:torchspine_2", {
|
||||
@ -101,7 +168,7 @@ minetest.register_node("df_trees:torchspine_2", {
|
||||
_doc_items_longdesc = df_trees.doc.torchspine_desc,
|
||||
_doc_items_usagehelp = df_trees.doc.torchspine_usage,
|
||||
tiles = {"dfcaverns_torchspine_1.5.png", "dfcaverns_torchspine_2.5.png", "dfcaverns_torchspine_2.png"},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, fall_damage_add_percent = 50},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, fall_damage_add_percent = 50, df_trees_torchspine = 1},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -127,7 +194,7 @@ minetest.register_node("df_trees:torchspine_3", {
|
||||
_doc_items_longdesc = df_trees.doc.torchspine_desc,
|
||||
_doc_items_usagehelp = df_trees.doc.torchspine_usage,
|
||||
tiles = {"dfcaverns_torchspine_2.5.png", "dfcaverns_torchspine_3.5.png", "dfcaverns_torchspine_3.png"},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, df_trees_torchspine = 1},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -157,7 +224,7 @@ minetest.register_node("df_trees:torchspine_4", {
|
||||
_doc_items_longdesc = df_trees.doc.torchspine_desc,
|
||||
_doc_items_usagehelp = df_trees.doc.torchspine_usage,
|
||||
tiles = {"dfcaverns_torchspine_3.5.png", "dfcaverns_torchspine_4.5.png", "dfcaverns_torchspine_4.png"},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1},
|
||||
groups = {oddly_breakable_by_hand = 1, subterrane_stal_align = 1, flow_through = 1, df_trees_torchspine = 1},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -201,6 +268,20 @@ minetest.register_node("df_trees:torchspine_ember", {
|
||||
}
|
||||
},
|
||||
on_place = stal_on_place,
|
||||
|
||||
on_construct = function(pos)
|
||||
if df_trees.torchspine_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
end
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end,
|
||||
|
||||
on_timer = function(pos)
|
||||
minetest.swap_node(pos, {name="df_trees:torchspine_1", param2=minetest.get_node(pos).param2})
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
end,
|
||||
})
|
||||
|
||||
df_trees.spawn_torchspine = function(pos)
|
||||
@ -259,80 +340,12 @@ df_trees.spawn_torchspine_vm = function(vi, area, data, data_param2, height, lit
|
||||
end
|
||||
end
|
||||
|
||||
-- overriding node groups using override_item doesn't appear to work with ABMs:
|
||||
-- https://github.com/minetest/minetest/issues/5518
|
||||
local coal_def = minetest.registered_nodes[df_trees.node_names.stone_with_coal]
|
||||
local coal_block_def = minetest.registered_nodes[df_trees.node_names.coalblock]
|
||||
if coal_def then
|
||||
coal_def.groups.coal = 1
|
||||
minetest.register_node(":"..df_trees.node_names.stone_with_coal, coal_def)
|
||||
end
|
||||
coal_block_def.groups.coal = 1
|
||||
minetest.register_node(":"..df_trees.node_names.coalblock, coal_block_def)
|
||||
|
||||
minetest.register_abm{
|
||||
label = "torchspine germinating",
|
||||
nodenames = {"df_trees:torchspine_ember"},
|
||||
neighbors = {"group:flammable", "group:coal"},
|
||||
interval = 30,
|
||||
chance = 10,
|
||||
catch_up = true,
|
||||
action = function(pos)
|
||||
local below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
if minetest.get_item_group(below_name, "flammable") > 0 or minetest.get_item_group(below_name, "coal") > 0 then
|
||||
minetest.swap_node(pos, {name="df_trees:torchspine_1", param2=minetest.get_node(pos).param2})
|
||||
end
|
||||
minetest.register_lbm({
|
||||
label = "Start timers for torchspine nodes that used to depend on the ABM",
|
||||
name = "df_trees:start_torchspine_timers",
|
||||
nodenames = {"df_trees:torchspine_ember", "df_trees:torchspine_1", "df_trees:torchspine_1_lit"},
|
||||
run_at_every_load = false,
|
||||
action = function(pos, node)
|
||||
minetest.get_node_timer(pos):start(math.random(torchspine_min_delay, torchspine_max_delay))
|
||||
end,
|
||||
}
|
||||
minetest.register_abm{
|
||||
label = "torchspine lighting",
|
||||
nodenames = {"df_trees:torchspine_1"},
|
||||
interval = 30,
|
||||
chance = 10,
|
||||
catch_up = true,
|
||||
action = function(pos)
|
||||
local above_def = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name]
|
||||
if above_def and above_def.buildable_to then
|
||||
minetest.swap_node(pos, {name="df_trees:torchspine_1_lit", param2=minetest.get_node(pos).param2})
|
||||
end
|
||||
end,
|
||||
}
|
||||
local torchspine_list = {"df_trees:torchspine_1","df_trees:torchspine_2","df_trees:torchspine_3","df_trees:torchspine_4"}
|
||||
minetest.register_abm{
|
||||
label = "torchspine growing",
|
||||
nodenames = {"df_trees:torchspine_1_lit"},
|
||||
interval = 37,
|
||||
chance = 10,
|
||||
catch_up = true,
|
||||
action = function(pos)
|
||||
local height = 0
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local dest_list = {{x=pos.x, y=pos.y+1, z=pos.z},pos,{x=pos.x, y=pos.y-1, z=pos.z},{x=pos.x, y=pos.y-2, z=pos.z},{x=pos.x, y=pos.y-3, z=pos.z}}
|
||||
local source_list = {
|
||||
minetest.get_node(dest_list[1]).name,
|
||||
minetest.get_node(dest_list[2]).name,
|
||||
minetest.get_node(dest_list[3]).name,
|
||||
minetest.get_node(dest_list[4]).name,
|
||||
minetest.get_node(dest_list[5]).name
|
||||
}
|
||||
local target_def = minetest.registered_nodes[source_list[1]]
|
||||
if target_def and target_def.buildable_to then
|
||||
for i = 2,4 do
|
||||
if minetest.get_item_group(source_list[i+1], "flammable") > 0 or minetest.get_item_group(source_list[i+1], "coal") > 0 then
|
||||
height = i
|
||||
break
|
||||
elseif source_list[i+1] ~= torchspine_list[i] then
|
||||
height = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if height == 0 then
|
||||
minetest.swap_node(pos, {name="df_trees:torchspine_1", param2=param2})
|
||||
return
|
||||
end
|
||||
for i = 1, height do
|
||||
minetest.swap_node(dest_list[i], {name=torchspine_list[i], param2=param2})
|
||||
end
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
--stem
|
||||
minetest.register_node("df_trees:tower_cap_stem", {
|
||||
@ -134,12 +134,11 @@ minetest.register_node("df_trees:tower_cap_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.tower_cap_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- Max trunk height 8
|
||||
-- depth 2-3
|
||||
|
||||
local S = df_trees.S
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
minetest.register_node("df_trees:tunnel_tube", {
|
||||
description = S("Tunnel Tube"),
|
||||
@ -311,12 +311,11 @@ minetest.register_node("df_trees:tunnel_tube_sapling", {
|
||||
sounds = df_trees.sounds.leaves,
|
||||
|
||||
on_construct = function(pos)
|
||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
|
||||
return
|
||||
if df_trees.tunnel_tube_growth_permitted(pos) then
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end
|
||||
minetest.get_node_timer(pos):start(math.random(
|
||||
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_min_growth_delay,
|
||||
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_max_growth_delay))
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
Loading…
Reference in New Issue
Block a user