ID:142330
 
Code:
        Take_Verb()
set category = "Admin"
var/list/players = list()
for(var/mob/M in world)
if(M.client)
players += M
players += "Cancel"
var/mob/M = input("Whose verbs do you want to edit?") in players
if(M == "Cancel")
return
else
var/tverb = input("Which verb to you want to take?") in M.verbs
M.verbs -= tverb


Problem description:
I get into the game, and when I try to get rid of a verb, nothing happens. Been playing with the code for a while now, no results.

You're making this more complicated than it has to be. Rather than loop through everyone in the world, just pass the mob off as an arguement to the verb.

    Take_Verb(mob/M in world)
var/tverb = input("What verb would you like to take?") in M.verbs + list("0") //0 added to make a false value
if(tverb) //If tverb is true, i.e. not 0
M.verbs -= tverb
In response to Darkmag1c1an11
I believe his problem is that mob/M in world contains NPCs, and generally it's bad to take away common verbs from NPC by accident.
In response to Darkmag1c1an11
Darkmag1c1an11 wrote:
You're making this more complicated than it has to be. Rather than loop through everyone in the world, just pass the mob off as an arguement to the verb.

Like Giantpanda said, a loop is needed, because otherwise NPCs will be available to choose. However, the loop should still be replaced by a simple loop through clients, so if you have 20 players and 200 mobs you don't loop 200 times when you don't need to.
If you test your code by adding an output or something like if(tverb == null)usr << "NULL" you'll see that input() returns null when a verb path is selected (this is the same with proc paths). input() has trouble with those and doesn't return them correctly; to circumvent this, you need to convert the paths to actual text strings. This can be done by simply embedding it in a text string (ie doing verbpathnode = "[verbpathnode]"), which will convert it to a text string (eg /proc/myproc to "/proc/myproc"). Converting them back is done with the text2path() proc, but actually for this case you don't need to do that; the verbs list can accept text strings as well.
So, you're going to need to create a new list for the choices containing every verb of M in text form, then make the player choose from that.

Also, don't add a "Cancel" option to the choices list. Rather, use a combined input type (by using the | operator) of null and your current input type. For in-list inputs, you'd use as null|anything in List, meaning allow it to be null (<-This adds a Cancel button) OR anything in the list (regardless of the type of the stuff in the list).
In response to Kaioken
Okay, so here is what happened, I convert the mob's verbs into a text string, put them in a list. However, when I try to run it, I get this run-time error.

runtime error: Cannot write to atom.verbs.
proc name: Take Verb (/mob/Admin/verb/Take_Verb)
usr: XeroXen (/mob)
src: XeroXen (/mob)
call stack:
XeroXen (/mob): Take Verb()

I get that, right after I select the name of the person who I want to take the verb of, also, here is the code.

            Take_Verb()
set category = "Admin"
var/list/players = list()
for(var/mob/M in world)
if(M.client)
players += M
var/mob/M = input("Whose verbs do you want to edit?") as null|anything in players
if(!M)
return
else
M.verbs = "M.verbs"
var/character_verbs = "M.verbs"
var/list/B = list()
character_verbs += B
var/tverb = input("Which verb to you want to take?") in B
tverb -= M.verbs
if(tverb == "null")
usr << "It worked"
else
usr << "Sorry, didn't work."


In response to XeroXen
What the... that code is screwed up on many levels. Here is how you should do it.
Remove_Verb()
var/list/players = new
for(var/client/C) players += C.mob //loop through all clients and add their mobs to the list. I covered this in another post
var/mob/M = input("Choose mob...") as null|anything in players //allow a cancel option by allowing 'null' input type
if(!M) //if they cancelled
return //which stops the proc (no need for an 'else' after it)
var/list/verbs_txt = new //create a new list for holding the verbs in text form.
for(var/X in M.verbs) //loop through X verbs,
verbs_txt += "[X]" //and add them in text form to the list
//now you can use input() as normal as it accepts the text strings.
M.verbs -= input("Choose verb...") as null|anything in verbs_txt //remove the chosen verb from the verbs list, or remove nothing if they cancelled