Hi how i use group in this case is possible function minetest.grow_canapa_red(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if name ~= "default:desert_sand" and name ~= "default:sand" then
return
end.......................
I would like to use all types of sand ,for example
default sand ,
desert_sand ,
silver sand ....
I know group_sand exists ,but how do you use for example in this code ?
group_dirt exists?
example
dirt ,
dirt_with_grass ,
dry_dirt_with_drygras .... ?
is right? function minetest.grow_canapa_red(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if name ~= "default:group_sand" and name ~= "default:group_dirt" then
return
end.......................
local groups_sand={
{"desert_sand"},
{"sand"},
{"silver_sand"}
}
for i in ipairs(groups_sand) do
local g_sand = group_sand[i][1]
function minetest.grow_canapa_red(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if name ~= "default:"..g_sand then
return
end..............
There`s a group named "sand" for all types of sand. In your case you need to apply minetest.get_item_group(name, group) function (also there`s an alternative one minetest.get_node_group(name, group), but it`s deprecated):
function group_canapa_red(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if not minetest.get_item_group(name, "sand") then
return
end
end
For dirts there`s a "soil" group. Also, I`d not advice to use "minetest" global table as it`s assigned for the internal usage in the engine.
function minetest.grow_canapa(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if name ~= "default:dirt_with_grass"
and name ~= "default:dirt"
and name ~= "default:dirt_with_rainforest_litter"
and name ~= "default:dry_dirt"
and name ~= "default:dirt_with_snow"
and name ~= "default:dirt_with_conifereous_litter"
then
return
end
if not minetest.find_node_near(pos, 1, {"group:water"}) then
return
end...............................
but I wanted to avoid and and and and and :-P
ps I tryed with table too but for the function can't work because only the last one in the list is used