-
Notifications
You must be signed in to change notification settings - Fork 3
user
mixed *distinct_array(mixed *arr)
mixed[] arr - An array of mixed types.
mixed[] - A new array with distinct elements from the input array.
Returns a new array containing the distinct elements of the input array.
varargs mixed *remove_array_element(mixed *arr, int start, int end)
mixed[] arr - The input array.
int start - The starting index of elements to be removed.
int [end] - The ending index of elements to be removed. Defaults to start if not specified.
mixed[] - A new array with specified elements removed.
Returns a new array containing the elements of the input array from index 0 to start-1, and from end+1 to the end of the input array. If start is greater than end, the new array will contain all the elements of the input array.
mixed *reverse_array(mixed *arr)
mixed[] arr - The input array.
mixed[] - A new array with elements in reverse order.
Returns a new array with the elements of the input array in reverse order.
varargs mixed *splice(mixed *arr, int start, int delete_count, mixed *items_to_add)
mixed[] arr - The array from which elements will be removed and to which new elements may be added.
int start - The zero-based index at which to start changing the array. If negative, it will begin that many elements from the end.
int delete_count - The number of elements to remove from the array, starting from the index specified by start. If delete_count is 0, no elements are removed.
mixed[] [items_to_add] - An array of elements to add to the array at the start index. Can be omitted or passed as null if no elements are to be added.
mixed[] - A new array reflecting the desired modifications.
Modifies the content of an array by removing existing elements and/or adding new elements. Returns a new array with the modifications.
string base64_decode(string source)
string source - The Base64 encoded string to be decoded.
string - The decoded string.
Decodes a given Base64 encoded string.
string base64_encode(mixed source_str)
mixed source_str - The string or buffer to be encoded.
string - The Base64 encoded string.
Encodes a given string or buffer into Base64 format.
int data_del(string file, string key)
string file - The file to modify.
string key - The key to delete.
int - 1 if the key was found and deleted, 0 otherwise.
Deletes the key-value pair from the file.
varargs int data_inc(string file, string key, int inc)
string file - The file to modify.
string key - The key to increment the value for.
int inc - The amount to increment by.
int - The new value after incrementing.
Increments the value associated with the given key in the file by the specified amount. If the key does not exist, it is created with the increment value.
varargs mixed data_value(string file, string key, mixed def)
string file - The file to read from.
string key - The key to search for.
mixed [def] - The default value to return if the key is not found.
mixed - The value associated with the key, or the default value if the key is not found.
Retrieves the value associated with a given key from a file.
varargs void data_write(string file, string key, mixed data...)
string file - The file to write to.
string key - The key to write.
mixed data - The value(s) to write.
Writes a key-value pair to a file. If the key already exists, the value is updated.
string get_long(object ob, int extras: (: 1 :))
object ob - The object to get the long description of.
int [extras=1] - Whether to include extra long descriptions. Defaults to 1 (include extras).
string - The long description of the object, including any extra long descriptions.
Returns the long description of an object, optionally including extra long descriptions.
string get_short(object ob, int extras: (: 1 :))
object ob - The object to get the short description of.
int [extras=1] - Whether to include extra short descriptions. Defaults to 1 (include extras).
string - The short description of the object, including any extra short descriptions.
Returns the short description of an object, optionally including extra short descriptions in parentheses.
int assure_dir(string path)
string path - The path of the directory to ensure.
int - 1 if the directory exists or was created successfully, otherwise 0.
Ensures that a directory exists by creating it and its parent directories if necessary.
string query_directory(object ob)
object ob - The object to query the directory of.
string - The directory path of the object.
Returns the directory of the given object. If no object is provided, it defaults to the previous object.
varargs string cap_significant_words(string str, int title)
string str - The string to capitalize.
int [title=0] - Whether to capitalize the first word as a title.
string - The string with significant words capitalized.
Capitalizes significant words in a string, ignoring certain insignificant words. Optionally capitalizes the first word as a title.
string cap_words(string str)
string str - The string to capitalize.
string - The capitalized string.
Capitalizes the first letter of each word in a string.
string objective(mixed ob)
mixed ob - The object or gender string to convert.
string - The objective pronoun.
Returns the objective pronoun corresponding to the object's gender. Defaults to "it" for non-string or unknown gender.
string possessive(mixed ob)
mixed ob - The object or gender string to convert.
string - The possessive adjective.
Returns the possessive adjective corresponding to the object's gender. Defaults to "its" for non-string or unknown gender.
string possessive_noun(mixed ob)
mixed ob - The object or string to convert to possessive form.
string - The possessive form of the noun.
Returns the possessive form of a noun. If the noun ends with 's', it adds an apostrophe; otherwise, it adds 's.
string possessive_pronoun(mixed ob)
mixed ob - The object or gender string to convert.
string - The possessive pronoun.
Returns the possessive pronoun corresponding to the object's gender. Defaults to "its" for non-string or unknown gender.
string reflexive(mixed ob)
mixed ob - The object or gender string to convert.
string - The reflexive pronoun.
Returns the reflexive pronoun corresponding to the object's gender. Defaults to "itself" for non-string or unknown gender.
string subjective(mixed ob)
mixed ob - The object or gender string to convert.
string - The subjective pronoun.
Returns the subjective pronoun corresponding to the object's gender. Defaults to "it" for non-string or unknown gender.
int cfile_exists(string file)
string file - The base name of the file to check.
int - 1 if the compiled file exists, otherwise 0.
Checks if a compiled file (.c) exists.
int directory_exists(string dirname)
string dirname - The name of the directory to check.
int - 1 if the directory exists, otherwise 0.
Checks if a directory exists.
int file_exists(string file)
string file - The name of the file to check.
int - 1 if the file exists, otherwise 0.
Checks if a file exists.
int ofile_exists(string file)
string file - The base name of the file to check.
int - 1 if the save file exists, otherwise 0.
Checks if a save file exists.
int user_exists(string user)
string user - The username to check.
int - 1 if the user data file exists, otherwise 0.
Checks if a user data file exists.
void assure_file(string file)
string file - The path of the file to ensure.
Given a file, ensures that the directory structure leading to the file exists, creating directories as needed.
string *dir_file(string path)
string path - The path to extract the components from.
string[] - An array containing the directory and file name components.
Given a path, returns an array containing the directory and file name components.
string *explode_file(string file)
string file - The path of the file to read.
string[] - An array of lines from the file.
Reads a file and returns its content as an array of lines, excluding comment lines and empty lines.
string file_owner(string file)
string file - The path of the file to check.
string - The owner of the file, or 0 if not found.
Determines the owner of a file based on its path.
varargs void implode_file(string file, string *lines, int overwrite)
string file - The path of the file to write to.
string[] lines - The array of lines to write.
int [overwrite=0] - Whether to overwrite the existing content. Defaults to 0 (append).
Writes an array of lines to a specified file, optionally overwriting the existing content.
varargs int log_file(string file, string str, mixed arg...)
string file - The name of the log file.
string str - The log message to write.
mixed [arg] - Additional arguments to include in the log message.
int - 1 if the log message was written successfully, otherwise 0.
Writes a log message to a specified log file.
string query_file_name(object ob)
object ob - The object to query the file name of.
string - The name of the file corresponding to the object.
Returns the name of the file corresponding to a given object.
varargs string tail(string path, int line_count)
string path - The path of the file to read.
int [line_count=25] - The number of lines to read from the end of the file. Defaults to 25.
string - The last few lines of the file.
Returns the last few lines of a file, similar to the Unix
tail command.
varargs string temp_file(mixed arg)
mixed arg - The file or object to create a temporary file for.
string - The path to the temporary file.
Generates a temporary file name based on the provided argument.
mixed *assemble_call_back(mixed arg...)
mixed arg - The arguments to assemble into a callback.
mixed[] - The assembled callback.
Assembles a callback function from the provided arguments. This function is used to create a callable structure that can be invoked later. The callback can be either a method on an object or a function. The assembled callback is returned as an array. Usage:
- When you need to create a callback for an object method:
assemble_call_back(object, "method", args...) - When you need to create a callback for a function:
assemble_call_back(function, args...)The function performs the following steps:
- Checks if the provided arguments form a valid array.
- Determines the size of the arguments array.
- Checks if the first argument is an object. If so, it verifies that the second argument is a valid method name on the object.
- If the first argument is a function, it creates a callback with the function and any additional arguments.
- Returns the assembled callback as an array.
mixed call_back(mixed cb, mixed new_arg...)
mixed cb - The callback to execute.
mixed new_arg - The arguments to pass to the callback.
mixed - The result of the callback execution.
Executes a callback with the given arguments.
varargs string call_trace(int colour)
int [colour=0] - Whether to include ANSI colour codes. Defaults to 0 (no colour).
string - The formatted call stack trace.
Returns a formatted string of the current call stack trace.
int valid_function(mixed f)
mixed f - The function to check.
int - 1 if the function is valid, otherwise 0.
Checks if a given function is valid and not owned by a destructed object.
string consolidate(int x, string str)
int x - The quantity of items.
string str - The description of the item(s).
string - The consolidated string.
Returns a consolidated string for a given quantity and item description, handling pluralization and special cases.
string int_string (int num)
int num - The numerical number to convert.
string - The worded number representation of the integer.
Converts a numerical number to its worded number representation.
string ordinal (int n)
int n - The integer to convert.
string - The ordinal string representation of the integer.
Converts an integer to its ordinal string representation.
varargs string identify( mixed a, string indent )
mixed a - The variable to identify.
string [indent] - The indentation string to use for formatting.
string - The string representation of the variable.
Converts a variable to its string representation for debugging purposes, handling various data types and preventing deep recursion.
mixed json_decode(string text)
string text - The JSON string to deserialize.
mixed - The deserialized LPC value.
Deserializes a JSON string into an LPC value.
varargs string json_encode(mixed value, mixed* pointers)
mixed value - The LPC value to serialize.
mixed[] [pointers] - An optional array of pointers to handle circular references.
string - The JSON string representation of the LPC value.
Serializes an LPC value into a JSON string.
mixed element_of_weighted(mapping m)
mapping m - The weighted mapping to select from, where keys are the elements and values are their weights.
mixed - The selected element.
Selects an element from a weighted mapping based on their weights.
string pretty_map(mapping map)
mapping map - The mapping to format.
string - The formatted string representation of the mapping.
Returns a formatted string representation of a mapping, removing any size annotations.
varargs void tell(object ob, string str, int msg_type)
object ob - The object to send the message to.
string str - The message string to send.
int [msg_type] - The message type.
Sends a direct message to the specified object without considering containment hierarchy.
varargs void tell_all(object ob, string str, int msg_type, mixed exclude)
object ob - The object to send the message from.
string str - The message string to send.
int [msg_type] - The message type, combined with ALL_MSG.
mixed [exclude] - The objects to exclude from receiving the message.
Sends a message to all objects in the same environment, regardless of their position in the containment hierarchy.
varargs void tell_direct(object ob, string str, int msg_type)
object ob - The object to send the message to.
string str - The message string to send.
int [msg_type] - The message type, combined with DIRECT_MSG.
Sends a direct message to the specified object without considering containment hierarchy.
varargs void tell_down(object ob, string str, int msg_type, mixed exclude)
object ob - The object to send the message from.
string str - The message string to send.
int [msg_type] - The message type, combined with DOWN_MSG.
mixed [exclude] - The objects to exclude from receiving the message.
Sends a message downward through the containment hierarchy, such as from a container to all objects it contains.
varargs void tell_up(object ob, string str, int msg_type, mixed exclude)
object ob - The object to send the message from.
string str - The message string to send.
int [msg_type] - The message type, combined with UP_MSG.
mixed [exclude] - The objects to exclude from receiving the message.
Sends a message upward through the containment hierarchy, such as from an object to its container, and further up to the room or environment.
float percent(float a, float b)
float a - The part value.
float b - The whole value.
float - The percentage of `a` out of `b`.
Calculates the percentage of a out of b.
float percent_of(float a, float b)
float a - The part value.
float b - The whole value.
float - The percentage of `a` in `b`.
Calculates what percentage a is of b.
float range(float min, float max, float val)
float min - The minimum value.
float max - The maximum value.
float val - The value to check.
float - The value, constrained within the range of `min` to `max`.
Ensures a value is within a specified range.
varargs float remainder(mixed a, mixed b)
mixed a - The dividend.
mixed b - The divisor.
float - The remainder of `a` divided by `b`.
Calculates the remainder of a divided by b.
int sum(mixed *arr)
mixed[] arr - The array of numbers to sum.
int - The sum of all elements in the array.
Calculates the sum of all elements in an array.
varargs object find_ob(mixed ob, mixed cont, function f)
mixed ob - The object or name of the object to find.
mixed [cont] - The container or environment to search within. Defaults to the previous object.
function [f] - An optional function to further filter the search.
object - The found object, or 0 if not found.
Searches for an object within a container or environment using the specified criteria.
varargs object get_object( string str, object player )
string str - The name of the object to locate.
object [player] - The player object to use as a reference for searching.
object - The located object, or 0 if not found.
Attempts to locate an object by the given name and returns the object pointer if found.
varargs mixed get_objects( string str, object player, int no_arr )
string str - The search string specifying the objects to locate.
object [player] - The player object to use as a reference for searching.
int [no_arr] - If specified, only a single object or 0 will be returned, otherwise an array of objects may be returned.
mixed - The located object(s), or 0 if not found.
Locates objects based on the specified search string, which can include various search criteria and options.
int getoid(object ob)
object ob - The object to get the ID of.
int - The unique object ID.
Retrieves the unique object ID of the given object.
object top_environment(object ob)
object ob - The object to get the top-level environment of.
object - The top-level environment of the object.
Retrieves the top-level environment of the specified object, traversing up through nested environments.
string resolve_path(string Current, string Next)
string Current - The current path.
string Next - The next path to resolve.
string - The resolved absolute path.
Resolves a given path relative to the current path, handling special cases such as user directories and relative paths.
string assure_object_save_dir(object ob)
object ob - The object to ensure the save directory for.
string - The save directory path for the object, or 0 if creation failed.
Ensures the save directory for the specified object exists, creating it if necessary.
string object_save_directory(object ob)
object ob - The object to get the save directory for.
string - The save directory path for the object.
Returns the save directory path for the specified object.
string object_save_file(object ob)
object ob - The object to get the save file for.
string - The save file path for the object.
Returns the save file path for the specified object.
int adminp(mixed user)
mixed user - The user to check, either as a username string or an object. Defaults to the previous object.
int - 1 if the user has admin privileges, otherwise 0.
Checks if a user has admin privileges.
varargs int devp(mixed user)
mixed user - The user to check, either as a username string or an object. Defaults to the previous object.
int - 1 if the user has developer privileges, otherwise 0.
Checks if a user has developer privileges.
int is_member(string user, string group)
string user - The username to check.
string group - The group to check membership in.
int - 1 if the user is a member of the group, otherwise 0.
Checks if a user is a member of a specified group.
int wizardp(mixed user) { return devp(user); }
mixed user - The user to check, either as a username string or an object.
int - 1 if the user has developer privileges, otherwise 0.
Checks if a user has developer privileges (alias for devp).
string dump_socket_status()
string - The formatted socket status information.
Returns a formatted string displaying the status of all sockets.
string add_commas(mixed number)
mixed number - The number to add commas to.
string - The number with commas added as a string.
Returns a string with commas added to the number.
string append(string source, string to_append)
string source - The string to append to.
string to_append - The string to append.
string - The original string with the appended string if it was not already present.
Appends a string to another string if it is not already there. If the string is already present, the original string is returned.
varargs string chop(string str, string sub, int dir)
string str - The string to chop from.
string sub - The substring to chop.
int [dir=-1] - The direction to chop: 1 for left, -1 for right.
string - The string with the substring chopped off if it was present.
Chops a substring off the end or beginning of another string if it is present. If the substring is not present, the original string is returned.
varargs string extract(string str, int from, int to)
string str - The string to extract from.
int from - The starting position to extract from.
int [to] - The ending position to extract to.
string - The extracted substring.
Extracts a substring from a string.
varargs mixed from_string(string str, int flag)
string str - The string to convert.
int [flag=0] - If set, returns an array with the value and the remaining string.
mixed - The LPC value represented by the string.
Converts a string representation of an LPC value to the corresponding LPC value.
string no_ansi(string str)
string str - The string to remove ANSI codes from.
string - The string without ANSI codes.
Returns a string with all ANSI colour codes removed.
string prepend(string source, string to_prepend)
string source - The string to prepend to.
string to_prepend - The string to prepend.
string - The original string with the prepended string if it was not already present.
Prepends a string to another string if it is not already there. If the string is already present, the original string is returned.
string reverse_string(string str)
string str - The string to reverse.
string - The reversed string.
Reverses a string.
varargs int reverse_strsrch(string str, string sub, int start)
string str - The string to search in.
string sub - The substring to search for.
int [start=-1] - The starting position to search from.
int - The position of the substring in the string, or -1 if not found.
Searches for a substring in a string starting from a given position and moving backwards.
varargs string simple_list(string *arr, string conjunction)
string[] arr - The array to make a list from.
string [conjunction="and"] - The word to join the last two elements of the list.
string - The simple list string.
Returns a string that is a simple list of the elements of an array, joined by a conjunction.
string stringify(mixed val)
mixed val - The value to convert.
string - The string representation of the value.
Converts an LPC value to its string representation.
varargs string substr(string str, string sub, int reverse)
string str - The string to extract from.
string sub - The substring to extract to.
int [reverse=0] - If set, the substring will start at the last occurrence.
string - The extracted substring.
Returns a substring of a string, starting from 0 and ending at the first occurrence of another string within it. If the reverse flag is set, the substring will start at the last occurrence of the substring within the string.
int _error(mixed str, mixed args...)
string str - The error message.
mixed [args] - Optional arguments to format the message.
int - Always returns 1, unless there is no previous object.
Provides an error message, optionally formatted with arguments.
int _ok(mixed str, mixed args...)
string str - The informational message.
mixed [args] - Optional arguments to format the message.
int - Always returns 1, unless there is no previous object.
Provides an informational message, optionally formatted with arguments.
int _warn(mixed str, mixed args...)
string str - The warning message.
mixed [args] - Optional arguments to format the message.
int - Always returns 1, unless there is no previous object.
Provides a warning message, optionally formatted with arguments.
string admin_email()
string - The admin email address.
Returns the admin email address for the MUD.
string arch()
string - The system architecture.
Returns the architecture of the system the MUD is running on.
string baselib_name()
string - The base library name.
Returns the name of the base library.
string baselib_version()
string - The base library version.
Returns the version of the base library.
string driver_version()
string - The driver version.
Returns the version of the MUD driver.
string lib_name()
string - The library name.
Returns the name of the library being used by the MUD.
string lib_version()
string - The library version.
Returns the version of the library being used by the MUD.
string log_dir()
string - The log directory.
Returns the directory where log files are stored.
mixed mud_config(string str)
string str - The configuration key to retrieve.
mixed - The configuration value.
Retrieves a specific configuration value from the MUD config.
string mud_name()
string - The name of the MUD.
Returns the name of the MUD.
string open_status()
string - The open status of the MUD.
Returns the open status of the MUD.
int port()
int - The port number.
Returns the port number the MUD is running on.
string tmp_dir()
string - The temporary directory.
Returns the directory where temporary files are stored.
varargs string ldate(int x, int brief)
int [x=time()] - The timestamp to format. Defaults to the current time.
int [brief=0] - If set to 1, returns a brief date format (MM-DD). Otherwise, returns a full date format (YYYY-MM-DD).
string - The formatted date string.
Returns a formatted date string.
varargs string ltime(int x, int brief)
int [x=time()] - The timestamp to format. Defaults to the current time.
int [brief=0] - If set to 1, returns a brief time format (HH:MM). Otherwise, returns a full time format (HH:MM:SS).
string - The formatted time string.
Returns a formatted time string.
varargs float time_frac(int nanoseconds)
int nanoseconds - The time value in nanoseconds. Defaults to the current time in nanoseconds if not provided.
float - The time value converted to a fractional value in seconds.
Converts a time value from nanoseconds to a fractional value in seconds. This function takes a time value in nanoseconds and converts it to a fractional value representing seconds by dividing the input by 1,000,000,000.
varargs int time_ms(int nanoseconds)
int nanoseconds - The time value in nanoseconds. Defaults to the current time in nanoseconds if not provided.
int - The time value converted to milliseconds.
Converts a time value from nanoseconds to milliseconds. This function takes a time value in nanoseconds and converts it to milliseconds by dividing the input by 1,000,000.
string user_core_data_directory(string name)
string name - The user's name.
string - The directory path for the user's core data directory, or 0 if the input is invalid.
Returns the directory path for the user's core data directory based on their name.
string user_data_directory(string name)
string name - The user's name.
string - The directory path for the user's data directory, or 0 if the input is invalid.
Returns the directory path for the user's data directory based on their name.
string user_data_file(string name)
string name - The user's name.
string - The file path for the user's data file, or 0 if the input is invalid.
Returns the file path for the user's data file.
string user_mob_data(string name)
string name - The user's name.
string - The file path for the user's mob data file, or 0 if the input is invalid.
Returns the file path for the user's mob data file.
string user_path(string name)
string name - The user's name.
string - The home directory path for the user.
Returns the home directory path for the user.