![]() |
DI-Guy SDK Documentation
13.1
|
#include <diguyVariable.h>
Public Member Functions | |
| const char * | get_name () |
| Returns the name of the variable. More... | |
| int | set_name (const char *name) |
| This function sets the name of this object. More... | |
| const char * | get_type_name () |
| Returns the type name of the object. More... | |
| diguyScenario * | get_scenario () |
| Returns the scenario that this variable belongs to. More... | |
| diguyCharacter * | get_character () |
| Returns the character that this variable belongs to, if any. More... | |
| int | copy (diguyVariable *rhs) |
| Copies the contents of the passed variable. More... | |
| int | get_value_as_int () |
| Returns the value of the variable as an integer. More... | |
| float | get_value_as_float () |
| Returns the value of the variable as a floating point number. More... | |
| const char * | get_value_as_string () |
| Returns the value of the variable as a string. More... | |
| int | set_value_as_int (int value) |
| This function sets the value as an integer. More... | |
| int | set_value_as_float (float value) |
| This function sets the value as a floating point number. More... | |
| int | set_value_as_string (const char *value) |
| This function sets the value as a string. More... | |
| int | increment_value_as_int (int increment_amount=1) |
| This function increments the value as an int. More... | |
| int | decrement_value_as_int (int decrement_amount=1) |
| This function decrements the value as an int. More... | |
| int | equal_to_int (int value) |
| Returns: 1 if the variable as an int is equal to the passed value; 0 if not. More... | |
| int | greater_than_int (int value) |
| Returns: 1 if the variable as an int is greater than the passed value; 0 if not. More... | |
| int | less_than_int (int value) |
| Returns: 1 if the variable as an int is less than the passed value; 0 if not. More... | |
| int | equal_to_float (float value) |
| Returns: 1 if the variable as a float is equal to the passed value; 0 if not. More... | |
| int | greater_than_float (float value) |
| Returns: 1 if the variable as a float is greater than the passed value; 0 if not. More... | |
| int | less_than_float (float value) |
| Returns: 1 if the variable as a float is less than the passed value; 0 if not. More... | |
| int | equal_to_string (const char *value) |
| Returns: 1 if the variable as a string is equal to the passed value; 0 if not. More... | |
| int | greater_than_string (const char *value) |
| Returns: 1 if the variable as a string is alphabetically greater than the passed value; 0 if not. More... | |
| int | less_than_string (const char *value) |
| Returns: 1 if the variable as a string is alphabetically less than the passed value; 0 if not. More... | |
| int | get_initial_value_as_int () |
| Returns the initial value of the variable as an integer. More... | |
| float | get_initial_value_as_float () |
| Returns the initial value of the variable as a floating point number. More... | |
| const char * | get_initial_value_as_string () |
| Returns the initial value of the variable as a string. More... | |
| int | set_initial_value_as_int (int initial_value) |
| This function sets the initial value as an integer. More... | |
| int | set_initial_value_as_float (float initial_value) |
| This function sets the initial value as a floating point number. More... | |
| int | set_initial_value_as_string (const char *initial_value) |
| This function sets the initial value as a string. More... | |
Event Handler Functions | |
| int | map_event_handler_to_callback_id (int callback_id, const char *handler_name) |
| This function maps the event handler with the given name to a callback id. More... | |
| int | unmap_event_handler_from_callback_id (int callback_id, const char *handler_name, int unmap_all_matches=0) |
| This function unmaps the event handler with the given name from a callback id. More... | |
Callback Functions | |
| enum | { CALLBACK_ID_VALUE_CHANGED = 1 } |
| This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script(). More... | |
| int | add_callback (int callback_id, diguyVariableCallback *callback, void *callback_params=0, void *callback_user_data=0) |
| This function adds a user callback. More... | |
| int | remove_callback (int callback_id, diguyVariableCallback *callback) |
| This function removes a user callback. More... | |
| int | remove_callback_with_user_data (int callback_id, void *callback_user_data) |
| This function removes a user callback. More... | |
| int | add_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| This function adds a user callback script. More... | |
| int | remove_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL) |
| This function removes a user callback script previously added with add_callback_script(). More... | |
Private Functions | |
The functions and variables past this point are for internal use only. No external access to them is expected or necessary. | |
| bdiScenarioVariable * | m_scripted_object |
| A pointer to internal data. More... | |
| class | bdiScenarioVariable |
| bdiScenarioVariable * | get_scripted_object () |
| diguyVariable (bdiScenarioVariable *variable) | |
| A private constructor. More... | |
| anonymous enum |
This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script().
Usable From:
| Enumerator | |
|---|---|
| CALLBACK_ID_VALUE_CHANGED | |
|
private |
A private constructor.
| const char* diguyVariable::get_name | ( | ) |
Returns the name of the variable.
This pointer will never be NULL.
Returns:
name of the variable
Callable From:
| int diguyVariable::set_name | ( | const char * | name | ) |
This function sets the name of this object.
Returns:
0 on success, -1 on failure
Callable From:
| const char* diguyVariable::get_type_name | ( | ) |
Returns the type name of the object.
This pointer will never be NULL.
Returns:
type name of the object
Callable From:
| diguyScenario* diguyVariable::get_scenario | ( | ) |
Returns the scenario that this variable belongs to.
This pointer will never be NULL. Note that if this variable belongs to a character, a pointer to the scenario that the character belongs to will be returned.
Returns:
pointer of type diguyScenario
Callable From:
| diguyCharacter* diguyVariable::get_character | ( | ) |
Returns the character that this variable belongs to, if any.
This pointer might be NULL is this variable is not a character variable.
Returns:
pointer of type diguyCharacter; NULL if this variable is not a character variable
Callable From:
| int diguyVariable::copy | ( | diguyVariable * | rhs | ) |
Copies the contents of the passed variable.
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::get_value_as_int | ( | ) |
Returns the value of the variable as an integer.
Returns:
value of the variable
Callable From:
| float diguyVariable::get_value_as_float | ( | ) |
Returns the value of the variable as a floating point number.
Returns:
value of the variable
Callable From:
| const char* diguyVariable::get_value_as_string | ( | ) |
Returns the value of the variable as a string.
This pointer will never be NULL.
Returns:
value of the variable
Callable From:
| int diguyVariable::set_value_as_int | ( | int | value | ) |
This function sets the value as an integer.
| value | new value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::set_value_as_float | ( | float | value | ) |
This function sets the value as a floating point number.
| value | new value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::set_value_as_string | ( | const char * | value | ) |
This function sets the value as a string.
| value | new value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::increment_value_as_int | ( | int | increment_amount = 1 | ) |
This function increments the value as an int.
| increment_amount | the value by which to increment |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::decrement_value_as_int | ( | int | decrement_amount = 1 | ) |
This function decrements the value as an int.
| decrement_amount | the value by which to decrement |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::equal_to_int | ( | int | value | ) |
Returns: 1 if the variable as an int is equal to the passed value; 0 if not.
| value | the value to compare against |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::greater_than_int | ( | int | value | ) |
Returns: 1 if the variable as an int is greater than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::less_than_int | ( | int | value | ) |
Returns: 1 if the variable as an int is less than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::equal_to_float | ( | float | value | ) |
Returns: 1 if the variable as a float is equal to the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::greater_than_float | ( | float | value | ) |
Returns: 1 if the variable as a float is greater than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::less_than_float | ( | float | value | ) |
Returns: 1 if the variable as a float is less than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::equal_to_string | ( | const char * | value | ) |
Returns: 1 if the variable as a string is equal to the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::greater_than_string | ( | const char * | value | ) |
Returns: 1 if the variable as a string is alphabetically greater than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::less_than_string | ( | const char * | value | ) |
Returns: 1 if the variable as a string is alphabetically less than the passed value; 0 if not.
| value | the value to compare against |
Callable From:
| int diguyVariable::get_initial_value_as_int | ( | ) |
Returns the initial value of the variable as an integer.
Returns:
initial value of the variable
Callable From:
| float diguyVariable::get_initial_value_as_float | ( | ) |
Returns the initial value of the variable as a floating point number.
Returns:
initial value of the variable
Callable From:
| const char* diguyVariable::get_initial_value_as_string | ( | ) |
Returns the initial value of the variable as a string.
This pointer will never be NULL.
Returns:
initial value of the variable
Callable From:
| int diguyVariable::set_initial_value_as_int | ( | int | initial_value | ) |
This function sets the initial value as an integer.
The current value will be set to the initial value when the scenario containing this variable is reset.
| initial | value new initial value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::set_initial_value_as_float | ( | float | initial_value | ) |
This function sets the initial value as a floating point number.
The current value will be set to the initial value when the scenario containing this variable is reset.
| initial | value new initial value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::set_initial_value_as_string | ( | const char * | initial_value | ) |
This function sets the initial value as a string.
The current value will be set to the initial value when the scenario containing this variable is reset.
| initial | value new initial value of variable |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::add_callback | ( | int | callback_id, |
| diguyVariableCallback * | callback, | ||
| void * | callback_params = 0, |
||
| void * | callback_user_data = 0 |
||
| ) |
This function adds a user callback.
| callback | pointer to function with prototype diguyVariableCallback (typedefed above) |
| callback_id | integer id of when this callback is to be called |
| callback_params | not currently used; pass NULL |
| callback_user_data | pointer for user's own use; DI-Guy will do nothing to the contents of this pointer beyond passing it back when the callback is invoked |
callback_id should be one of the following values:
CALLBACK_ID_VALUE_CHANGED
This callback will be called whenever the value of the variable changes. There are no parameters for this callback.
Callback Return Values:
Callbacks return a value of type diguyCallbackReturn, which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE. If the callback returns DIGUY_CALLBACK_STOP, the default handler of the function will not be called; the callback is asserting that it has done everything necessary for the function call. If the callback returns DIGUY_CALLBACK_CONTINUE, the default handler for the function will be called after the callback.
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::remove_callback | ( | int | callback_id, |
| diguyVariableCallback * | callback | ||
| ) |
This function removes a user callback.
All callbacks matching the specified callback_id and callback function will be removed.
| callback_id | integer id of when this callback is to be called |
| callback | pointer to function with prototype diguyVariableCallback (typedefed above) |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::remove_callback_with_user_data | ( | int | callback_id, |
| void * | callback_user_data | ||
| ) |
This function removes a user callback.
All callbacks matching the specified callback_id and callback_user_data pointer will be removed.
| callback_id | integer id of when this callback is to be called |
| callback_user_data | pointer for user's own use |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::add_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
This function adds a user callback script.
Callback scripts can be removed with remove_callback_script().
See diguyCharacter::add_callback_script() for an example of use.
| callback_id | integer id of the callback |
| callback_script | script text of callback to be added |
| callback_script_type | the type of script contained in callback_script |
If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.
Lua specific:
When the script is called, the object for which it is being called will be in the callback_object global.
To pass NULL when calling from a lua script, use nil.
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::remove_callback_script | ( | int | callback_id, |
| const char * | callback_script, | ||
| const char * | callback_script_type = NULL |
||
| ) |
This function removes a user callback script previously added with add_callback_script().
See diguyCharacter::remove_callback_script() for an example of use.
| callback_id | integer id of the callback |
| callback_script | script text of callback previously added |
| callback_script_type | the type of script contained in callback_script |
If NULL is passed for callback_script, all callback scripts whose ids match callback_id and whose types match callback_script_type will be removed.
If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.
Lua specific:
To pass NULL when calling from a lua script, use nil.
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::map_event_handler_to_callback_id | ( | int | callback_id, |
| const char * | handler_name | ||
| ) |
This function maps the event handler with the given name to a callback id.
This mapping will be saved in the .dss file and restored when the .dss file is loaded.
Mappings can also be made via the DI-Guy Scenario UI.
The event handler is one of the following:
| callback_id | integer id of callback |
| handler_name | name of the event handler to map |
Returns:
0 on success, -1 on failure
Callable From:
| int diguyVariable::unmap_event_handler_from_callback_id | ( | int | callback_id, |
| const char * | handler_name, | ||
| int | unmap_all_matches = 0 |
||
| ) |
This function unmaps the event handler with the given name from a callback id.
| callback_id | integer id of callback |
| handler_name | name of the event handler to map |
| unmap_all_matches | pass 0 to unmap only the first match, pass 1 to unmap all matches |
Returns:
0 on success, -1 on failure
Callable From:
|
inline |
|
friend |
|
private |
A pointer to internal data.