/* VARIABLES */
mob/var
guild_rank
guild
guild/member/var
user
name
rank
guild/var
list/roster[]
list/rank_li = list("leader","officer","member")
//Is a handlebar for guild to deal with guild roster and rank, respectivly to individual /mob
guild/member
New(var/mob/ref, rank)
user = ref
rank = rank
proc
get_user()
return user
get_rank()
return rank
guild
New(ref, name)
src.add(ref)
src.name = name
proc
//create a new guild/member inside guild.roster[]. ref equals /mob being added to the guild.
add(var/mob/ref)
if(istype(ref,/mob))
var/guild/member/new_member = new/guild/member(ref, "member")
roster.Add(new_member)
ref.guild = src
mob/verb
check_guild() //debug purposes
var/guild/g = usr.guild
usr << "guild.name = [g.name]"
usr << "guild.roster:"
for(var/guild/member/p in g.roster)
usr << "[p] = [g.roster[p.name]]"
create_guild()
var/name = input("what do you whish to call the guild")
var/guild/guild = new/guild(usr,name) // usr is being stored into guild/member child as "guild/member/user".
usr.guild = guild
Problem description:
mob/check_guild()
//returns: guild.name = test, guild.roster: /guild/member =
Quick explanation. We have a datum called guild, which acts as a guild. The child /member acts as a handlebar to store information from /mob being added. For every mob being added to said /guild creates a new /guild/member child, which is stored into guild.roster
However, mob/check_guild() returns that guild.roster equals blank. It might be a very simple mistake, but i can't find it!
guild.roster[new_member.name] = new_member
Which is how you tried to access the guild/member instance in the check_guild() verb. Because p.name hasn't been associated with any value in g.roster, it returns null, which is output to the world as "". Also, "[p]" probably also outputs as "" because it doesn't have a set name variable. That's what I'm guessing is the root of your problem.
Also, don't forget to add parent_type = /datum to /guild/member. Otherwise your members will inherit from /guild, and you'll get unintended behavior (each guild member will also be a guild object).