Event

来自MudWiki

名称

   event() - 呼叫指定对象中的 event_* 方法

语法

   void event(object ob, string event_name, ...);
   void event(object *ob, string event_name, ...);

描述

   FluffOS新增efun,这个外部函数调用指定对象中的 `event_` + event_name(...) 方法。如果是对象数组,每个对象都会调用。如果对象是单个对象,对象和对象中的所有对象都会调用。

示例

   // In a room

   // will call event_heal_up on the room, and then every object in the room
   event( this_object(), "heal_up", 50, 50 ) ; 

   // will call event_heal_up in the results of users() efun
   event( users(), "heal_up", 25, 25 ) ;

   // In a player object

   // To take advantage of this event, write an event_heal_up in the player
   // object to receive the call
   void event_heal_up(object source, int health, int mana)
   {
       message("heal", sprintf("You were healed %d health and %d mana by %O.\n", health, mana, source), this_object()) ;
   }

翻译

   雪风(i@mud.ren)