version 0.21
This commit is contained in:
parent
bd1233aaf1
commit
c8d70b992c
1717 changed files with 68882 additions and 0 deletions
1
mods/bookex/depends.txt
Normal file
1
mods/bookex/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
49
mods/bookex/init.lua
Normal file
49
mods/bookex/init.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
local S;
|
||||
if (minetest.get_modpath("intllib")) then
|
||||
dofile(minetest.get_modpath("intllib").."/intllib.lua");
|
||||
S = intllib.Getter(minetest.get_current_modname());
|
||||
else
|
||||
S = function ( s ) return s end;
|
||||
end
|
||||
|
||||
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["default: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(), "default:book", formspec);
|
||||
|
||||
end
|
||||
|
||||
minetest.register_craftitem(":default:book", newbook);
|
||||
|
||||
minetest.register_on_player_receive_fields(function ( player, formname, fields )
|
||||
if ((formname == "default:book") and fields and fields.text) then
|
||||
local stack = player:get_wielded_item();
|
||||
if (stack:get_name() and (stack:get_name() == "default:book")) then
|
||||
local t = stack:to_table();
|
||||
t.metadata = fields.text;
|
||||
player:set_wielded_item(ItemStack(t));
|
||||
end
|
||||
end
|
||||
end);
|
BIN
mods/bookex/textures/book_bg.png
Normal file
BIN
mods/bookex/textures/book_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue