initial commit

master
Diego Martínez 2013-04-21 22:52:27 -03:00
commit 115b09adb7
4 changed files with 85 additions and 0 deletions

1
bookex/depends.txt Normal file
View File

@ -0,0 +1 @@
default

48
bookex/init.lua Normal file
View File

@ -0,0 +1,48 @@
-- 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,8]"..
"textarea[1,1;8,6;text;Foo;"..minetest.formspec_escape(text).."]"..
"button[1,7;2,1;ok;OK]";
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);

0
modpack.txt Normal file
View File

36
testclock/init.lua Normal file
View File

@ -0,0 +1,36 @@
local player_hud = { };
local timer = 0;
local function floormod ( x, y )
return (math.floor(x) % y);
end
local function get_time ( )
local secs = (60*60*24*minetest.env:get_timeofday());
local s = floormod(secs, 60);
local m = floormod(secs/60, 60);
local h = floormod(secs/3600, 60);
return ("%02d:%02d:%02d"):format(h, m, s);
end
minetest.register_globalstep(function ( dtime )
timer = timer + dtime;
if (timer >= 1.0) then
timer = 0;
for _,p in ipairs(minetest.get_connected_players()) do
local name = p:get_player_name();
local h = p:hud_add({
hud_elem_type = "text";
position = {x=0.35, y=0.900};
text = get_time();
number = 0xFFFF00;
});
if (player_hud[name]) then
p:hud_remove(player_hud[name]);
end
player_hud[name] = h;
end
end
end);