diff --git a/gui.lua b/gui.lua index 76a8c02..becbed0 100644 --- a/gui.lua +++ b/gui.lua @@ -14,7 +14,7 @@ local player_current_calendars = {} local ORDINAL = true -local function show_calendar(player_name, ordinal, wanted_months, wanted_years) +function calendar.show_calendar(player_name, ordinal, wanted_months, wanted_years) local days, months, years = calendar.get_date() local total_days = minetest.get_day_count() local ddays, dmonths, dyears = calendar.get_date(nil, ordinal) @@ -157,6 +157,33 @@ minetest.register_chatcommand("calendar", { param = "", description = S("Display calendar"), func = function( name, param ) - show_calendar(name, ORDINAL) + calendar.show_calendar(name, ORDINAL) + end, +}) + +minetest.register_node("calendar:calendar", { + drawtype = "signlike", + description = S("Calendar"), + tiles = { "calendar_calendar.png" }, + inventory_image = "calendar_calendar.png", + wield_image = "calendar_calendar.png", + paramtype = "light", + paramtype2 = "wallmounted", + is_ground_content = false, + walkable = false, + groups = { dig_immediate = 2, attached_node = 1, }, + selection_box = { + type = "wallmounted", + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Calendar")) + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if not clicker:is_player() then + return itemstack + end + calendar.show_calendar(clicker:get_player_name(), ORDINAL) + return itemstack end, }) diff --git a/textures/calendar_calendar.png b/textures/calendar_calendar.png new file mode 100644 index 0000000..ab780fb Binary files /dev/null and b/textures/calendar_calendar.png differ