Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-01-2005, 07:06 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
timevar

Recently, I was looking for documents on "timevar". I could not find any documentations on timevar. Can someone explain it or find a documentation on it for me. (I already used search ;-)).

Possibly, just explain how you would get hours/minutes/seconds out of the big long variable.

Maybe, if possible, someone can show me how to divide it correctly so it would be like hmm. Half Hour (irl) --> One day (Graal)

I would TRULY appreciate if you can show me how this would be done. (thanks)
Reply With Quote
  #2  
Old 05-01-2005, 07:23 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Set to zero when server starts, increments every five seconds.

There are 60 seconds in a minute, 60 minutes in an hour and 24 hours in a day.

If you can't figure it out from there, you need a new hobby.
__________________
Reply With Quote
  #3  
Old 05-01-2005, 07:48 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
seconds = (timevar*5)%60;
minutes = int((timevar*5)/60)%60;
hours = int((timevar*5)/(60*60))%24;
days = int((timevar*5)/(60*60*24));

I believe? I'm not sure. I did this pretty fast.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #4  
Old 05-01-2005, 08:11 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
so would it be like:

NPC Code:
//#CLIENTSIDE
if (timeout || created) {
//Some variables
setstring this.month,January,February,March,April,May,June,J uly,August,September,October,November,December;
this.minute = int(timevar/.2);
this.hour = int(this.minute/60);
this.day = int(this.hour/24);
this.month = int(this.day/31);
this.year = int(this.month/12);
this.Nminute = this.minute%60;
this.Nhour = this.hour%24;
this.Nday = this.day%24;
this.Nmonth = this.month%12;
this.Nyear = this.year%1;
//Variable Ending
if (this.Nminute < 10) setstring this.Nminute,0#v(this.Nminute);
else setstring this.Nminute,#v(this.Nminute);
if (this.Nhour > 12) setstring this.Nhour,#v(this.Nhour-12); else
if (this.Nhour == 0) setstring this.Nhour,1; else
setstring this.Nhour,#v(this.Nhour);
if (this.Nhour > 12) setstring this.time,PM; else setstring this.time,AM;
message The time is now #s(this.Nhour):#s(this.Nminute) #s(this.time) on #I(this.month,this.Nmonth-1) #v(this.Nday), #v(this.Nyear)!;
timeout = 0.05;
}





Err, I probally can code it better. But I was just rushing, how is that? Is that every 30 min --> 1 graal day?


Quote:
Originally Posted by Velox Cruentus
seconds = (timevar*5)%60;
minutes = int((timevar*5)/60)%60;
hours = int((timevar*5)/(60*60))%24;
days = int((timevar*5)/(60*60*24));

I believe? I'm not sure. I did this pretty fast.
Is that 30 minutes per graal day or no?
Reply With Quote
  #5  
Old 05-01-2005, 09:05 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
No. That's a direct conversion of.. 1 day = 1 graal day.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #6  
Old 05-01-2005, 10:03 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by KuJi
this.minute = int(timevar/.2);
Why the heck would you divide by 0.2 when you can multiply by 5?
__________________
Reply With Quote
  #7  
Old 05-01-2005, 04:40 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Quote:
Originally Posted by Kaimetsu
Why the heck would you divide by 0.2 when you can multiply by 5?
I asked a friend, he gave me the conversion.
Reply With Quote
  #8  
Old 05-01-2005, 08:43 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by KuJi
I asked a friend, he gave me the conversion.
Haha, okay.
__________________
Reply With Quote
  #9  
Old 05-02-2005, 04:53 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Because not everybody is familier with programming theory.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #10  
Old 05-02-2005, 06:32 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
Ah! Adam! You are the guilty person who gave the script! Note that I gave it before it was posted in real-time conversion... =3 Ohwell... I haven't heard much from you. Where've you been?
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #11  
Old 05-02-2005, 07:11 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Velox Cruentus
seconds = (timevar*5)%60;
minutes = int((timevar*5)/60)%60;
hours = int((timevar*5)/(60*60))%24;
days = int((timevar*5)/(60*60*24));

I believe? I'm not sure. I did this pretty fast.
What do you suppose would happen if timevar incremented during the execution of your script?
Reply With Quote
  #12  
Old 05-02-2005, 07:40 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
It will most likely not have an impact -- Considering that it would only rise of one... The only cases that it would actually matter is if it was the last second required for the minute, hour, day, so on... And while that time, it would display an entire minute/hour/day - 5 seconds more. However... The likelihood of such occurance is very minimal, and the actual damage it may cause, depending on the situation, won't matter at all.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #13  
Old 05-02-2005, 08:16 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
"timevar" is not changed in the middle of a script execution, so you can use that securely.
On serverside you also have the option to use "timevar2" which gives the seconds since Janurar 1st 1970, and is very precise (nano seconds), but might change between the call of two script functions, but you can still assign it to some temp variable before getting the seconds, minutes etc.
Reply With Quote
  #14  
Old 05-02-2005, 11:17 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
Ohh! "timevar2" would actually be quite useful for finding the actual date...

Wait! How do we know how much seconds past since? Considering there are leap years, and well... The amount of days in a year is something like 365.245...
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #15  
Old 05-02-2005, 11:59 PM
Evil_Trunks Evil_Trunks is offline
Evil
Evil_Trunks's Avatar
Join Date: Dec 2004
Posts: 391
Evil_Trunks is on a distinguished road
Almost all languages have built in functions for doing this because it's a quite complicated process.
__________________

Reply With Quote
  #16  
Old 05-03-2005, 12:46 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
ALL!... Except Graal.

PHP Code:
function date()
{
  
this.time int(timevar2);
  
this.day int(int(this.time/(60*60*24))%365.242199);
  
this.month := find_month(this.day);
  
this.year 1970 int(this.time/(60*60*24*365.242199));

  return 
this.month[0] @ "/" @ (this.month[1] + 1) @ "/" this.year;
}

function 
find_month(day)
{
  
:= 0;
  while (
true)
  {
    if (
day days_in_month(i))
      return {
day,i};

    
day -= days_in_month(i);
    
++;
  }
}

function 
days_in_month(month)
{
  return (
month == 28 30 + (month 2));

I don't have it leap years intergrated, but the next leap year is in three years. This is what I made
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #17  
Old 05-03-2005, 01:10 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
It would be possible to add a function which returns the year, month, day of the year, day of the month, day of the week, hours, minutes, and seconds for a given unix time (timevar2 + 3600*timezone)
Reply With Quote
  #18  
Old 05-03-2005, 01:53 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Quote:
Originally Posted by Stefan
It would be possible to add a function which returns the year, month, day of the year, day of the month, day of the week, hours, minutes, and seconds for a given unix time (timevar2 + 3600*timezone)
What about a timevar that gets the time automatically determining what timezone is put in the serveroptions:

EX


If GMT in options --> -5:00 (Daylights Saving)

then it would show automatically the time for that zone. I believe if you script something like this the time may change or be too fast/slow or just be quitely laggy. Not sure.

Time would show: 7:52 PM (time i posted this --> Eastern Time)
Reply With Quote
  #19  
Old 05-03-2005, 02:37 AM
pacMASTA pacMASTA is offline
British Guy
pacMASTA's Avatar
Join Date: Aug 2003
Location: California
Posts: 377
pacMASTA has a little shameless behaviour in the past
Send a message via AIM to pacMASTA Send a message via MSN to pacMASTA
Or just make it a client var for people to change for their own timezone but make it so they cant change it >_> cause its not fun when you can only play at 8:00 on server time
and something shuts at 7 and ect.
Reply With Quote
  #20  
Old 05-03-2005, 02:43 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by KuJi
What about a timevar that gets the time automatically determining what timezone is put in the serveroptions
Too inflexible. It'd be extremely easy to script using the feature Stefan described, assuming we'd be given access to timezone information.

Quote:
I believe if you script something like this the time may change or be too fast/slow or just be quitely laggy
No.
__________________
Reply With Quote
  #21  
Old 05-03-2005, 06:29 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally Posted by Velox Cruentus
Ah! Adam! You are the guilty person who gave the script! Note that I gave it before it was posted in real-time conversion... =3 Ohwell... I haven't heard much from you. Where've you been?
I gave no script. Don't know a thing about it really.
I was just claiming, most people who script don't understand
what it means to make a script clean and efficient.

I just stopped by to see if anything was new, like usual.
I'm playing another mmorpg (I'll be kind and not mention it on the forums of another mmorpg)
But mostly I am working, and spending time with my girlfriend. I dont' have time for this anymore. AIM: RogueTCN I answer if i'm there. Your welcome to send a message even if it says i'm busy (which it does for days on end, even if i'm not there, or if I am there.)
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.