ID:264668
 
Code:
clan
var
Leader
Name
Desc
list/Members = list()
proc/CreateClan(mob/M, name, desc)
src.Name = name
src.Leader = M
src.Desc = desc
M<<output("Your Clan, [name], has been successfully created.","messages")
mob/verb/Create_Clan()
var/K = input("What would you like the name of your clan to be?")
var/L = input("What is your clan's description? \n You can leave this blank for no Description.")
if(K != "" && lentext(K) <= 3)
CreateClan(usr, K, L)


Problem description:
This is my first time making my own datum. As far as I know, I specified everything correctly in the datum, but I do not know what I should put next to CreateClan(usr, K, L) to make it work. I get this error:
Codes\Clans.dm:16:error: CreateClan: undefined proc

The problem is that you're trying to call a global proc, not a local proc, and the global proc doesn't exist. Calling CreateClan() is different from clan.CreateClan() as mob.Jump() is to Jump().
In response to Jeff8500 (#1)
Oh, so I just need to put clan in front of it? Thanks.
In response to RushSoft Developers (#2)
It still wont work...It says undefined var when I use clan.CreateClan. Suggestions?
You're doing this wrong.

clan
var
leader
name
desc
members

New(mob/l, name, desc)
leader = l
SetName(name)
SetDesc(desc)

AddMembers(leader)

proc
SetName(n)
if(!n)
n = "[l]\s Clan"

// Names can only be thirty characters long.
name = copytext(n, 1, 30)

SetDesc(d)
// Descriptions can only be 150 characters long.
desc = copytext(d, 1, 150)

AddMembers(...)
for(var/mob/m in args)
if(m.client)
members += m

mob
var/clan/clan

verb/Create_Clan()
if(!clan)
var/name = input("Name")
var/desc = input("Desc")

clan = new(src, name, desc)
if(clan)
src << "You are now the leader of clan [clan]."
In response to RushSoft Developers (#3)
The problem is that you need an actual clan object to call it. You can make the proc a global proc, and then do what you were originally doing, though.
In response to Popisfizzy (#4)
Also, clans should have individual tags or something for the mob to store (and later locate the clan with), so that when you load a player's save, you don't get the roll back bug.
In response to Jeff8500 (#5)
Thanks a lot. This really helped. I understand some more about datums now ^.^
In response to Jeff8500 (#6)
Hmmm...Could you go more into detail? I have never been very good with savefiles x.x
In response to RushSoft Developers (#8)
Ultimately, it's up to you what to do; you just need to make sure that you don't load a reference to the clan, unless the clan no longer references players.
In response to Jeff8500 (#9)
Im really sorry for sounding so noobish, but I do not have enough experience apparently...xD
What do you mean by "you don't load a reference to the clan"? By that question I mean what do you mean by reference?
In response to Popisfizzy (#4)
Thanks for all of your help, but would you mind helping me on one more thing?
mob/verb
View_Clans()
var/html="<html>&lt;STYLE&gt;BODY {background:#555555}&lt;/STYLE&gt;<head><title>View Clans</title></head>\
<body><table border=1 width=98% cols=3><tr>\
"

for(var/clan/M in allclans)
html+="<tr><td>[M.name]</td><td>[M.leader]</td><td>[M.members]</td>"
html+="</table></body></html>"
src<<browse(html,"window=viewclans;size=275x300")

I tried making this system to see all the clans that are registered. It doesn't work. I think it is because of the way I tried to use the for(), but I couldn't think of what to put there. Any help please?
In response to RushSoft Developers (#11)
In /clan.New() you're adding src to a global list of clans, correct? I assume so given that code, but I can't be sure and just want to verify. Also, M.members will simply output /list.
In response to Popisfizzy (#12)
I actually had it under the Create Clan verb. After moving it under New(), it sort of worked. It showed the table, but it had two columns, both of which had my key in it.
In response to RushSoft Developers (#13)
The problem is that the 3rd column isn't being displaying because you're trying to put a list where it shouldn't be. You're going to need to turn the list into a string, so it will actually display something. However, if a quick list2params(M.Members) doesn't add a 3rd column, then the problem runs a little deeper than I thought.