Home

[Package Index | Mudlib Index | Effect Index]

File /std/delivery.c

Inheritable Delivery System

This object provides a way of storing and sending objects to players while they are not online. It is roughly based on the concepts found in Post Offices that support parcel depositing, and also Bernita's Flower Shop. (Which delivers flowers to people when they log on.)

This object is easy to use, and can be combined with most other objects on the Disc. (ie, /obj/monster and /std/room). See delivery_room.c for a pre-made room which handles the delivery of objects.

Note that this system uses static login calls. These must be configured first and turned on manually in order for the delivery system to work.

In order to use this inheritable the following things must be done:

  • The object that uses it created, and this object inherited.
  • The save file set using set_save_file().
  • Any extra settings such as delivery message and delay configured.
  • setup_delivery() called on the object to finalize setup.

Written by Taffyd

Inherits

This class inherits the following classes /global/auto_load.c

Includes

This class includes the following files /include/move_failures.h, /include/player_handler.h, /include/login.h and /include/login_handler.h

Class Index

Method index

  • add_delivery(mixed, mixed, object, int)
    This method adds a new item to the delivery mapping for the specified recipient.
  • check_delivery(mixed, string)
    This method is called by the login handler every time someone logs on to the Disc.
  • clean_delivery_mapping()
  • clear_delivery()
    This method is used to remove all deliveries currently stored within the delivery system.
  • deliver_item(string, object, string)
    This method is called when an item is being delivered to a player.
  • load_file()
    This method loads retrieves data from the save file, and handles the autoloading of the items.
  • query_burdened_mess()
    This returns the current delivery message that is displayed to the recipient of a delivery, if it is too heavy go to in their inventory.
  • query_delivery(string)
    This method returns the delivery details for a particular person, or the entire delivery mapping of one doesn't exist.
  • query_delivery_delay()
    This method returns how long after the login an item is delivered to the recipient.
  • query_delivery_mess()
    This returns the current delivery message that is displayed to the recipient of a delivery.
  • query_save_file()
    This method is used to query the save file in which the delivery data is stored.
  • save_file()
    This method saves all of the delivery data into the save file, handling saving of the auto loading as well.
  • set_burdened_mess(string)
    This method sets the message that is displayed when an item is too heavy to be placed in the victim's inventory.
  • set_delivery(mapping)
    This is used to set all of the delivery mapping manually.
  • set_delivery_delay(int)
    This method is used to specify how many seconds to wait after login until the item is delivered.
  • set_delivery_mess(string)
    This method sets the delivery message that is displayed to the player when they log on.
  • set_save_file(string)
    This method sets the save file to a file name so that auto loading and delivery details can be successfully saved.
  • setup_delivery()
    This method adds the object into the login handler's static login calls list.
  • valid_delivery(class delivery_item, string)
    This method is called by the check_delivery() function when it validates someone's deliveries.

Public Functions

These are functions that everyone can access.

.

    add_delivery
    void add_delivery(mixed who,
                      mixed sender,
                      object item,
                      int delay)
    

    This method adds a new item to the delivery mapping for the specified recipient. This should always be used instead of set_delivery(), as it makes sure that all the data structures have been configured correctly.
    • Parameters:
      who - the person to receive the item.
      sender - the person sending the file.
      item - the item to be sent
      delay - how many seconds to wait before delivering item on the next login.
    • See also:
      check_delivery()
    • Example:
           add_delivery(this_player(), "taffyd", frog, 360);
    check_delivery
    void check_delivery(mixed person,
                        string type)
    

    This method is called by the login handler every time someone logs on to the Disc. It handles the delivery of items and all sorts of nifty things.


    • Parameters:
      person - the name of the person logging on
      type - the type of login event
        clean_delivery_mapping
        void clean_delivery_mapping()
        
          clear_delivery
          void clear_delivery()
          

          This method is used to remove all deliveries currently stored within the delivery system.

          Be very careful when using this function! It will save the cleared delivery mapping after it has been called.

            load_file
            void load_file()
            

            This method loads retrieves data from the save file, and handles the autoloading of the items.
              query_burdened_mess
              string query_burdened_mess()
              

              This returns the current delivery message that is displayed to the recipient of a delivery, if it is too heavy go to in their inventory.


              • Returns:
                the delivery message
              • See also:
                set_burdened_mess() and query_delivery_mess()
                  query_delivery
                  varargs mixed query_delivery(string person)
                  

                  This method returns the delivery details for a particular person, or the entire delivery mapping of one doesn't exist.


                  • Parameters:
                    person - the person's delivery details to query.
                      query_delivery_delay
                      int query_delivery_delay()
                      

                      This method returns how long after the login an item is delivered to the recipient.
                      • Returns:
                        the number of seconds unt
                          query_delivery_mess
                          string query_delivery_mess()
                          

                          This returns the current delivery message that is displayed to the recipient of a delivery.
                          • Returns:
                            the delivery message
                          • See also:
                            set_delivery_mess()
                              query_save_file
                              string query_save_file()
                              

                              This method is used to query the save file in which the delivery data is stored.
                              • Returns:
                                the path of the save file used to store delivery details.
                                  save_file
                                  void save_file()
                                  

                                  This method saves all of the delivery data into the save file, handling saving of the auto loading as well.
                                    setup_delivery
                                    void setup_delivery()
                                    

                                    This method adds the object into the login handler's static login calls list. It only ever needs to be called _once_, and doesn't need to be called every time the object loads.

                                    Once this is done, the object will automatically be loaded whenever someone logs on.

                                    This must be called in order for the delivery system to work at all.

                                    Protected Functions

                                    These are functions that only objects inheriting the class can access.

                                      deliver_item
                                      void deliver_item(string who,
                                                        object ob,
                                                        string sent_by)
                                      

                                      This method is called when an item is being delivered to a player. The delivery message or the burdened mess is used depending on how the item is delivered, and then it is removed from the delivery mapping.

                                      Note that this routine uses add_message() to display movement messages to the player, instead of tell_object() or a traditional move message. This is so that the messages can be 'clumped' together properly, otherwise it just doesn't work.


                                      • Parameters:
                                        who - the person to deliver to
                                        ob - the object to deliver
                                        sent_by - the person that send the parcel
                                        position - its location in the recepient's delivery mapping.
                                          set_burdened_mess
                                          void set_burdened_mess(string s)
                                          

                                          This method sets the message that is displayed when an item is too heavy to be placed in the victim's inventory. This uses the same format as the normal delivery message.


                                          • Parameters:
                                            s - message to display
                                          • See also:
                                            set_delivery_mess() and query_burdened_mess()
                                              set_delivery
                                              void set_delivery(mapping x)
                                              

                                              This is used to set all of the delivery mapping manually. You should not use this method.
                                              • Parameters:
                                                x - the new delivery mapping.
                                              • See also:
                                                add_delivery()
                                                  set_delivery_delay
                                                  void set_delivery_delay(int new_time)
                                                  

                                                  This method is used to specify how many seconds to wait after login until the item is delivered. Note that if this is too long, then the receipient may log out before you can give them the item. If the receipient logs out, then the item will be destroyed.

                                                  This is set to 5 by default.


                                                  • Parameters:
                                                    new_time - the time in seconds after log in to deliver the message.
                                                      set_delivery_mess
                                                      void set_delivery_mess(string s)
                                                      

                                                      This method sets the delivery message that is displayed to the player when they log on. $S is substituted in the string with the name of the player who sent the message, $N is replaced with the a_short() of the item being sent.
                                                      • Parameters:
                                                        s - the new delivery string
                                                      • See also:
                                                        query_delivery_mess() and /std/basic/desc->a_short()
                                                      • Example:
                                                            set_delivery_mess("A small frog hops up to you, and thrusts $N "
                                                                "into your arms.  He holds up a large sign that reads: \""
                                                                "From $S\", and then runs away.\n");
                                                        
                                                        // Recipient sees:
                                                        A small frog hops up to you, and thrusts a large blue box into your
                                                        arms.  He holds up a large sign that reads: \"From Taffyd!\", and then
                                                        runs away.
                                                        
                                                          set_save_file
                                                          void set_save_file(string str)
                                                          

                                                          This method sets the save file to a file name so that auto loading and delivery details can be successfully saved.
                                                          • Parameters:
                                                            str - the new path.
                                                              valid_delivery
                                                              int valid_delivery(class delivery_item delivery,
                                                                                 string person)
                                                              

                                                              This method is called by the check_delivery() function when it validates someone's deliveries. It is used to determine whether or not it's time for a delivery to be delivered, and whether or not to remove it.


                                                              • Parameters:
                                                                delivery - the delivery item to be tested
                                                                person - the person to deliver the item to.

                                                              • Returns:
                                                                1 if the delivery is not ready, 0 if it is. (yes, this is kind of backwards.)

                                                                Classes

                                                                These are nice data types for dealing with... Data!

                                                                • delivery_item
                                                                  class delivery_item {
                                                                                        object delivery_ob;
                                                                                        string sent_by;
                                                                                        int submit_time;
                                                                                        int delay_time;
                                                                  }
                                                                  
                                                                  
Valid HTML 4.01 Transitional
Valid CSS!
Read More