Database Functions

Summary
Locate a replica with a matching mother and room.
Locate all the replicas with a matching mother and room.
Locate a replica using an object name.
Search for a replica in a given room, with a given object.
Search for a replica in a given room, with a given object.
Find an object with the given name.
Find a persona with the given name.
Find an online player with the given name.
Find a room with the given name.
Locate the next active player.
Decrement a given replica data, returning any record that reaches 0.
Decrement a given replica variable, returning any record that reaches 0.
Decrement a given replica byte, returning any record that reaches 0.
Search for for a replica with the given flag enabled.

find_replica

Locate a replica with a matching mother and room.  This is used to iterate through the replica database, finding each replica that has either the given mother, the given room, or both.  This is much like <search_replica_room>() except that here you specify an exact mother to match, not a mother name.  If mother is 0, then match any mother.  If room is 0, then match any room.  The search will start on the replica immediately after the specified start replica.  (Note, this does not imply ordered progression.  Due to indexing, replica are likely going to be returned out of order.)  A start value of 0 will always return the first match found (and should be used to begin an iteration).

Params

motherthe exact mother to match (or 0 for any)
startbegin searching immediately after this record
roomthe exact room to match (or 0 for any)

Returns

A replica record number of the next replica to match in this iteration search, or 0 if no more have been found.

find_replica@

Locate all the replicas with a matching mother and room.  This is used to iterate through the replica database, finding each replica that has either the given mother, the given room, or both.  This is much like <search_replica_room>() except that here you specify an exact mother to match, not a mother name.  If mother is 0, then match any mother.  If room is 0, then match any room.

Unlike find_replica, all matches are found at once.

Params

motherthe exact mother to match (or 0 for any)
roomthe exact room to match (or 0 for any)

Returns

A list of all matching replicas.

search_replica

Locate a replica using an object name.  This is for compatibility only.  It is exactly equivalent to <search_replica_room>(0, str$, start) which provides the same functionality but with more search options (namely the room).

Params

object$object name to search for (e.g.  “sword”)
startbegin searching immediately after this record

Returns

The next replica in the search or 0 if no more are found.

search_replica_room

Search for a replica in a given room, with a given object.  This is the meat of powerful replica searching.  It takes an object name (e.g.  “sword”) and searches for any replica that has an object with that name.  So, for instance, if you have two sword objects, one with names [“longsword”,”sword”] and the other with [“shortsword”,”sword”], it will match both those objects in the search for “sword”.  It will also optionally limit the search to only a given room if the specified room is non-zero.  This routine is highly indexed and optimized for performance.

Params

roomroom to match (or 0 for any)
object$object name to search for (e.g.  “sword”)
startbegin searching immediately after this record

Returns

The next replica in the search or 0 if no more are found.

search_replica_room@

Search for a replica in a given room, with a given object.  This is the meat of powerful replica searching.  It takes an object name (e.g.  “sword”) and searches for any replica that has an object with that name.  So, for instance, if you have two sword objects, one with names [“longsword”,”sword”] and the other with [“shortsword”,”sword”], it will match both those objects in the search for “sword”.  It will also optionally limit the search to only a given room if the specified room is non-zero.  This routine is highly indexed and optimized for performance.

Params

roomroom to match (or 0 for any)
object$object name to search for (e.g.  “sword”)

Returns

All matching replicas, or an empty vector if none are found.

search_object

Find an object with the given name.  This will search through the object database, returning the next object that has the given name in its list of names.

Params

object$object name to search for (e.g.”sword”)
startbegin searching immediately after this record

Returns

The next object in the search or 0 if no more are found.

search_persona

Find a persona with the given name.  This will search through the persona database, returning the persona with the given name.  Note that the lack of ‘start’ parameter implies that names should be unique (this is not actually enforced however).  Contrast this with <search_player>().

Params

name$persona name to search for (e.g.”Frodo”)

Returns

The matching persona or 0 if no persona record matches.

search_player

Find an online player with the given name.  Search through the persona database finding a persona record that matches the name (or partial name) given and is currently online (has a node pointing to it).

This routine does partial name matching.  This means that for every online player, if the search name is “fr” then it will return the nodes on which “Frodo”, “Frumpy”, and “Frobozz” are playing (assuming they are online of course).  Contrast with <search_persona>().

Params

name$persona name (or partial name) to match (e.g.  “frodo” or “fr”)
startbegin searching immediately after this record

Returns

The next online player to match, or 0 if no more are found.

search_room

Find a room with the given name.  This will lookup a room number given its unique name (uniqueness is enforced here, unlike for personas).

Params

name$name of the room

Returns

The room record number or 0 if not found.

next_player

Locate the next active player.  This will check all the online players and return the next one who has as an active node (node[].status of either 1 or 2) and a valid persona (between 1 and persona.maxrecord and who’s name is not empty).

Params

startbegin searching immediately after this record

Returns

The next player, or 0 if no more are found.

decrement_replica_data

Decrement a given replica data, returning any record that reaches 0.  This is a strange routine it will iterate over the replica database, decrementing the specified data field by 1.  If, after decrementing, it causes that value to be 0, the loop ends, and the record is returned.  It can be continued by calling again, with the last value returned given as the start record.  This was used to implement timers in older games.  Note: this will not wrap around (values of 0 are not decremented below 0).

Params

indexindex into data field to decrement (e.g.  5 for data[5])
startbegin immediately after this record

Returns

The next replica to reach 0, or 0 if none are found to do so.

decrement_replica_var

Decrement a given replica variable, returning any record that reaches 0.  This is just like <decrement_replica_data>() but operates on the replica[].variable field instead.

Params

indexindex into data field to decrement (e.g.  5 for variable[5])
startbegin immediately after this record

Returns

The next replica to reach 0, or 0 if none are found to do so.

decrement_replica_var

Decrement a given replica byte, returning any record that reaches 0.  This is just like <decrement_replica_data>() but operates on the replica[].byte field instead.

Params

indexindex into data field to decrement (e.g.  5 for byte[5])
startbegin immediately after this record

Returns

The next replica to reach 0, or 0 if none are found to do so.

find_repflag

Search for for a replica with the given flag enabled.  This routine is for compatibility and find_repflag(f,0) can be rewritten as replica.flag[f].search(1, 0);

Params

flagwhich flag to search (e.g.  5 for flag[5])
startbegin immediately after this record

Returns

The next matching replica, or 0 if none are found.