1
0
Fork 0

Make book and quill react on rightclick

This commit is contained in:
Wuzzy 2017-02-01 23:36:53 +01:00
parent e1d94e27cc
commit ea1eae674b
1 changed files with 11 additions and 8 deletions

View File

@ -13,20 +13,23 @@ minetest.register_craft({
} }
}) })
-- Book and Quill local write = function(itemstack, user, pointed_thing)
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 text = itemstack:get_metadata()
local formspec = "size[8,9]".. local formspec = "size[8,9]"..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]".. "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).."]".. "textarea[0.5,0.25;7.5,9.25;text;;"..minetest.formspec_escape(text).."]"..
"button_exit[2.5,8.15;3,1;ok;Done]" "button_exit[2.5,8.15;3,1;ok;Done]"
minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec) minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec)
end, 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_place = write,
on_secondary_use = write,
}) })
minetest.register_on_player_receive_fields(function ( player, formname, fields ) minetest.register_on_player_receive_fields(function ( player, formname, fields )