Multiplayer Interactive-Fiction Game-Design Blog



Download 8.87 Mb.
Page145/151
Date02.02.2017
Size8.87 Mb.
#15199
1   ...   141   142   143   144   145   146   147   148   ...   151

DatabaseObjectSave


Saves a checked-out object to the database.

This saves a checked-out object to the database. An application should call this if any important information in the object changes so that in the event of an application crash, the object will be saved.

If an object is checked-in it will automatically be saved.

Once an object is saved to the database, it is normally written to disk at the application's convenience. To write to disk immediately (which can be slow), call DatabaseSave().



Parameter Name

Description

DatabaseName

Name of the database. This cannot contain any spaces, and must be made up of letters, numbers (except the fist character), and underscores.

Object

Checked-out object that is to be saved to disk.

Return value description

Returns TRUE if the object was added, FALSE if it couldn't be saved (perhaps because the object is not checked out).


DatabasePropertyAdd


Causes a property to be cached by the database.

The database automatically caches some commonly-used property values when an object is added, checked in, or saved. Cached properties can be accessed much more quickly than ones that aren't cached. Thus, (as a general rule) calls to DatabasePropertyGet() and DatabaseQuery() should only be passed properties that are cached, or they will become extremely slow.

To tell a database to cache a property, call DatabasePropertyAdd().

Make sure to call this BEFORE filling the database with any objects since calling it after objects have been added will result in calls for DatabasePropertyGet() and DatabaseQuery() for the given property to return Undefined. (This will be rectified the next time the object is saved or checked in though.)



Parameter Name

Description

DatabaseName

Name of the database. This cannot contain any spaces, and must be made up of letters, numbers (except the fist character), and underscores.

Property

Name of the property.

Return value description

Returns TRUE if the property was added, FALSE if it couldn't be added.


DatabasePropertyEnum


Lists all of the cached properties.

This returnes a list of all the properties cached by the database.



Parameter Name

Description

DatabaseName

Name of the database. This cannot contain any spaces, and must be made up of letters, numbers (except the fist character), and underscores.

Return value description

Returns a list of properties cached by the database.


DatabasePropertyGet


Gets one or more properties from one or more objects.

This gets one or more properties from one or more objects stored in the database. If the properties are cached (See DatabasePropertyAdd()) then the values will be retrieved much quicker.

NOTE: If a property is not cached, and it's a default value for the object, then DatabasePropertyGet() will return Undefined for the value. (Example: If the object is a "cLantern", the default "Weight" for a cLantern is 10, and this lantern's weight is 10, then DatabasePropertyGet() will return Undefined if the property is not cached.) This happens because when an object is saved any properties that are the same as the object's default aren't written out (to save disk space).

Parameter Name

Description

DatabaseName

Name of the database. This cannot contain any spaces, and must be made up of letters, numbers (except the fist character), and underscores.

Objects

This is either a single object, or a list containing one or more objects.

Properties

This is either a string representing a public property, or a list containing one or more strings.

A property can also be:

"containedin" - Returns the object this is contained in, or NULL if not contained.

"dataischeckedout" - To see if the object is checked out.

"datadatecreated" - To find the date that the object was created.

"datadatemodified" - To find the date that the object was last modified.

"datadateaccessed" - To find the date that the object was last checked out.

(Note: The dates are returns as the number of days since Jan 1, 2001.)



Return value description

Returns FALSE if there was an error getting the property.

If it succedes, the return is one of the following formats:

Single object and single property - This returns the value for the property.

Single object and list of properties - This returns a list containing values, corresponding to the properties. For example: If Properties had ["Name", "Age", "Height"] passed in, the return would be ["Mike", "20", "1.9m"]

List of objects and single property - The return is a list of the property value for each object. For example: If Objects had [Mike, Fred, George] passed in, with a Property of "Age", then the return would be [20, 43, 15].

List of objects and list of properties - This returns a list of lists. The top-level entries all correspond to the object. The secondard list corresponds to the properties. Thus, if Objects was [Mike, Fred, George] and Properties was ["Name", "Age", "Height"], then the return would be [["Mike", 20, "1.9m"], ["Fred", 43, "1.8m"], ["George", 15, "1.7m"]]





Download 8.87 Mb.

Share with your friends:
1   ...   141   142   143   144   145   146   147   148   ...   151




The database is protected by copyright ©ininet.org 2024
send message

    Main page