ID:2350255
 
Code:
/*  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!
You're using roster.Add(new_member) to add instances to the guild's roster list. This means that the list will have numeric indexes with objects at those indexes. This is different from an associative list. In an associative list, you associate one value with another, like:

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).
[p] outputs its type, hence the "/guild/member" bit. Replace the "[g.roster[p.name]]" with just "[p.name]" and you should be fine. Well except that the guild member's name isn't actually set anywhere.

And in the future, please typecast your variables. guild/var/user is a mob, so it should be mob/user. Like how you have your lists as list/roster and list/rank_li. This makes figuring out what everything is supposed to be much clearer and means you won't have to do useless stuff like var/guild/g = usr.guild because usr.guild will already be a known guild object.
Yes, so i thought i changed the title to solved yesterday, but it didn't.

I made sure to give p.name a value, so adding "name = arg_name" and i basicly did exactly what MisterPerson said. Also, i came upon this problem. As when things happen to the guild while someone is offline, it wont affect them. Therefore each datum needs an id, and be saved. Each mob then uses this id to load guild savefile. Still working on it.

Ty for the tips


EDIT: As i am back on my main PC, i checked over the code again. It is a bit messy, but i took the tips you provided to make changes.