mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2025-06-28 14:16:11 +02:00
Make waterliles placable on the surface of standing water.
Lilies will be rotated randomly on place, in the same manner as they're usually generated. Hold 'sneak' (usually shift) while placing to force them to follow your facedir instead. Liles will replace buildable_to nodes when placed, including themselves. This will cause a loss of lilies if you just keep placing them over and over, but this is intentional. node_ownership, glomie's protection mod, and zeg9's protection mod are accounted for, as are infinite item stacks (e.g. plain creative mode). Also, compact the waterlily register node calls into a loop.
This commit is contained in:
@ -437,6 +437,58 @@ function plantslib:grow_tree(pos, node_or_function_or_model)
|
||||
plantslib:dbg("Generated one tree in ".. (os.clock()-t)*1000 .."ms")
|
||||
end
|
||||
|
||||
-- check if a node is owned before allowing manual placement of a node
|
||||
-- (used by flowers_plus)
|
||||
|
||||
function plantslib:node_is_owned(pos, placer)
|
||||
local ownername = false
|
||||
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
||||
if HasOwner(pos, placer) then -- returns true if the node is owned
|
||||
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
||||
if type(getLastOwner) == "function" then -- ...is an old version
|
||||
ownername = getLastOwner(pos)
|
||||
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
||||
ownername = GetNodeOwnerName(pos)
|
||||
else
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif type(isprotect)=="function" then -- glomie's protection mod
|
||||
if not isprotect(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
|
||||
if not protector.can_dig(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
|
||||
if ownername ~= false then
|
||||
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Check for infinite stacks
|
||||
|
||||
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
||||
plantslib.expect_infinite_stacks = false
|
||||
else
|
||||
plantslib.expect_infinite_stacks = true
|
||||
end
|
||||
|
||||
-- read a field from a node's definition
|
||||
|
||||
function plantslib:get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
|
||||
print("[Plantlife Library] Loaded")
|
||||
|
Reference in New Issue
Block a user