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({
} }
}) })
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 -- Book and Quill
minetest.register_craftitem("mcl_books:writable_book", { minetest.register_craftitem("mcl_books:writable_book", {
description = "Book and Quill", description = "Book and Quill",
inventory_image = "mcl_books_book_writable.png", inventory_image = "mcl_books_book_writable.png",
groups = { book=1 }, groups = { book=1 },
stack_max = 1, stack_max = 1,
on_use = function (itemstack, user, pointed_thing) on_place = write,
local text = itemstack:get_metadata() on_secondary_use = write,
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,
}) })
minetest.register_on_player_receive_fields(function ( player, formname, fields ) minetest.register_on_player_receive_fields(function ( player, formname, fields )