Server Totals
Deglos - (2)
Underdark - (1)
Visimontium - (1)
Ferrell - (0)
Elysia - (0)
M'Chek - (0)
Le'Or - (0)
Wilderness - (0)
Mikona - (0)
Total players: 4
Gallery

Links Menu

Date and time functions

Moderators: Nighthawk4, Dungeon Masters

Date and time functions

PostAuthor: Papillon » Sun Aug 04, 2002 11:43 pm

I wrote a small library for handling date and time values.

// Name : Date and time functions
// Author : Ingmar Stieger / Papillon
// Modified : August 04, 2002
// Version : 0.1

// Implemented datatype
// * DateTime

// Implemented functions
// * addDateTime() : Add two DateTimes
// * subDateTime() : Substract two DateTimes
// * compareDateTime() : Compare two DateTimes
// * getCurrentDateTime() : Return current DateTime
// * newDateTime() : Create new DateTime with given values
// * SetLocalDateTime() : Set oObject's local DateTime variable to date
// * GetLocalDateTime() : Get oObject's local DateTime variable
// * debugPrintDateTime() : Print DateTime for debugging purposes

// See function headers for details
//
// Example:
/* object oPC = GetPCSpeaker();

struct DateTime date1 = getCurrentDateTime();
struct DateTime date2 = newDateTime(0,0,0,8); // 8 hours later
struct DateTime finished = addDateTime(date1, date2);

SetLocalDateTime(oPC, "forge_shortsword_blade_finished", finished);
*/

--- cut

The source is too long to post here, but I've attached it as a .erf file.

Papillon
Team Member; Retired with Honors
 
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm

PostAuthor: Silk » Thu Aug 15, 2002 5:40 pm

You need to edit this a bit.

We don't want to store each variable seperately as a Persistant Variable.

Encode all the date/time variables into one deliminated string (don't use | pipes as a deliminator).

Then Make that set that string as persitant.

When your get the persistant string, simply decode the string into it's seperate date/time components.

The Persistant Date script get's too large too fast if you save 7+ variables every time for this functionality.

Otherwise, this code is very cool. I'll be using it for my tracking scripts.
Silk

Member of the MadK@t lover's group.
User avatar
Silk
Co-Founder
 
Posts: 6665
Joined: Fri Sep 14, 2001 6:47 pm

PostAuthor: Papillon » Tue Aug 27, 2002 11:17 am

Updated version 0.2

* Date encoding added as suggested by Silk

Papillon
Team Member; Retired with Honors
 
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm

PostAuthor: Silk » Tue Aug 27, 2002 3:05 pm

schweet!!!
Silk

Member of the MadK@t lover's group.
User avatar
Silk
Co-Founder
 
Posts: 6665
Joined: Fri Sep 14, 2001 6:47 pm


Return to NWN Scripting

Who is online

Registered users: Yahoo [Bot]