A couple informational functions I can't figure out

Paragon

Member
I was wondering if anyone had, or knew how to create any of the following:
A function that would determine the amount of light coming from an individual moon (taking into acount the mini-moon). I know there is moon_phase and moon_light, but those give the total amount of light and I couldn't quite figure out how to have them apply only to a specific moon. (This is for determining the effectiveness of say, grimicite items.)

A function that would return the current day of the week. Again there is date_to_string but that returns a mmddyyyy string, which in theory could be used to figure out the current day, but would require a pretty intricate function taking into account leapyears, months that have a variety of number of days etc.

Also, I realize that this is mostly for people who have written part of a script and just need help rather then asking for a script... but in reality these are just functions for a larger project which requires them but doesn't need the whole script described to ask for help on these minor parts.

Thanks in advance.
 

macman104

Member
Search the forums for a Moonmap function. I wrote that, and you can strip from that pieces to get individual moonlight.
 
[quote author=Paragon link=topic=1423.msg6544#msg6544 date=1199540904]
A function that would return the current day of the week. Again there is date_to_string but that returns a mmddyyyy string, which in theory could be used to figure out the current day, but would require a pretty intricate function taking into account leapyears, months that have a variety of number of days etc.
[/quote]

Actually that isn't very hard at all. This should be good till the year 10000 at which point neither of us should worry much about it anyway:

Code:
int dayofweek(string date)
{
  int c = substring(date,0,2).to_int();
  int y = substring(date,2,4).to_int();
  int m = substring(date,4,6).to_int();
  int d = substring(date, 6, 8 ).to_int();
  if( m<3 )  //for Zeller's Rule march is the first month and febuary is last.
    {
      m=m+10;
      y=y-1;
    }
    else
    {m=m-2;}
  int temp1 = ( ( ( 13*m ) -1 ) /5 );
  int temp2 = (y/4);
  int temp3 = (C/4);
  int f = d + temp1 + y + temp2 + temp3 - (2*C);
  if ( f < 0 ){return (f % 7) + 7;}
  return f % 7;
}

0=sun,1=mon etc.

The problem is this doesn't tell much about kol's moons because if memory serves me they are on an 8 and 16 day cycle, not a 7 day cycle. In theory to get an 8 day cycle out of that function you simply need to replace the 7s on the last 2 lines with 8s. For 16 the same would apply just 16. I don't know where it would start relative to kol's calendar though but it should return the same number every 8 or 16 days (0-7 or 0-15)

Now, just for the fun of it, I made the script into something that makes more sense to me, and my playing around with the relay browser. Here that is:

Code:
String [int] weekdays;
weekdays[0] = "Sun";
weekdays[1] = "Mon";
weekdays[2] = "Tues";
weekdays[3] = "Wednes";
weekdays[4] = "Thurs";
weekdays[5] = "Fri";
weekdays[6] = "Sat";

String [int] months;
months[1] = "January";
months[2] = "Febuary";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";

string [int] suffix;
suffix[0] = "th";
suffix[1] = "st";
suffix[2] = "nd";
suffix[3] = "rd";
suffix[4] = "th";
suffix[5] = "th";
suffix[6] = "th";
suffix[7] = "th";
suffix[8] = "th";
suffix[9] = "th";

int dayofweek(string date)
{
  int c = substring(date,0,2).to_int();
  int y = substring(date,2,4).to_int();
  int m = substring(date,4,6).to_int();
  int d = substring(date, 6, 8 ).to_int();
  if( m<3 )  //for Zeller's Rule march is the first month and febuary is last.
    {
      m=m+10;
      y=y-1;
    }
    else
    {m=m-2;}
  int temp1 = ( ( ( 13*m ) -1 ) /5 );
  int temp2 = (y/4);
  int temp3 = (C/4);
  int f = d + temp1 + y + temp2 + temp3 - (2*C);
  if ( f < 0 ){return (f % 7) + 7;}
  return f % 7;
}

string format_date(string date)
{
  int y = substring( date,0,4).to_int();
  int m = substring(date,4,6).to_int();
  int d = substring(date,6,8).to_int();
  
  string day;
  if(d = 11 || d = 12 || d = 13)
    {day = d + suffix[0];}
    else
    {day = d + suffix[d];}

 return weekdays[dayofweek(date)] + "day, " + months[m] + " " + day + " " + y;
}
today_to_string().format_date().print();

which when ran today printed:
Sun, January 6th 2008
 
Top