mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 20:41:11 +01:00
Respawn enchantbook ent when rightclick table
This commit is contained in:
parent
73cb6b7a22
commit
e6d99b8b18
1 changed files with 16 additions and 1 deletions
|
@ -142,7 +142,20 @@ minetest.register_craftitem("mcl_enchanting:book_enchanted", {
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
local spawn_book_entity = function(pos)
|
local spawn_book_entity = function(pos, respawn)
|
||||||
|
if respawn then
|
||||||
|
-- Check if we already have a book
|
||||||
|
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||||
|
for o=1, #objs do
|
||||||
|
local obj = objs[o]
|
||||||
|
local lua = obj:get_luaentity()
|
||||||
|
if lua and lua.name == "mcl_enchanting:book" then
|
||||||
|
if lua._table_pos and vector.equals(pos, lua._table_pos) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local obj = minetest.add_entity(vector.add(pos, mcl_enchanting.book_offset), "mcl_enchanting:book")
|
local obj = minetest.add_entity(vector.add(pos, mcl_enchanting.book_offset), "mcl_enchanting:book")
|
||||||
if obj then
|
if obj then
|
||||||
local lua = obj:get_luaentity()
|
local lua = obj:get_luaentity()
|
||||||
|
@ -221,6 +234,8 @@ minetest.register_node("mcl_enchanting:table", {
|
||||||
player_meta:set_int("mcl_enchanting:num_bookshelves", num_bookshelves)
|
player_meta:set_int("mcl_enchanting:num_bookshelves", num_bookshelves)
|
||||||
player_meta:set_string("mcl_enchanting:table_name", table_name)
|
player_meta:set_string("mcl_enchanting:table_name", table_name)
|
||||||
mcl_enchanting.show_enchanting_formspec(clicker)
|
mcl_enchanting.show_enchanting_formspec(clicker)
|
||||||
|
-- Respawn book entity just in case it got lost
|
||||||
|
spawn_book_entity(pos, true)
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
spawn_book_entity(pos)
|
spawn_book_entity(pos)
|
||||||
|
|
Loading…
Reference in a new issue