Clean up code a bit

master
Wuzzy 2020-08-28 15:54:35 +02:00
parent 12cc219ad6
commit 4c8e0a8115
3 changed files with 3 additions and 8 deletions

View File

@ -1,7 +1,6 @@
local S = calendar._get_translator("calendar")
minetest.register_chatcommand("calendar", {
param = "",
description = S("Display calendar"),
func = function( name, param )
calendar.show_calendar(name)

View File

@ -53,21 +53,17 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
local days, months, years = calendar.get_date()
local total_days = minetest.get_day_count()
local ddays, dmonths, dyears = calendar.get_date(nil, settings.ordinal)
local wanted_dmonths, wanted_dyears
local wanted_dyears
if not wanted_months then
wanted_months = months
end
if not wanted_years then
wanted_years = years
end
wanted_dmonths = wanted_months
wanted_dyears = wanted_years
if settings.ordinal then
wanted_dmonths = wanted_dmonths + 1
wanted_dyears = wanted_dyears + 1
end
local start_day, end_day
local tdays = 0
tdays = tdays + wanted_years * (calendar.MONTHS * calendar.MONTH_DAYS)
tdays = tdays + wanted_months * calendar.MONTH_DAYS
@ -212,7 +208,8 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
formspec = "size["..size_x..","..size_y.."]" .. formspec
minetest.show_formspec(player_name, "calendar:calendar", formspec)
player_current_calendars[player_name] = { years = wanted_years, months = wanted_months, settings = settings, caption_format = caption_format }
player_current_calendars[player_name] =
{ years = wanted_years, months = wanted_months, settings = settings, caption_format = caption_format }
end
minetest.register_on_player_receive_fields(function(player, formname, fields)

View File

@ -30,7 +30,6 @@ else
end
local S = calendar._get_translator("calendar")
local F = minetest.formspec_escape
dofile(minetest.get_modpath("calendar").."/gameconfig.lua")