ID:150007
 
I heard mention of creating an array through a list and I'm wondering if this is what I should do for some of my code -

As an example, my internal game calander has names for the hour / month / year etc (sort of like it's the Hour of the Crow in the Day of Celebration in the 42nd assention of the Dragon).

I've been keeping track of the names like this (from memory):
var/global/HOUR=21
calander/proc/Hour2Text()
    var/H=HOUR
    switch(H)
        if(1) return "Crow"
        if(2) return "Cat"
        if(3) return "Dog"
        // etc

Gabriel wrote:
I heard mention of creating an array through a list and I'm wondering if this is what I should do for some of my code -

As an example, my internal game calander has names for the hour / month / year etc (sort of like it's the Hour of the Crow in the Day of Celebration in the 42nd assention of the Dragon).

I've been keeping track of the names like this (from memory):
var/global/HOUR=21
calander/proc/Hour2Text()
var/H=HOUR
switch(H)
if(1) return "Crow"
if(2) return "Cat"
if(3) return "Dog"
// etc

Lists are definitely a better way to go. You can set up a list var for your calendar object that's shared by all the calendars, so it'd really be quite convenient--and faster. List indexes are numbered from 1 up, so your system will work nicely with that.
calendar
var/list/hourname=list("Crow","Cat","Dog",...)
var/list/dayname=list("Slumpday","Runeday","Purpleday",...)
var/list/yearname=list("Wheel","Muskrat","Hot Dog",...)

proc/Hour2Text()
return hourname[HOUR]

proc/Weekday2Text()
return dayname[DAYOFWEEK]

proc/Year2Text()
return yearname[(YEAR%12)+1] // Chinese-style 12-year cycle

Lummox JR
Gabriel wrote:
I heard mention of creating an array through a list

A list is an array by the way. It's just the DM name for an array.
Not related to lists, but check out Deadrons Calendar Library. Tons of premade calendar functionality, its really quite nice. (Since he didn't suggest it, I will)

flick()
In response to Flick
Flick wrote:
Not related to lists, but check out Deadrons Calendar Library. Tons of premade calendar functionality, its really quite nice. (Since he didn't suggest it, I will)

I didn't mention it because it was originally inspired by Gabriel, so I figured he knew about it!

But thanks for the reference nonetheless!
In response to Deadron
Hey Deadron :). I just like customizing for my own system, otherwise I'd use the calander. If I remember correctly, the calander system you build uses real-life time for reference wheras I need one driven by the game itself.

I also use the calander for linking to my global systems and running code based off of the time... for example, I have loops set up that run every minute of game time (so if there was a 5:1 ratio, that would be about every 12 seconds).

Easier for me to do this within the time/calander system I'm using than create a seperate system for the loops and then use a seperate system to keep track of date and time.