ID:153441
 
Is it possible to create a verb with arguments that perform no function, but are required by the verb anyway?

For example:

"look at <object>"

I know the command to look at an object is simple to design, but what if I want the syntax to be "look at"?

Or:

"Give to "

I would like to do this without using underscore verbs like "look_at" since those require the use of hyphenation. It's really a matter of syntax preference, that's all. You know, like text adventure game style.

Thank you,

=$= Big J Money =$=</object>
To do what you want, you'll need to parse the input. Parsing means to take a text string, break it up into pieces, and do things based on what pieces are in what order.

I'd suggest looking at AbyssDragon.Parser for a well rounded and fully functioning parser library. It requires a BYONDscape subscription to DL, but it's well worth it for the other utilities you'll gain access to.
This can be done by making the argument in list("preposition"), for example:

obj/verb/give(prep in list ("to"),mob/m as mob in oview(1))


give sword to Lord-Suchandsuch

No hyphens, no underscores, no parsing, and the user hitting a space bar will automatically fill in the preposition.

You can also put two or more items in the list, for cases where the preposition makes a difference.

look(prep in list("in","at"),atom/a as mob|obj in view())
if (prep == "in")
//show me the contents
else
//show me the object's description.

You can end up with some extremely tortured argument lists in this fashion, by making later arguments found in proc(), where the proc() returns a different list of targets based on the preposition chosen.
In response to Hedgemistress
Thank you! Could I ask where you got this information from? I can't find any information about "prep in list()" anywhere. Or is that something that I am supposed to create, a list of prepositions?

Once again thanks. I tried to log into BYONDscape and access that document the other person listed, but it doesn't seem to do anything. Yes, I bought a subscription.

=$=
In response to BigJMoney
prep is simply a variable name you choose. It could as easily be t1 in list. The variable list is also just that, a variable. However, list needs to be a /list variable.

So, you can have a pre-defined list of prepositions such as:

var/list/look_preps = list("in","at","on","under","over")


Now, when using Hedge's example, the code for 'look' looks like this:
verb/look(prep in look_preps,atom/A)
switch(prep)
if("in")
//show contents of A
if("at")
//show the description of A
//etc,etc...


You can now look (in,at,on,under,over,to, and from) any object in the game.

The 'in' operator is used to tell DM that the variable should be found in the following list.
In response to BigJMoney
prep is what I call the argument/variable, because that's what it usually is... a preposition. It could be called arg, v, or Henrietta, without any actual effect.

Putting "in [whatever]" after an argument means it will accept any of the items in [whatever] as an input for that argument. "in oview(1)", for instance, means get a list of everything in oview(1) and use those for inputs.

If you literally put, "in list("whatever")", it creates a list that contains one item, "whatever", and that's all it accepts. You don't even need to define a separate variable to hold the list, especially if the preposition is truly fluff... it does nothing.

The same technique works for non-fluff arguments. For example:

sex(sex in list("female","male"))