Move book/bookshelf to new mod mcl_books

This commit is contained in:
Wuzzy 2017-02-01 23:15:23 +01:00
parent b6c603dc23
commit 92274ae1fa
13 changed files with 77 additions and 79 deletions

View File

@ -1 +0,0 @@
mcl_core

View File

@ -1,39 +0,0 @@
local function deepcopy ( t )
local nt = { };
for k, v in pairs(t) do
if (type(v) == "table") then
nt[k] = deepcopy(v);
else
nt[k] = v;
end
end
return nt;
end
local newbook = deepcopy(minetest.registered_items["mcl_core:book"]);
newbook.on_use = function ( itemstack, user, pointed_thing )
local text = itemstack:get_metadata();
local formspec = "size[8,9]"..
"background[-0.5,-0.5;9,10;book_bg.png]"..
"textarea[0.5,0.25;7.5,9.25;text;;"..minetest.formspec_escape(text).."]"..
"button_exit[3,8.25;2,1;ok;Exit]";
minetest.show_formspec(user:get_player_name(), "mcl_core:book", formspec);
end
minetest.register_craftitem(":mcl_core:book", newbook);
minetest.register_on_player_receive_fields(function ( player, formname, fields )
if ((formname == "mcl_core:book") and fields and fields.text) then
local stack = player:get_wielded_item();
if (stack:get_name() and (stack:get_name() == "mcl_core:book")) then
local t = stack:to_table();
t.metadata = fields.text;
player:set_wielded_item(ItemStack(t));
end
end
end);

View File

@ -0,0 +1,2 @@
mcl_core
mcl_mobitems

74
mods/mcl_books/init.lua Normal file
View File

@ -0,0 +1,74 @@
-- Book
minetest.register_craftitem("mcl_books:book", {
description = "Book",
inventory_image = "default_book.png",
stack_max = 64,
groups = { book=1 },
})
minetest.register_craft({
type = 'shapeless',
output = 'mcl_books:book',
recipe = { 'mcl_core:paper', 'mcl_core:paper', 'mcl_core:paper', 'mcl_mobitems:leather',
}
})
-- 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[3,8.25;2,1;ok;Exit]"
minetest.show_formspec(user:get_player_name(), "mcl_core:book", formspec)
end,
})
minetest.register_on_player_receive_fields(function ( player, formname, fields )
if ((formname == "mcl_books:writable_book") and fields and fields.text) then
local stack = player:get_wielded_item()
if (stack:get_name() and (stack:get_name() == "mcl_books:writable_book")) then
local t = stack:to_table()
t.metadata = fields.text
player:set_wielded_item(ItemStack(t))
end
end
end)
minetest.register_craft({
type = "shapeless",
output = "mcl_books:writable_book",
recipe = { "mcl_books:books", "mcl_dyes:black", "mcl_mobitems:feather" },
})
-- Bookshelf
minetest.register_node("mcl_books:bookshelf", {
description = "Bookshelf",
tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
stack_max = 64,
is_ground_content = false,
groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3,building_block=1},
drop = "mcl_books:book 3",
sounds = mcl_core.node_sound_wood_defaults(),
})
minetest.register_craft({
output = 'mcl_books:bookshelf',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'mcl_books:book', 'mcl_books:book', 'mcl_books:book'},
{'group:wood', 'group:wood', 'group:wood'},
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:bookshelf",
burntime = 15,
})

1
mods/mcl_books/mod.conf Normal file
View File

@ -0,0 +1 @@
name = mcl_books

View File

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 278 B

View File

Before

Width:  |  Height:  |  Size: 476 B

After

Width:  |  Height:  |  Size: 476 B

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

View File

@ -591,22 +591,6 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({
type = 'shapeless',
output = 'mcl_core:book',
recipe = { 'mcl_core:paper', 'mcl_core:paper', 'mcl_core:paper', 'mcl_mobitems:leather',
}
})
minetest.register_craft({
output = 'mcl_core:bookshelf',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'mcl_core:book', 'mcl_core:book', 'mcl_core:book'},
{'group:wood', 'group:wood', 'group:wood'},
}
})
minetest.register_craft({ minetest.register_craft({
output = 'mcl_core:ladder 3', output = 'mcl_core:ladder 3',
recipe = { recipe = {
@ -950,12 +934,6 @@ minetest.register_craft({
burntime = 15, burntime = 15,
}) })
minetest.register_craft({
type = "fuel",
recipe = "mcl_core:bookshelf",
burntime = 15,
})
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "mcl_core:ladder", recipe = "mcl_core:ladder",

View File

@ -18,13 +18,6 @@ minetest.register_craftitem("mcl_core:paper", {
groups = { craftitem=1 }, groups = { craftitem=1 },
}) })
minetest.register_craftitem("mcl_core:book", {
description = "Book",
inventory_image = "default_book.png",
stack_max = 64,
groups = { craftitem=1 },
})
minetest.register_craftitem("mcl_core:coal_lump", { minetest.register_craftitem("mcl_core:coal_lump", {
description = "Coal", description = "Coal",
groups = { coal=1 }, groups = { coal=1 },

View File

@ -985,16 +985,6 @@ minetest.register_node("mcl_core:bedrock", {
drop = '', drop = '',
}) })
minetest.register_node("mcl_core:bookshelf", {
description = "Bookshelf",
tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
stack_max = 64,
is_ground_content = false,
groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3,building_block=1},
drop = "mcl_core:book 3",
sounds = mcl_core.node_sound_wood_defaults(),
})
minetest.register_node("mcl_core:slimeblock", { minetest.register_node("mcl_core:slimeblock", {
description = "Slime Block", description = "Slime Block",
drawtype = "nodebox", drawtype = "nodebox",