Version 1.0.0
[minetest_calendar_node.git] / init.lua
blobe2df5dbfefa66758c5b4aef2fa52867fa2c5b0c3
1 local S
2 -- Compability translator code to support MT 0.4, which doesn't support
3 -- translations for mods.
4 if not minetest.translate then
5 -- No translation system available, use dummy functions
6 local function translate(textdomain, str, ...)
7 local arg = {n=select('#', ...), ...}
8 return str:gsub("@(.)", function(matched)
9 local c = string.byte(matched)
10 if string.byte("1") <= c and c <= string.byte("9") then
11 return arg[c - string.byte("0")]
12 else
13 return matched
14 end
15 end)
16 end
18 S = function(str, ...)
19 return translate("calendar_node", str, ...)
20 end
21 else
22 S = minetest.get_translator("calendar_node")
23 end
25 local on_rightclick
26 if minetest.get_modpath("calendar") then
27 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
28 if not clicker:is_player() then
29 return itemstack
30 end
31 calendar.show_calendar(clicker:get_player_name())
32 return itemstack
33 end
34 -- If the calendar mod was not found, the calendar node is basically
35 -- just a decorative node.
36 end
38 minetest.register_node("calendar_node:calendar", {
39 drawtype = "signlike",
40 description = S("Calendar"),
41 tiles = { "calendar_node_calendar.png" },
42 inventory_image = "calendar_node_calendar.png",
43 wield_image = "calendar_node_calendar.png",
44 paramtype = "light",
45 paramtype2 = "wallmounted",
46 is_ground_content = false,
47 walkable = false,
48 groups = { dig_immediate = 3, attached_node = 1, },
49 selection_box = {
50 type = "wallmounted",
52 on_construct = function(pos)
53 local meta = minetest.get_meta(pos)
54 meta:set_string("infotext", S("Calendar"))
55 end,
56 on_rightclick = on_rightclick,
59 if minetest.get_modpath("default") and minetest.get_modpath("dye") then
60 minetest.register_craft({
61 output = "calendar_node:calendar",
62 recipe = {
63 { "default:paper","default:paper","default:paper" },
64 { "default:paper","dye:black","default:paper" },
65 { "default:paper","default:paper","default:paper" },
70 end