31
Modification Help / Re: A clock.
« on: December 11, 2017, 05:40:10 PM »
The day counter is supposed to add a day every six hours actually. It's intended for a friend's server, nothing special really. But my friend and I rather the months have separate day limits. I saw it possible in a CityRPG script but I couldn't figure out how they did it. I vaguely figured out how to do this, and if someone could walk me through how I could make this neater/actually work properly (and save the time when the host closes) that'd be awesome. I only tried it myself first to practice a little bit, since I'm mostly new to using torquescript.
Here's what I put together based on your guys help so far (besides what phantos suggested, as I didn't quite understand what he asked to do.) and snippets of code from other places. It showed no errors at the end but didn't function properly at all. December counted to 28 days only, then reset back to December 1st rather than January 1st. The announcement didn't print the variables for the names and stuff.
Here's what I put together based on your guys help so far (besides what phantos suggested, as I didn't quite understand what he asked to do.) and snippets of code from other places. It showed no errors at the end but didn't function properly at all. December counted to 28 days only, then reset back to December 1st rather than January 1st. The announcement didn't print the variables for the names and stuff.
Code: [Select]
$day = 1;
$month = 1;
$year = 2150;
$m = "January";
$n = "th";
$dayInterval = 5000; //set to five seconds so I can actually test it, otherwise would be 2,600,000 for six hours. I dont even know if that's valid for torquescript.
function dayAdder()
{
cancel($dayAdder);
$day += 1;
if ($month = 1)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 2)
{
if ($day > 28)
{
$day = 1;
$month += 1;
}
}
if ($month = 3)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 4)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 5)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 6)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 7)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 8)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 9)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 10)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 11)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 12)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
switch$ ($month)
{
case 1: $m = "January";
case 2: $m = "February";
case 3: $m = "March";
case 4: $m = "April";
case 5: $m = "May";
case 6: $m = "June";
case 7: $m = "July";
case 8: $m = "August";
case 9: $m = "September";
case 10: $m = "October";
case 11: $m = "November";
case 12: $m = "December";
default: $m = "n/a";
}
switch$ ($day)
{
case 1: $d = "st";
case 2: $d = "nd";
case 3: $d = "rd";
case 21: $d = "st";
case 22: $d = "nd";
case 23: $d = "rd";
case 31: $d = "st";
default: $d = "th";
}
announce("Today is $m $day$d, $year.);
schedule($dayInterval, 0, dayAdder);
}
The only thing that worked properly was that it played every five seconds and each number had it's own suffix. 1=st, 25=th, etc.