Autom. make grass/fern dry if placed on dry grass
This commit is contained in:
parent
4083432770
commit
6b2c06934a
2 changed files with 49 additions and 15 deletions
|
@ -411,10 +411,12 @@ end
|
|||
mcl_util.clock_works = mcl_util.compass_works
|
||||
|
||||
-- Returns a on_place function for plants
|
||||
-- * condition: function(pos, node)
|
||||
-- * condition: function(pos, node, itemstack)
|
||||
-- * A function which is called by the on_place function to check if the node can be placed
|
||||
-- * Must return true, if placement is allowed, false otherwise
|
||||
-- * Must return true, if placement is allowed, false otherwise.
|
||||
-- * If it returns a string, placement is allowed, but will place this itemstring as a node instead
|
||||
-- * pos, node: Position and node table of plant node
|
||||
-- * itemstack: Itemstack to place
|
||||
function mcl_util.generate_on_place_plant_function(condition)
|
||||
return function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
|
@ -445,9 +447,20 @@ function mcl_util.generate_on_place_plant_function(condition)
|
|||
end
|
||||
|
||||
-- Check placement rules
|
||||
if (condition(place_pos, node) == true) then
|
||||
local idef = itemstack:get_definition()
|
||||
local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
local result = condition(place_pos, node, itemstack)
|
||||
if result == true or type(result) == "string" then
|
||||
local itemstack_place
|
||||
if type(result) == "string" then
|
||||
-- Let's pretend we place a different item
|
||||
itemstack_place = ItemStack(itemstack)
|
||||
itemstack_place:set_name(result)
|
||||
else
|
||||
itemstack_place = itemstack
|
||||
end
|
||||
local idef = itemstack_place:get_definition()
|
||||
local new_itemstack, success = minetest.item_place_node(itemstack_place, placer, pointed_thing)
|
||||
-- Restore old itemstack name
|
||||
new_itemstack:set_name(itemstack:get_name())
|
||||
|
||||
if success then
|
||||
if idef.sounds and idef.sounds.place then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue