ID:148921
 
Ok..I've been wondering a while about this and nobody I know can seem to answer it.

is it possible to create a new verb at runtime by inhereting from an old verb?

I'm going to use the reason I need it to better explain why I need it.

I have a channel system that starts with 4 channels.. IC, OOC, Helper, and Newbie.

I have an admin command that lets new channels get addded, by name, at any time at runtime.

I have a command that simply and cleanly lets players add or remove any given channel from the list of those they're listneing to...

Now.. Here's where it's not so pretty. I have a verb called channelsay that takes a channel and a text as a parameter... It talks to just that channel when you do it... For the 4 pre-generated, I created verbs IC, OOC, Helperchat, Newbiechat, as aliases for channelsay (channame) so that the player need only type the alias then the text..

What i'd like, if possible, is for admin-added channels to have that functionality. I could easily embed a verb inside an object, and toss around instances of the object, but is there any way to define a new verb by name?

For this example..say an admin in my game wants to create an Adminchat channel...easy part is to create the channel..but then, the only way to use it, is

"channelsay Adminchat text"

Not pretty, if it can be avoided!
I'd much prefer the create-channel verb to create a new communication verb called Adminchat
If I remember correctly, Dan has a MUD demo where he creates verbs at runtime. He has a few MUD-related things in his hub page, but I don't remember which one it is. You might want to take a look. It's not an advertised feature, but I think a few other people have tried it out.
In response to ACWraith (#1)
I've been looking through the libraries and tutorials by DanTom... I can't seem to find anything close..I checked nightmud and the other mud Dan did, especially, and found nothing.

Any other suggestions?
In response to Abraxas (#2)
The other mud has what you're looking for. But you have to go into byond/users/Yourname/libs/dan or something like that, it's in there. The files you look at when you open it up are in a subfolder of the folder the other ones including the verb on runtime code is.
In response to Garthor (#3)
Heh, yup. They were even harder to find than I remembered. The files are in the "mud" directory (which contains "Mud Demo"). BYOND\users\<username>\lib\dan\mud

Try looking at action.dm for a datum which modifys its verbs. The SetName() and Action() procs are probably most important. Also, you might want to look in designer.dm for the new_action() verb.


PS: Three words: Arthur Dent's house.
If I am understanding you correctly, I think what you want is completely accomplishable without having to create a completely new verb.

var/global/channels[] = list("Newbie","OOC","IC","Helper")

mob
channel="Newbie"
verb/channelsay(msg as text)
var/tmp/ch=input("What channel do you wish to speak to?","Channel",usr.channel) in channels
for(var/tmp/mob/pc/P in world)
if(ckey(P.channel)=ckey(ch))
P << "[usr] says to [ch] channel: [msg]"
verb/changechannel()
channel = input("What channel do you want to use?","Channel",usr.channel) in channels

verb/addchannel(msg as text)
if(msg in channels)
return 0
else
channels += msg

Here all the channels are defined in a global list
the admin command addchannel can add new channels to the list, the change channel allows players to pick their current channel from the list of available ones, and the channelsay allows them to type a message and select the channel to say it to.
I don't know if this is exactly what your looking for but i hope it helps.
In response to LostRealm (#5)
I asked this(and a few other) questions a long time ago, for use in a communications library which never got finished. Here's an example for ya:
<code> communication parent_type=/atom/ New(name) ..() var/verb/V=verbs[1] verbs.Cut() new V(src,name) verb commverb(T as text) ... mob/Login() ..() if(client) for(var/communication/C in communications) var/verb/V=C.verbs[1] src.verbs += V </code>
This isn't tested or anything, and you'll need to do a bit on your own, but thats the basics of it. I used a slightly more complex system(that I never got to work and scrapped it. Booh). I was told that you can also set the desc of the verb in new, but I haven't tested it(ie new V(src,name,desc)).

Hope that helps.
Alathon\\

In response to Alathon (#6)
Since you have the experience, it might be nice if you made a runtime verb creation demo, Alathon. The feature is undocumented, but has its uses. I'm not sure if it will get official support, but an unofficial demo might help someone.

Sure, someone could try searching for this post, but I think an unofficial demo looks more official than an official post... in my unofficial opinion... officially. (Don't expect a coherent thought when I can't come up with a good reason for shoving this on you instead of trying it myself. ;) )