Improved Books
|
@ -2879,7 +2879,10 @@ minetest.register_craft({
|
|||
local bookcolors = {
|
||||
"red",
|
||||
"green",
|
||||
"blue"
|
||||
"blue",
|
||||
"violet",
|
||||
"grey",
|
||||
"brown"
|
||||
}
|
||||
|
||||
for _, color in ipairs(bookcolors) do
|
||||
|
|
|
@ -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", {
|
||||
|
|
Before Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 174 B After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 405 B |
BIN
homedecor/textures/homedecor_book_brown_bottom.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
homedecor/textures/homedecor_book_brown_inv.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
homedecor/textures/homedecor_book_brown_top.png
Normal file
After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 389 B |
BIN
homedecor/textures/homedecor_book_grey_bottom.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
homedecor/textures/homedecor_book_grey_inv.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
homedecor/textures/homedecor_book_grey_top.png
Normal file
After Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 136 B |
BIN
homedecor/textures/homedecor_book_open_brown_bottom.png
Normal file
After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 136 B |
BIN
homedecor/textures/homedecor_book_open_grey_bottom.png
Normal file
After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 9.3 KiB |
BIN
homedecor/textures/homedecor_book_open_violet_bottom.png
Normal file
After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 170 B After Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 85 B |
BIN
homedecor/textures/homedecor_book_violet_bottom.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
homedecor/textures/homedecor_book_violet_inv.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
homedecor/textures/homedecor_book_violet_top.png
Normal file
After Width: | Height: | Size: 362 B |