mirror of
https://github.com/pyrollo/display_modpack.git
synced 2024-11-27 16:43:45 +01:00
Improved on_place
Now uses player view direction when trying to place nodes on the floor or ceiling, for both wallmounted and facedir nodes. Also supports nodes where paramtype2 is not wallmounted or facedir.
This commit is contained in:
parent
2793e0ab8f
commit
dfaf64cd61
@ -191,26 +191,24 @@ function display_api.on_place(itemstack, placer, pointed_thing)
|
|||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local dir = {x = under.x - above.x,
|
local dir = {x = under.x - above.x,
|
||||||
y = under.y - above.y,
|
y = 0,
|
||||||
z = under.z - above.z}
|
z = under.z - above.z}
|
||||||
|
|
||||||
if ndef then
|
-- If item is not placed on a wall, use the player's view direction instead
|
||||||
if ndef.paramtype2 == "wallmounted" then
|
if dir.x == 0 and dir.z == 0 then
|
||||||
|
|
||||||
local wdir = minetest.dir_to_wallmounted(dir)
|
|
||||||
|
|
||||||
if wdir == 0 or wdir == 1 then
|
|
||||||
dir = placer:get_look_dir()
|
dir = placer:get_look_dir()
|
||||||
dir.y = 0
|
dir.y = 0
|
||||||
wdir = minetest.dir_to_wallmounted(dir)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing, wdir)
|
local param2
|
||||||
else
|
if ndef then
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing, minetest.dir_to_facedir(dir))
|
if ndef.paramtype2 == "wallmounted" then
|
||||||
|
param2 = minetest.dir_to_wallmounted(dir)
|
||||||
|
elseif ndef.paramtype2 == "facedir" then
|
||||||
|
param2 = minetest.dir_to_facedir(dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On_construct callback for display_api items. Creates entities and update them.
|
--- On_construct callback for display_api items. Creates entities and update them.
|
||||||
|
Loading…
Reference in New Issue
Block a user