lotrointerface.com
Search Downloads

LoTROInterface SVN Calendar

[/] [trunk/] [FrostyPlugins/] [Calendar/] [Commands.lua] - Rev 20

Compare with Previous | Blame | View Log

-- Calendar commands

--------------------------------------------------------------------------
--- Register commands with LOTRO chat window
function RegisterCommands()
        calendarCommand = Turbine.ShellCommand();

        --------------------------------------------------------------------------
        function calendarCommand:Execute( command, arguments )
                if ( "" == arguments ) then
                        Turbine.Shell.WriteLine(calendarCommand:GetHelp());
                elseif ( "help" == arguments ) then
                        Turbine.Shell.WriteLine(calendarCommand:GetHelp());
                elseif ( "?" == arguments ) then
                        Turbine.Shell.WriteLine(calendarCommand:GetHelp());
                elseif ( "show" == arguments ) then
                        calendarWindow:SetVisible( true );
                elseif ( "hide" == arguments ) then
                        calendarWindow:SetVisible( false );
                elseif ( "toggle" == arguments ) then
                        calendarWindow:SetVisible( not calendarWindow:IsVisible() );
                elseif ( "options" == arguments ) then
            Turbine.PluginManager.ShowOptions(Plugins["Calendar"]);
                elseif ( "list" == arguments ) then
            calendarWindow:ListEntries();
                --elseif ( string.match(arguments,"^dayLabel") ) then
                --      local patStart,patEnd,weekday = string.find(arguments,"^dayLabel (%d+)");
                --      if( nil ~= patStart ) then
                --              weekday = tonumber(weekday);
                --              Turbine.Shell.WriteLine("dayLabel(" .. weekday .. ")"); 
                --              Turbine.Shell.WriteLine(calTools:dayLabel( weekday ));
                --      else
                --              Turbine.Shell.WriteLine("Missing required parameters: dayLabel <weekday>");
                --      end
                --elseif ( string.match(arguments,"^monthLabel") ) then
                --      local patStart,patEnd,month = string.find(arguments,"^monthLabel (%d+)");
                --      if( nil ~= patStart ) then
                --              month = tonumber(month);
                --              Turbine.Shell.WriteLine("monthLabel(" .. month .. ")"); 
                --              Turbine.Shell.WriteLine(calTools:monthLabel( month ));
                --      else
                --              Turbine.Shell.WriteLine("Missing required parameters: monthLabel <month>");
                --      end
                --elseif ( string.match(arguments,"^isLeapYear") ) then
                --      local year = string.match(arguments,"^isLeapYear (%d+)");
                --      if( nil == year ) then
                --              local year = Turbine.Engine.GetDate().Year;
                --              Turbine.Shell.WriteLine("defaulting year=" .. year);
                --      end
                --      year = tonumber(year);
                --      if type(year) == "number" then
                --              Turbine.Shell.WriteLine("isLeapYear(" .. year .. ")=" .. 
                --                      (CalTools:isLeapYear(year) and "true" or "false"));
                --      else
                --              Turbine.Shell.WriteLine("Missing required parameters: isLeapYear [<year>]");
                --      end
                --elseif ( string.match(arguments,"^daysInMonth") ) then
                --      local patStart,patEnd,month,year = string.find(arguments,"^daysInMonth (%d+) (%d+)");
                --      if( nil ~= patStart ) then
                --              month = tonumber(month);
                --              year = tonumber(year);
                --              Turbine.Shell.WriteLine("daysInMonth(" .. month .. "," .. year .. "):" .. 
                --                      CalTools:daysInMonth(month,year));
                --      else
                --              Turbine.Shell.WriteLine("Missing required parameters: daysInMonth <month> <year>");
                --      end
                --elseif ( string.match(arguments,"^dayOfWeek") ) then
                --      local patStart,patEnd,year,month,day = string.find(arguments,"^dayOfWeek (%d+) (%d+) (%d+)");
                --      if( nil ~= patStart ) then
                --              year = tonumber(year);
                --              month = tonumber(month);
                --              day = tonumber(day);
                --              Turbine.Shell.WriteLine("dayOfWeek(" .. month .. "/" .. day .. "/" .. year .. ")");
                --              local dayOfWeek = CalTools:dayOfWeek(year, month, day);
                --              Turbine.Shell.WriteLine("dayOfWeek(" .. month .. "/" .. day .. "/" .. year .. ")=" .. 
                --                      dayOfWeek);
                --              Turbine.Shell.WriteLine("dayOfWeekLabel[" .. dayOfWeek .. "]=" .. 
                --                      calTools:dayLabel( dayOfWeek ));
                --      else
                --              Turbine.Shell.WriteLine("Missing required parameters: dayOfWeek <year> <month> <day>");
                --      end
                else
                        Turbine.Shell.WriteLine("Calendar: Unsupported Command");
                end
        end
        
        --------------------------------------------------------------------------
        function LoadStrings()
                LANGID = Utils.GetClientLanguage();
                _STRINGS = {};
                import (PLUGINDIR..".Strings");
        end
        
        --------------------------------------------------------------------------
        function GetString(stringID)
                if stringID == nil then return "" end;
                local sOutput = "";
                if _STRINGS[stringID] ~= nil then
                        sOutput = _STRINGS[stringID];
                else
                        sOutput = "<string error ID: "..stringID..">";
                end
                return sOutput;
        end
        
        --------------------------------------------------------------------------
        function calendarCommand:GetHelp()
                return "Calendar\n" ..
                        "calendar show: Display the calendar\n" ..
                        "calendar hide: Hides the calendar\n" ..
                        "calendar list: Lists the calendar entries\n" ..
                        "calendar options: show options\n";
                        --"calendar initialVisiblity {true,false} : sets initial calendar visibility on load\n" ..
                        --"calendar dayLabel <weekday> : shows name of specified day of week\n" ..
                        --"calendar monthLabel <month> : shows name of specified month\n" ..
                        --"calendar isLeapYear [<year>] : returns true if specified year is a leap year, false otherwise\n" ..
                        --"calendar daysInMonth <month> <year> : returns number of days for specified month and year \n" ..
                        --"calendar dayOfWeek <year> <month> <day> : returns the day of the week for specified date\n";
        end
        
        --------------------------------------------------------------------------
        function calendarCommand:GetShortHelp()
                return "Shows or hides the calendar.";
        end

        Turbine.Shell.AddCommand( "cal;calendar", calendarCommand );
end

Compare with Previous | Blame


All times are GMT -5. The time now is 06:27 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui