From ea1eae674b05f3c69a4793f53877016d95faa3d3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 1 Feb 2017 23:36:53 +0100 Subject: [PATCH] Make book and quill react on rightclick --- mods/mcl_books/init.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mods/mcl_books/init.lua b/mods/mcl_books/init.lua index 0634a9c2bf..8d63179cbf 100644 --- a/mods/mcl_books/init.lua +++ b/mods/mcl_books/init.lua @@ -13,20 +13,23 @@ minetest.register_craft({ } }) +local write = function(itemstack, user, pointed_thing) + local text = itemstack:get_metadata() + local formspec = "size[8,9]".. + "background[-0.5,-0.5;9,10;mcl_books_book_bg.png]".. + "textarea[0.5,0.25;7.5,9.25;text;;"..minetest.formspec_escape(text).."]".. + "button_exit[2.5,8.15;3,1;ok;Done]" + minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec) +end + -- Book and Quill minetest.register_craftitem("mcl_books:writable_book", { description = "Book and Quill", inventory_image = "mcl_books_book_writable.png", groups = { book=1 }, stack_max = 1, - on_use = function (itemstack, user, pointed_thing) - local text = itemstack:get_metadata() - local formspec = "size[8,9]".. - "background[-0.5,-0.5;9,10;mcl_books_book_bg.png]".. - "textarea[0.5,0.25;7.5,9.25;text;;"..minetest.formspec_escape(text).."]".. - "button_exit[2.5,8.15;3,1;ok;Done]" - minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec) - end, + on_place = write, + on_secondary_use = write, }) minetest.register_on_player_receive_fields(function ( player, formname, fields )