accept diffent growth stages of plants based on player_can_provide

master
Sokomine 2018-08-04 00:05:28 +02:00
parent 80da8e710c
commit 10c5f22a5d
2 changed files with 16 additions and 1 deletions

View File

@ -705,7 +705,11 @@ handle_schematics.generate_building = function(pos, minp, maxp, data, param2_dat
-- the existing node is not air, scaffolding, special scaffolding or a dig-here-indicator
-- -> the existing node needs to be digged
if(new_content and new_content ~= node_content
and node_content ~= cid.c_air and node_content ~= c_scaffolding and node_content ~= c_scaffolding_empty) then
and node_content ~= cid.c_air and node_content ~= c_scaffolding and node_content ~= c_scaffolding_empty
-- if this is just a plant in a diffrent growth stage: ignore it
and not( handle_schematics.player_can_provide[new_content] and
handle_schematics.player_can_provide[new_content] ==
handle_schematics.player_can_provide[node_content])) then
local h;
-- search upward for the first empty (air) node or dig-here-indicator and place a dig_here-indicator
for h=ay, maxp.y do

View File

@ -56,3 +56,14 @@ handle_schematics.get_what_player_can_provide = function( node_wanted )
-- the player ought to be able to come up with this node (or we need to define more exceptions)
return node_wanted;
end
-- store the IDs as well (for faster access in generate_building)
for node_name, player_provides in pairs(handle_schematics.player_can_provide) do
if( minetest.registered_nodes[ node_name ]
and minetest.registered_nodes[ player_provides ]) then
handle_schematics.player_can_provide[ minetest.get_content_id( node_name )] =
minetest.get_content_id( player_provides );
handle_schematics.player_can_provide[ minetest.get_content_id( player_provides )] =
minetest.get_content_id( player_provides );
end
end