ID:156714
 
I'm not exactly sure on how I should handle this, let me explain. Every player will have 2 datums associated with them.
Cave
var
_size
_defense //etc.

Dragon
var
_name
_strength
_defense //etc..


The object is to do things such as quests and attacking other player's Dragons. Attacking a Dragon will take say, an hour to complete. I want players to be able to attack an enemy's Dragon, even if the enemy is offline.

How would I go about handling this?
The dragons could just be held elsewhere, for example you create a DragonManager datum, that holds Dragons and who owns them (probably just a ckey of the owner, as they may be offline) in some form. Makes one of these DragonManagers, as a world variable, and the Dragon (if referenced by the DragonManager) will stick around after the user has logged out (as long as the world carries on running). Datums themselves are not tied to users, unless you tie them in that way.
In response to Stephen001
I took your advice, however I think that I may be doing something wrong. Here is what I have so far:
var/DragonHolder/DragonHolder=new()
//Initialize Datum

DragonHolder
var
list/_dragons
//Holds all dragons


Dragon
var
owner //Dragon Variables
strength
name

mob
New()
..()
var/Dragon/Dragon = new()
//Create a new Dragon

Dragon.owner = ckey
Dragon.name = input(src,"Name your Dragon!") as text
Dragon.strength = rand(10,100)
//Set owner, Input name, Set strength

DragonHolder._dragons.Add(Dragon)
//Add the Dragon to DragonHolder


Stat()
statpanel("Dragon")
for(var/Dragon/D in DragonHolder)
if(D.owner==ckey)
//Display your Dragon's stats
stat("Name:",D.name)
stat("Strength:",D.strength)


As far as I can tell, it never gets past 'var/Dragon/Dragon = new()'. Am I doing this correctly?
In response to Dice1989
Dice1989 wrote:
> DragonHolder
> var
> list/_dragons
> //Holds all dragons
> ...
> for(var/Dragon/D in DragonHolder)
> ...


The dragonholder datum doesn't have a contents list, being a datum, so it can't be looped through like that. Loop through DragonHolder._dragons instead.
In response to Skyspark
Thanks, I should have noticed that.

The initial problem still occurs though, after creating the Dragon, none of the variables are set and I am not prompted with an input.
In response to Dice1989
I tried testing out your code, with some debug messages sent to world added in.

The reason the input() box doesn't show up is because in mob/New(), the player's client hasn't yet attached to the mob.

mob/Login() might be a better place. Also, you might want to initialize the _dragons list with '= list()' so that it starts out as an empty list instead of as null.