diff --git a/homedecor/crafts.lua b/homedecor/crafts.lua index e7ef7fd7..f426c321 100644 --- a/homedecor/crafts.lua +++ b/homedecor/crafts.lua @@ -2879,7 +2879,10 @@ minetest.register_craft({ local bookcolors = { "red", "green", - "blue" + "blue", + "violet", + "grey", + "brown" } for _, color in ipairs(bookcolors) do diff --git a/homedecor/misc-nodes.lua b/homedecor/misc-nodes.lua index 23813401..8d717a7d 100644 --- a/homedecor/misc-nodes.lua +++ b/homedecor/misc-nodes.lua @@ -1897,7 +1897,10 @@ minetest.register_node("homedecor:swing_rope", { local bookcolors = { "red", "green", - "blue" + "blue", + "violet", + "grey", + "brown" } for c in ipairs(bookcolors) do @@ -1909,26 +1912,51 @@ minetest.register_node("homedecor:book_"..color, { tiles = { "homedecor_book_"..color.."_top.png", "homedecor_book_"..color.."_bottom.png", - "homedecor_book_right.png", + "homedecor_book_open_sides.png", "homedecor_book_"..color.."_bottom.png", - "homedecor_book_back.png", - "homedecor_book_back.png^[transformFX" + "homedecor_book_open_sides.png", + "homedecor_book_open_sides.png" }, inventory_image = "homedecor_book_"..color.."_inv.png", drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", - groups = { snappy=3, oddly_breakable_by_hand=3 }, + groups = { snappy=3, oddly_breakable_by_hand=3, book=1 }, + stack_max = 1, node_box = { type = "fixed", fixed = { - {0, -0.5, -0.375, 0.3125, -0.4375, 0.0625}, -- NodeBox1 + {0, -0.5, -0.375, 0.3125, -0.4375, 0.0625}, } }, - on_punch = function(pos, node, puncher, pointed_thing) + on_rightclick = function(pos, node, clicker) local fdir = node.param2 minetest.set_node(pos, { name = "homedecor:book_open_"..color, param2 = fdir }) end, + on_use = function(itemstack, user, pointed_thing) + local player_name = user:get_player_name() + local data = minetest.deserialize(itemstack:get_metadata()) + local title, text, owner = "", "", player_name + if data then + title, text, owner = data.title, data.text, data.owner + end + local formspec + if owner == player_name then + formspec = "size[8,8]"..default.gui_bg..default.gui_bg_img.. + "field[0.5,1;7.5,0;title;Book title :;".. + minetest.formspec_escape(title).."]".. + "textarea[0.5,1.5;7.5,7;text;Book content :;".. + minetest.formspec_escape(text).."]".. + "button_exit[2.5,7.5;3,1;save;Save]" + else + formspec = "size[8,8]"..default.gui_bg.. + "button_exit[7,0.25;1,0.5;close;x]".. + default.gui_bg_img.. + "label[1,0.5;"..minetest.formspec_escape(title).."]".. + "label[0.5,1.5;"..minetest.formspec_escape(text).."]" + end + minetest.show_formspec(user:get_player_name(), "homedecor:book_"..color, formspec) + end, }) minetest.register_node("homedecor:book_open_"..color, { @@ -1951,12 +1979,28 @@ minetest.register_node("homedecor:book_open_"..color, { } }, drop = "homedecor:book_"..color, - on_punch = function(pos, node, puncher, pointed_thing) + on_rightclick = function(pos, node, clicker) local fdir = node.param2 minetest.set_node(pos, { name = "homedecor:book_"..color, param2 = fdir }) end, }) +minetest.register_on_player_receive_fields(function(player, form_name, fields) + if form_name ~= "homedecor:book_"..color or not fields.save then + return + end + local stack = player:get_wielded_item() + if minetest.get_item_group(stack:get_name(), "book") == 0 then + return + end + local data = minetest.deserialize(stack:get_metadata()) + if not data then data = {} end + data.title, data.text, data.owner = + fields.title, fields.text, player:get_player_name() + stack:set_metadata(minetest.serialize(data)) + player:set_wielded_item(stack) +end) + end minetest.register_node("homedecor:calendar", { diff --git a/homedecor/textures/homedecor_book_back.png b/homedecor/textures/homedecor_book_back.png deleted file mode 100644 index 66e2c464..00000000 Binary files a/homedecor/textures/homedecor_book_back.png and /dev/null differ diff --git a/homedecor/textures/homedecor_book_blue_bottom.png b/homedecor/textures/homedecor_book_blue_bottom.png index 90a9ad4f..c2aaecff 100644 Binary files a/homedecor/textures/homedecor_book_blue_bottom.png and b/homedecor/textures/homedecor_book_blue_bottom.png differ diff --git a/homedecor/textures/homedecor_book_blue_inv.png b/homedecor/textures/homedecor_book_blue_inv.png index 9828ae55..0d9ab883 100644 Binary files a/homedecor/textures/homedecor_book_blue_inv.png and b/homedecor/textures/homedecor_book_blue_inv.png differ diff --git a/homedecor/textures/homedecor_book_blue_top.png b/homedecor/textures/homedecor_book_blue_top.png index e5589d48..ce1b670a 100644 Binary files a/homedecor/textures/homedecor_book_blue_top.png and b/homedecor/textures/homedecor_book_blue_top.png differ diff --git a/homedecor/textures/homedecor_book_brown_bottom.png b/homedecor/textures/homedecor_book_brown_bottom.png new file mode 100644 index 00000000..0a822c34 Binary files /dev/null and b/homedecor/textures/homedecor_book_brown_bottom.png differ diff --git a/homedecor/textures/homedecor_book_brown_inv.png b/homedecor/textures/homedecor_book_brown_inv.png new file mode 100644 index 00000000..c38aefd3 Binary files /dev/null and b/homedecor/textures/homedecor_book_brown_inv.png differ diff --git a/homedecor/textures/homedecor_book_brown_top.png b/homedecor/textures/homedecor_book_brown_top.png new file mode 100644 index 00000000..faef791f Binary files /dev/null and b/homedecor/textures/homedecor_book_brown_top.png differ diff --git a/homedecor/textures/homedecor_book_green_bottom.png b/homedecor/textures/homedecor_book_green_bottom.png index 69b6a4a5..8871dd1d 100644 Binary files a/homedecor/textures/homedecor_book_green_bottom.png and b/homedecor/textures/homedecor_book_green_bottom.png differ diff --git a/homedecor/textures/homedecor_book_green_inv.png b/homedecor/textures/homedecor_book_green_inv.png index 35fe9344..fab4bc94 100644 Binary files a/homedecor/textures/homedecor_book_green_inv.png and b/homedecor/textures/homedecor_book_green_inv.png differ diff --git a/homedecor/textures/homedecor_book_green_top.png b/homedecor/textures/homedecor_book_green_top.png index 3d3a6d97..4d267414 100644 Binary files a/homedecor/textures/homedecor_book_green_top.png and b/homedecor/textures/homedecor_book_green_top.png differ diff --git a/homedecor/textures/homedecor_book_grey_bottom.png b/homedecor/textures/homedecor_book_grey_bottom.png new file mode 100644 index 00000000..6c2f8470 Binary files /dev/null and b/homedecor/textures/homedecor_book_grey_bottom.png differ diff --git a/homedecor/textures/homedecor_book_grey_inv.png b/homedecor/textures/homedecor_book_grey_inv.png new file mode 100644 index 00000000..12da54c3 Binary files /dev/null and b/homedecor/textures/homedecor_book_grey_inv.png differ diff --git a/homedecor/textures/homedecor_book_grey_top.png b/homedecor/textures/homedecor_book_grey_top.png new file mode 100644 index 00000000..5423820f Binary files /dev/null and b/homedecor/textures/homedecor_book_grey_top.png differ diff --git a/homedecor/textures/homedecor_book_open_blue_bottom.png b/homedecor/textures/homedecor_book_open_blue_bottom.png index 01ca62ea..306c0685 100644 Binary files a/homedecor/textures/homedecor_book_open_blue_bottom.png and b/homedecor/textures/homedecor_book_open_blue_bottom.png differ diff --git a/homedecor/textures/homedecor_book_open_brown_bottom.png b/homedecor/textures/homedecor_book_open_brown_bottom.png new file mode 100644 index 00000000..cd5449e5 Binary files /dev/null and b/homedecor/textures/homedecor_book_open_brown_bottom.png differ diff --git a/homedecor/textures/homedecor_book_open_green_bottom.png b/homedecor/textures/homedecor_book_open_green_bottom.png index 3c0e7946..6c73038b 100644 Binary files a/homedecor/textures/homedecor_book_open_green_bottom.png and b/homedecor/textures/homedecor_book_open_green_bottom.png differ diff --git a/homedecor/textures/homedecor_book_open_grey_bottom.png b/homedecor/textures/homedecor_book_open_grey_bottom.png new file mode 100644 index 00000000..4921095f Binary files /dev/null and b/homedecor/textures/homedecor_book_open_grey_bottom.png differ diff --git a/homedecor/textures/homedecor_book_open_red_bottom.png b/homedecor/textures/homedecor_book_open_red_bottom.png index ae630636..a233e482 100644 Binary files a/homedecor/textures/homedecor_book_open_red_bottom.png and b/homedecor/textures/homedecor_book_open_red_bottom.png differ diff --git a/homedecor/textures/homedecor_book_open_top.png b/homedecor/textures/homedecor_book_open_top.png index bfe4323b..c2d07bfe 100644 Binary files a/homedecor/textures/homedecor_book_open_top.png and b/homedecor/textures/homedecor_book_open_top.png differ diff --git a/homedecor/textures/homedecor_book_open_violet_bottom.png b/homedecor/textures/homedecor_book_open_violet_bottom.png new file mode 100644 index 00000000..f121f6e7 Binary files /dev/null and b/homedecor/textures/homedecor_book_open_violet_bottom.png differ diff --git a/homedecor/textures/homedecor_book_red_bottom.png b/homedecor/textures/homedecor_book_red_bottom.png index 041aa3ab..52d312d9 100644 Binary files a/homedecor/textures/homedecor_book_red_bottom.png and b/homedecor/textures/homedecor_book_red_bottom.png differ diff --git a/homedecor/textures/homedecor_book_red_inv.png b/homedecor/textures/homedecor_book_red_inv.png index 73bf9d55..cbd5ebd0 100644 Binary files a/homedecor/textures/homedecor_book_red_inv.png and b/homedecor/textures/homedecor_book_red_inv.png differ diff --git a/homedecor/textures/homedecor_book_red_top.png b/homedecor/textures/homedecor_book_red_top.png index fda00505..1d360587 100644 Binary files a/homedecor/textures/homedecor_book_red_top.png and b/homedecor/textures/homedecor_book_red_top.png differ diff --git a/homedecor/textures/homedecor_book_right.png b/homedecor/textures/homedecor_book_right.png deleted file mode 100644 index 52c500ac..00000000 Binary files a/homedecor/textures/homedecor_book_right.png and /dev/null differ diff --git a/homedecor/textures/homedecor_book_violet_bottom.png b/homedecor/textures/homedecor_book_violet_bottom.png new file mode 100644 index 00000000..7d65e0f6 Binary files /dev/null and b/homedecor/textures/homedecor_book_violet_bottom.png differ diff --git a/homedecor/textures/homedecor_book_violet_inv.png b/homedecor/textures/homedecor_book_violet_inv.png new file mode 100644 index 00000000..eec0b261 Binary files /dev/null and b/homedecor/textures/homedecor_book_violet_inv.png differ diff --git a/homedecor/textures/homedecor_book_violet_top.png b/homedecor/textures/homedecor_book_violet_top.png new file mode 100644 index 00000000..3452c3b5 Binary files /dev/null and b/homedecor/textures/homedecor_book_violet_top.png differ