ID:264276
 
Thisis just carried over from a Developer How-To ;p


Mizukouken Ketsu wrote:
> var/list/Verbs = list()
> proc/Add2VerbsList()
> for(var/atom/V in world)
> Verbs += V.verbs
>
> mob/Owner/verb
> Give_Verb(mob/M in world)
> set name = "Give Verb"
> set category = "Owner"
> Add2VerbsList()
> var/V = input("Which verb would you like to give [M]?","Verbs") as anything in Verbs
> M.verbs += V
>


Runtime error >_>

runtime error: wrong type of value for list
proc name: Give Verb (/mob/Owner/verb/Give_Verb)
usr: Brian (/mob)
src: Brian (/mob)
call stack:
Brian (/mob): Give Verb(Brian (/mob))
You cannot select a verb path in input(). You have to change it to text, then change it back into a type with text2path().
Also: you should always use an option of the null input type (combined with others by using the | operator), which allows players to Cancel. You should then check if the value returned is true of course, but you should do that anyway most of the time.
So in your case you'd have

Additionally, your method of getting all the available verbs isn't very good. First, it will cause a lot of duplicate values in the global Verbs list, which I'm not sure how input() handles (if it displays all the duplicates, it'll get ugly). Second, it will grab all kinds of verbs, even those not supposed to be on mobs... Third, it depends on actual objects existing to have access to verbs [that they have], etc etc.
Instead, you want to look into the typesof() proc; look it up in the DM Reference. It's quite straightforward; just make sure to use a list of text choices in input() as said.
In response to Kaioken
I don't want to type in a whole bunch of typesof() procs for every verb pathname. This was a quick and easy solution. If the owner of the game doesn't want all those "bad" or "duplicate" verbs you mention, I'll come back here for reference on what to do.

As for what Jeff said:

How do I convert var/V into text? There's no path2text() proc, yet there's a text2path() proc? o.O Weird
In response to Mizukouken Ketsu
You simply embed it into text. Embedding values into text often changes them (or results in null instead, with certain values). For example, when embedding an object reference that has a name var, its name is displayed (with "the" or "The" as applicable), when using a number it is converted to its text counterpart, etc. When using a type path, you get its literal text string counterpart instead of actual reference value or whatever, which is very useful.
In response to Kaioken
Well that's great info and all, Kaioken, but unfortunately that doesn't answer my question since I don't know how to embed a typepath into text... or embed anything for that matter.
In response to Mizukouken Ketsu
You can embed stuff in text by enclosing it in square brackets.

MagicDatum

world
New()
..()
var/MagicDatum/m = new()
var/embedded = "The type is: [m.type]"
In response to Stephen001
I tried that below and it still gives me the same runtime error.

    Give_Verb(mob/M in world)
set name = "Give Verb"
set category = "Owner"
Add2VerbsList()
var/V = input("Which verb would you like to give [M]?","Verbs") as anything in Verbs
var/Q = "[V]"
M.verbs += text2path(Q)
In response to Mizukouken Ketsu
The problem is the entries in Verbs are not text. Or at least that is what Kaioken seems to be suggesting. You need to convert those verb paths into text before you use the list as a data-source for input(), then use text2path(V) to convert the selected verb back to a path.

proc/Add2VerbsList()
for(var/atom/A in world)
for (var/V in A.verbs)
Verbs += "[V]"
In response to Stephen001
Why's it only adding verbs that I currently have to the list, and not EVERY verb that's in the game?
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
Well that's great info and all, Kaioken, but unfortunately that doesn't answer my question since I don't know how to embed a typepath into text... or embed anything for that matter.

Surely you do. It's the standard way of including variables in text output, or any text strings for that matter, without calling the text() proc.
mob/verb/Hello()
src << "Hello to you, [src.name]." //src.name is an embedded expression

You just didn't know the terminology, though you should've learned it from tutorials and the DM Guide.

Why's it only adding verbs that I currently have to the list, and not EVERY verb that's in the game?

This was already covered. [link]