Wanted to set the exact game time, when a player enters an area.
This script works, but there's got to be an easier way.
int nHr = GetTimeHour();
int nMn = GetTimeMinute();
int nSc = GetTimeSecond();
int nMs = GetTimeMillisecond();
int nYr = GetCalendarYear();
int nMh = GetCalendarMonth();
int nDy = GetCalendarDay();
nDy += 12;
if(nHr == 20)
{
SetTime(nHr+23,nMn,nSc,nMs);
}
else
{
if(nHr == 21)
{
SetTime(nHr+22,nMn,nSc,nMs);
}
else
{
if(nHr == 22)
{
SetTime(nHr+21,nMn,nSc,nMs);
}
else
{
if(nHr == 23)
{
SetTime(nHr+20,nMn,nSc,nMs);
}
else
{
if(nHr == 0)
{
SetTime(nHr+19,nMn,nSc,nMs);
}
else
{
if(nHr == 1)
{
SetTime(nHr+18,nMn,nSc,nMs);
}
else
{
if(nHr == 2)
{
SetTime(nHr+17,nMn,nSc,nMs);
}
else
{
if(nHr == 3)
{
SetTime(nHr+16,nMn,nSc,nMs);
}
else
{
if(nHr == 4)
{
SetTime(nHr+15,nMn,nSc,nMs);
}
else
{
if(nHr == 5)
{
SetTime(nHr+14,nMn,nSc,nMs);
}
else
{
if(nHr == 6)
{
SetTime(nHr+13,nMn,nSc,nMs);
}
else
{
if(nHr == 7)
{
SetTime(nHr+12,nMn,nSc,nMs);
}
else
{
if(nHr == 8)
{
SetTime(nHr+11,nMn,nSc,nMs);
}
else
{
if(nHr == 9)
{
SetTime(nHr+10,nMn,nSc,nMs);
}
else
{
if(nHr == 11)
{
SetTime(nHr+9,nMn,nSc,nMs);
}
else
{
if(nHr == 12)
{
SetTime(nHr+8,nMn,nSc,nMs);
}
else
{
if(nHr == 13)
{
SetTime(nHr+7,nMn,nSc,nMs);
}
else
{
if(nHr == 14)
{
SetTime(nHr+6,nMn,nSc,nMs);
}
else
{
if(nHr == 15)
{
SetTime(nHr+5,nMn,nSc,nMs);
}
else
{
if(nHr == 16)
{
SetTime(nHr+4,nMn,nSc,nMs);
}
else
{
if(nHr == 17)
{
SetTime(nHr+3,nMn,nSc,nMs);
}
else
{
if(nHr == 18)
{
SetTime(nHr+2,nMn,nSc,nMs);
}
else
{
if(nHr == 19)
{
SetTime(nHr+1,nMn,nSc,nMs);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
SetCalendar(nYr,nMh,nDy);
Ed
Setting the exact time
Débuté par
Ed Venture
, févr. 01 2014 02:32
#1
Posté 01 février 2014 - 02:32
#2
Posté 01 février 2014 - 02:45
Ed Venture wrote...
Wanted to set the exact game time, when a player enters an area.
This script works, but there's got to be an easier way.
I am assuming that not including 10 was an oversight as well as the one hour shift it produced. If this is the case then all those if statements simplify to:
if(nHr >= 20) SetTime(43,nMn,nSc,nMs);
else SetTime(19, nMn, nSc, nMs);
Modifié par WhiZard, 01 février 2014 - 02:45 .
#3
Posté 01 février 2014 - 03:11
WhiZard ,
Oversight, what a tactful way of asking, are you stupid ?
Why, yes ! Yes I am !
Thanks for your help. I knew there had to be an easier way.
As a noob I always try to translate a script as I read it.
One more question.
if(nHr >= 20) SetTime(43,nMn,nSc,nMs);
if(GetTheCurrentHour, Is greater or equall to 20), SetTheTime(43,and son on)
I do not understand what the int. 43 is doing.
Ed
Oversight, what a tactful way of asking, are you stupid ?
Why, yes ! Yes I am !
Thanks for your help. I knew there had to be an easier way.
As a noob I always try to translate a script as I read it.
One more question.
if(nHr >= 20) SetTime(43,nMn,nSc,nMs);
if(GetTheCurrentHour, Is greater or equall to 20), SetTheTime(43,and son on)
I do not understand what the int. 43 is doing.
Ed
#4
Posté 01 février 2014 - 04:15
43 is the solution to all your additions: 20+23, 21+22, etc. this seems intentional as it is 24 (24 hours is one day) greater than 19.
#5
Posté 01 février 2014 - 04:49
I am not sure you are trying to arive at 19:00 or 20:00. 12 days later. either way your script can be simplified to.
void main ()
{
SetTime ( (12*24) + 20, GetTimeMinute(),GetTimeSecond(),GetTimeMillisecond());
}
The hours will wrap into days so there is no reason to also use the SetCalendar function. the set time function will handle both.
EDIT:
I myself would also not worrie about the nimute and second and millsecond and just do the math to begin with and end up with.
SetTime( 308,0,0,0);
void main ()
{
SetTime ( (12*24) + 20, GetTimeMinute(),GetTimeSecond(),GetTimeMillisecond());
}
The hours will wrap into days so there is no reason to also use the SetCalendar function. the set time function will handle both.
EDIT:
I myself would also not worrie about the nimute and second and millsecond and just do the math to begin with and end up with.
SetTime( 308,0,0,0);
Modifié par Lightfoot8, 01 février 2014 - 04:55 .
#6
Posté 02 février 2014 - 03:05
WhiZard,
Thank you ! Now it makes sense to me.
The help you and others here give is of great value to those of us that are still learning.
Thanks again,
Ed
Thank you ! Now it makes sense to me.
The help you and others here give is of great value to those of us that are still learning.
Thanks again,
Ed
#7
Posté 02 février 2014 - 03:31
Lightfoot8,
The script is set on a trigger, on a docked ship, after a 12 day trip.
I realy am a good welder and machinist, but sadly lacking in computer background.
I started as a builder, with no more than the toolset, and my own personal harddrive full of useless crap.
I have learned a great deal, through tutorials, the Lexicon, and the help of others like yourself.
I am doing my best to learn the shortcuts that have been provided to me, but still have a long way to go. But, that's okay, I enjoy the chance to learn new things.
I want to say thank you for the help, you have given me today. It is greatly appreciated.
I fixed the original script, and left it in the mod. I have pasted the scripts in this thread into a word dock I use to save scripts for future use.
Thank you for your input,
ED
The script is set on a trigger, on a docked ship, after a 12 day trip.
I realy am a good welder and machinist, but sadly lacking in computer background.
I started as a builder, with no more than the toolset, and my own personal harddrive full of useless crap.
I have learned a great deal, through tutorials, the Lexicon, and the help of others like yourself.
I am doing my best to learn the shortcuts that have been provided to me, but still have a long way to go. But, that's okay, I enjoy the chance to learn new things.
I want to say thank you for the help, you have given me today. It is greatly appreciated.
I fixed the original script, and left it in the mod. I have pasted the scripts in this thread into a word dock I use to save scripts for future use.
Thank you for your input,
ED





Retour en haut






