Feature object

33 views
Skip to first unread message

Antonio Cascales

unread,
Oct 18, 2020, 8:35:16 AM10/18/20
to moo-...@googlegroups.com
Hi everyone:


   Could someone explain how the objects that inherit from $ feature
work and how to make the verbs defined in it accessible to those players
to whom this object is added?


  I have searched the internet for examples but have not found any, and
with the help I am not able to get it.


   Thank you very much and greetings.

lisdude

unread,
Oct 18, 2020, 3:14:02 PM10/18/20
to Antonio Cascales, MOO Talk
Sure, I can give it a whirl.

To make feature verbs accessible, they need to be executable: @chmod $my_feature:some_verb +x

As to how features work...

Without getting into the hairier details, MOO's last ditch command parsing attempt occurs in the 'huh()' verb on the player's location. Typically this just defers to '$command_utils:do_huh()', which then calls a cascading series of huh verbs on the player, their location, etc. What we're looking for is in 'player:my_huh()', which happens to be the first attempt made by '$command_utils:do_huh()'.

Actually from here it's not very interesting. You can @list $player:my_huh to see exactly how feature verbs are found, but in a nutshell: It goes through your .features property looking for valid objects. It then asks the object if it has a verb by calling 'object:has_feature_verb()', or if something goes wrong, it falls back to calling '$object_utils:has_callable_verb()'. When it finds the verb, it calls it.

It's also convention to move your feature into $feature_warehouse but this doesn't seem to be a requirement.


Quick, but sure to be exciting, example:

>@create $feature called Pointless Matching Feature                                                                                                                                  
You now have Pointless Matching Feature with object number #112 and parent Generic Feature Object (#74).                                                                             
>@verb #112:@match any any any rxd                                                                                                                                                   
Verb added (1).                                                                                                                                                                      
>@prog #112:@match                                                                                                                                                                   
Now programming Pointless Matching Feature:@match(1).                                                                                                                                
[Type lines of input; `?' for help; end with `.', `@abort' or `@edit'.]
>match = player:my_match_object(argstr);                                                                                                                                             
>if ($command_utils:object_match_failed(match, argstr))                                                                                                                              
>return;                                                                                                                                                                             
>endif                                                                                                                                                                               
>player:tell("'", argstr, "' matches to ", $string_utils:nn(match), ".");                                                                                                            
>.                                                                                                                                                                                   
0 errors.                                                                                                                                                                            
Verb programmed.  
>@add-feature #112                                                                                                                                                                   
#112 (Pointless Matching Feature) added as a feature.
>@match me                                                                                                                                                                           
'me' matches to Wizard (#2).

--
You received this message because you are subscribed to the Google Groups "MOO Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to MOO-talk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/MOO-talk/a2a89752-df7d-8d74-7b3c-52a148961d06%40gmail.com.

Antonio Cascales

unread,
Oct 20, 2020, 11:56:37 AM10/20/20
to moo-...@googlegroups.com

Hello again:


   Thanks Lisdude for the explanation. You're very kind.


   greetings.

Reply all
Reply to author
Forward
0 new messages