[Package Index | Mudlib Index | Effect Index]

File /obj/handlers/smack_handler.c

Smack stands for Self-Made, Advanced Command Kit, and is a system which can be used in the creation of meta commands, that is, commands that can make new commands. It works by keeping track of a list of "modules", each of which contains a bit of Fancy Stuff the finished command can do. Then different modules are combined into a finished command. This handler keeps track of what the modules are and where to find them, and also keeps track of which players have access to which home-made commands.

See also:
/obj/smack/smack_object.c, /obj/smack/smack_module.c and /cmds/playtester/squint_.c

Written by Woom

Started October 2, 2003

Inherits

This class inherits the following classes /std/room/basic_room.c

Includes

This class includes the following files /include/smack.h

Method index

Public Functions

These are functions that everyone can access.

add_known_smack
void add_known_smack(mixed pl,
                     mixed name,
                     string build,
                     string id)

This adds a smack as known to someone.

Parameters:
pl - The person to add the smack to, or her name
name - The name of the smack to add, or the smack as a store class
build - What buildup to give the smack (can be anything if name is given as a class)
id - What smack list to add it to


add_save_call
int add_save_call(string file,
                  string func)

Add a save call. This is called each time the handler saves. Good for cleaning up caches.

Parameters:
file - What file to call in
func - What function to call

Returns:
1 for success, 0 for failure


char_to_method
string char_to_method(string ch)

This tells us the method of the module with character ch.

Parameters:
ch - The character to search for

Returns:
Its associated method


char_to_module
object char_to_module(string ch)

Gives a certain module object

Parameters:
ch - The character of the module to search for

Returns:
The loaded object


char_to_path
string char_to_path(string ch)

Gives the file name of a module, based on its character.

Parameters:
ch - The character to search for

Returns:
The file name of the module


do_add
int do_add(string file,
           string guild)
do_list
int do_list()
do_remove
int do_remove(string mod,
              string guild)
do_set
int do_set(string module,
           int onoff)
get_smack_object
object get_smack_object(string b)

This returns a set up smack object, based on its buildup.

Parameters:
b - The buildup to use

Returns:
The set up smack object


method_to_char
string method_to_char(string m,
                      string g)

This finds the character of the module with a specific method and guild.

Parameters:
m - The method to search for
g - In what guild to search for the module

Returns:
The found module character


module_info
string module_info()

This gives information on what modules are available, as a string.

Returns:
All sorts of information


player_name
string player_name(mixed name)

Turns a player object into its name.

Parameters:
name - The player object, or her name

Returns:
The player's name


query_all_module_methods
varargs string * query_all_module_methods(string g)

This returns all module methods, or only those of guild g if g is specified.

Parameters:
g - 0 to get all methods, a string for methods of guild g

Returns:
A list of available methods


query_guild
string * query_guild(string ch)

This tells us what guilds a specific module is registered for.

Parameters:
ch - The character of the module we want to check

Returns:
A list of guilds the module is registered for


query_module_chars
varargs string * query_module_chars(string g)

This will tell us what module chars are available, or what chars of a specific guild are available.

Parameters:
g - 0 for all chars, a string for chars of guild g

Returns:
A list of characters


query_module_methods
varargs string * query_module_methods(string g)

This returns all module methods that are currently in game, or only those of guild g if g is specified.

Parameters:
g - 0 to get all methods, a string for methods of guild g

Returns:
A list of available methods


query_pt_module_methods
varargs string * query_pt_module_methods(string g)

This returns all module methods that are currently in playtesting, or only those of guild g if g is specified.

Parameters:
g - 0 to get all methods, a string for methods of guild g

Returns:
A list of available methods


query_save_calls
mapping query_save_calls()

This gives a list of functions called each time the handler saves.

Returns:
A list of files, and what functions are called in them.


query_smack
class store query_smack(mixed player,
                        string smack,
                        string id)

This will give the store data of a particular smack in a particular player's memory, if it exists. It takes nicknames in account.

Parameters:
player - The player to check for
smack - The smack name to look for
id - The smack list to look in

Returns:
The store class corresponding to the name


query_smack_names_known
string * query_smack_names_known(mixed pl,
                                 string id)

This tells the names of the smacks someone knows.

Parameters:
pl - The person to check, or her name
id - The list to check in

Returns:
A list with the names of the known smacks


query_smack_names_known_nocase
string * query_smack_names_known_nocase(mixed pl,
                                        string id)

This tells the names of the smacks someone knows, in all lower case. It's a bit more economic than lower-casing the above function.

Parameters:
pl - The person to check, or her name
id - The list to check in

Returns:
A list with the names of the known smacks


query_smacks_known
class store * query_smacks_known(mixed name,
                                 string id)

This gives a list of smacks someone knows.

Parameters:
name - The person to check, or her name
id - What list of smacks to fetch

Returns:
A list of smacks known


register_module
int register_module(string file,
                    string g)

This registers a module with the handler.

Parameters:
file - Where to find the module
g - What guild to register it for

Returns:
1 if it succeeds, 0 if it fails


rehash
int rehash()

This re-registers all modules, effectively checking for changes. This shouldn't be called too often...

Returns:
The number of modules that were removed from the handler.


remove_known_smack
string remove_known_smack(mixed pl,
                          string name,
                          string id)

This makes someone forget a specific smack.

Parameters:
pl - The person whose mind we want to alter, or her name
name - The name of the smack to remove
id - The smack list to remove it from

Returns:
The correctly capitalised name of the smack removed, or 0 if it failed


remove_module
void remove_module(string ch,
                   string g)

This removes a specific module from a specific guild.

Parameters:
ch - The module character
g - The guild to remove it from


remove_record
void remove_record(mixed person)

This deletes someone's save file. Used by the refresh handler.

Parameters:
person - The person whose data to delete, or her name


remove_save_call
int remove_save_call(string file)

Remove a save call.

Parameters:
file - What save call to remove

Returns:
1 for success, 0 for failure


remove_specific_record
void remove_specific_record(mixed person,
                            string id)

This deletes a specific list from someone's save file.

Parameters:
person - The person whose data to delete, or her name
id - The list to remove


reset_pt
int reset_pt(string ch)

This removes a module as being in playtesting, and makes it open to the public.

Parameters:
ch - The character of the module we want to change the status of

Returns:
1 if status was changed, otherwise 0


set_pt
int set_pt(string ch)

This flags a module as being in playtesting.

Parameters:
ch - The character of the module we want to change the status of

Returns:
1 if status was changed, otherwise 0