ID:164966
 
I am trying to make a system in which a guild leader can control what verbs each other level of guild member has. Currently all possible verbs can be chosen from are under the type /mob/player/guild/verb (but it could really be anything), and I want to be able to pick verbs from that type and add them to lists for each level. All of this durring run time. Once the leader chooses the verb it is added to a list which is saved along with the guild. I haven't been able to make a list of verbs with the below method of picking a verb from a list to add to another list. The verb is not being passed as a verb, but as well nothing.
var/list/DIRverbs = new()
switch(alert(src,"Add or Remove Verbs","DIRECTOR VERBS","Add","Remove","Cancel"))
if("Add")
DIRverbs += input(src,"What Verb Would You Like To Add?","DIRECTOR VERBS",) in typesof(/mob/player/guild/verb)
if("Remove")
DIRverbs -= input(src,"What Verb Would You Like To Remove?","DIRECTOR VERBS",) in DIRverbs
if("Cancel") return

I am sure it is just something simple I have missed. Or is it only possible to store verbs in a mob/clients verb list?

var/list/verb_list = new()

guild/verb/test()
usr << "A guild verb you've just executed."

mob/verb/verberation()
switch(alert(src,"Add or Remove Verbs","DIRECTOR VERBS","Add","Remove","Cancel"))
if ("Add")
var/list/verbs = new()
for(var/I in typesof(/guild/verb))
verbs += "[I]"
verb_list += input("Add which verb?") in verbs
if ("Remove")
verb_list -= input("Remove which verb?") in verb_list

mob/verb/collect_verbs()
src.verbs -= typesof(/guild/verb) // get rid of existing guild verbs.
for(var/I in verb_list)
src.verbs += new I // add the new updated verbs for the guild


With this method, it will save the verb's type in text form to the verb_list. This way, the verb can be recreated with the new() procedure wherever you want.

I thought it was possible to save verb objects to lists, but I guess not.

Then you can go on to remove the verb_list variable, and store each list to a savefile, or whatever you plan on doing. Then make a procedure like collect_verbs to be called whenever the list is modified, grab all of the guild members online, and update their guild verbs.
In response to Keeth
I was thinking I was going to have to do something like this, I kind of hoped I wouldn't have to though. Oh well. Thanks.
In response to Drumersl
You don't have to. You could use an associative list.

My code:
var/list/verbList = list()
for(var/i in typesof(/mob/player/guild/verb))
verbList["[i]"] = i
var/choice = input(src, "What verb would you like to add?", "Add Director Verb")as null|anything in verbList
if(isnull(choice)) return
DIRverbs += verbList[choice]


This also adds a "Cancel" button to the input box.
In response to Yota
Hmm.
I didn't think of that.
In response to Keeth
Don't use new with verbs, especially not if you don't actually want a dynamic name/desc. You can directly add a type path or text string containing a type path to the verbs list, and it will work. Using new makes removing those verbs later a mess.