1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2025-07-16 04:30:23 +02:00

Add a tree swing

model and textures by jp

To place, point at the underside of a node, e.g. a ceiling or the bottom
side of tree leaves or something.  It will automatically stretch
downward trying to find the ground (well, anything that isn't
buildable_to anyway), down to a maximum of 4 meters' worth of rope.

To remove, dig the swing itself and it'll take the rope with it.
This commit is contained in:
Vanessa Ezekowitz
2014-09-18 16:29:28 -04:00
parent 1196c17b31
commit 763d8fa200
8 changed files with 130 additions and 9 deletions

View File

@ -146,6 +146,54 @@ function homedecor.stack_sideways(itemstack, placer, pointed_thing, node1, node2
end
end
-- Determine if the item being pointed at is the underside of a node (e.g a ceiling)
function homedecor.find_ceiling(itemstack, placer, pointed_thing)
-- most of this is copied from the rotate-and-place function in builtin
local unode = core.get_node_or_nil(pointed_thing.under)
if not unode then
return
end
local undef = core.registered_nodes[unode.name]
if undef and undef.on_rightclick then
undef.on_rightclick(pointed_thing.under, unode, placer,
itemstack, pointed_thing)
return
end
local pitch = placer:get_look_pitch()
local fdir = core.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
local above = pointed_thing.above
local under = pointed_thing.under
local iswall = (above.y == under.y)
local isceiling = not iswall and (above.y < under.y)
local anode = core.get_node_or_nil(above)
if not anode then
return
end
local pos = pointed_thing.above
local node = anode
if undef and undef.buildable_to then
pos = pointed_thing.under
node = unode
iswall = false
end
if core.is_protected(pos, placer:get_player_name()) then
core.record_protection_violation(pos,
placer:get_player_name())
return
end
local ndef = core.registered_nodes[node.name]
if not ndef or not ndef.buildable_to then
return
end
return isceiling, pos
end
-- load various other components
dofile(homedecor.modpath.."/misc-nodes.lua") -- the catch-all for all misc nodes