|
DI-Guy Lua AI SDK
|
The base class of all the diguyCharacter's lua representation. More...
Public Member Functions | |
UI Accessors | |
| get_ui_signals () | |
| This function returns a comma separated list of signals that the agent is currently willing to accept. More... | |
| get_ui_state_label () | |
| This function returns a string that the DI-Guy Scenario UI will add onto the end of the state name label. More... | |
FrameWork Functions | |
| one_time_init () | |
| This function is called when a mind is first created, currently no ops. More... | |
| init (arg0, arg1, arg2) | |
| This function is called at t=0 or when a mind is created, currently no ops. More... | |
| reset () | |
| This function resets the luaCharacter representation, called by c++ on scenario reset. More... | |
| destroy () | |
| This function is called by C++ when the character is destroyed. Overload it to trigger any world cleanup on destruction. More... | |
| die_now () | |
| This function is called when the character is killed. Overload it to trigger any final events or agent clean up on death. More... | |
| draw () | |
| This function is called by diguy scenario to draw a lua object Overload it to create your own Drawing behavior. More... | |
| entry_point () | |
| This function is called by the state manager as the entry point into the lua state machine. Overload it to create your own HFSM. More... | |
Miscellaneous and Convenience Functions | |
| send_message_to_character (to, from, msg_type, message, params) | |
| Send a message from a character to a character, will automatically send message over network. More... | |
Coroutine Management Functions | |
| state_manager (sender, message_type, message, params) | |
| This is the main entry point from C++ into the lua framework. More... | |
Sleep Management Functions | |
| sleep (duration) | |
| sleep_until (wake_time) | |
| sleep_ignore_messages (duration) | |
| This is a simple sleep function, it will put the character to sleep for the duration specified. Messages will not be processed. More... | |
| sleep_process_messages (duration, message_handler) | |
| This is a sleep function that can take a message_handler function. More... | |
| wait_for_message (message_to_wait_for, message_handler, bg_check_func, bg_freq) | |
| This is a sleep function that will wait a long time and only wake up when a specific message is recieved. More... | |
| wait_for_multichoice (...) | |
| This is a sleep function that will wait a long time and only wake up when one of a few specific messages are recieved. More... | |
UI Agent Picking Functions | |
| internal_get_user_selected (options) | |
| Internal support function used by other picking functions. More... | |
| get_user_selected_point (_options) | |
| Function returns a point in the world, picked via the UI. More... | |
| get_user_selected_character (_options) | |
| Function returns a character in the world, picked via the ui. More... | |
UI Agent Moveto Functions | |
| simple_move_to_state (x, y, z, message_handler, bg_check_func, bg_check_freq, force_a_star) | |
| This function implements a simple move to state. More... | |
| simple_move_to_path_state (path, message_handler, bg_check_func, bg_check_freq, force_a_star) | |
State Management functions | |
| get_state_name (state_function, object) | |
| Convenience function for printing the name of a state, given a function_pointer. More... | |
| begin_state (_name) | |
| Convenience function for storing the current state in the luaCharacter. More... | |
| get_current_and_previous_states () | |
| Convenience function for debugging. Returns comma-separated list of recent states. More... | |
| is_new_state (ret) | |
| Convenience function for checking if the argument is a new state table. More... | |
| invoke_state (new_state, cleanup_function, extra_info) | |
| Convenience function for doing a tail call function invokation. More... | |
Experimental | |
| draw_path () | |
| Function that draws the character's current path object. More... | |
| draw_line_from_self () | |
| Function draws a line from self to the point under the mouse, plus it either a circle under the mouse point. More... | |
| get_user_selected_path (message, use_default_ui_draw_function) | |
| Function returns a string and a path clicked in the world, picked via the UI. More... | |
| scheduler_heartbeat () | |
| Experimental - heartbeat function for the post event sceduler. More... | |
| add_scheduled_event (callback_data) | |
| Experimental - adds a function to happen in the future. More... | |
| update_scheduler () | |
| process_messages_enroute (message_obj) | |
Public Attributes | |
| userdata | character |
| a pointer to the underlying character; More... | |
| coroutine | state_coroutine |
| a microthread that holds the current state of the VM; More... | |
| MESSAGE_HANDLED = -1 | |
Constructor Template String | |
| init_code = | |
| Constructor Template String. More... | |
| local | character = this_scenario->find_character("CHARACTER_NAME") |
| DERIVED_CLASS = BASE_CLASS->new(character) | |
The base class of all the diguyCharacter's lua representation.
This class wraps a microthread (coroutine) which is responsible for providing a sleepable state machine.
| luaCharacter::add_scheduled_event | ( | callback_data | ) |
Experimental - adds a function to happen in the future.
| luaCharacter::begin_state | ( | _name | ) |
Convenience function for storing the current state in the luaCharacter.
| _name | name of current state |
| luaCharacter::destroy | ( | ) |
This function is called by C++ when the character is destroyed. Overload it to trigger any world cleanup on destruction.
| luaCharacter::die_now | ( | ) |
This function is called when the character is killed. Overload it to trigger any final events or agent clean up on death.
| luaCharacter::draw | ( | ) |
This function is called by diguy scenario to draw a lua object Overload it to create your own Drawing behavior.
| luaCharacter::draw_line_from_self | ( | ) |
Function draws a line from self to the point under the mouse, plus it either a circle under the mouse point.
Function renders a 3d line from the location of the luaCharacter to the location of the mouse point. This is a suitable draw_ui function for selecting a "move to" point, for example.
| luaCharacter::draw_path | ( | ) |
Function that draws the character's current path object.
| luaCharacter::entry_point | ( | ) |
This function is called by the state manager as the entry point into the lua state machine. Overload it to create your own HFSM.
| luaCharacter::get_current_and_previous_states | ( | ) |
Convenience function for debugging. Returns comma-separated list of recent states.
| luaCharacter::get_state_name | ( | state_function | , |
| object | |||
| ) |
Convenience function for printing the name of a state, given a function_pointer.
| state_function | pointer to state_function |
| object | should be nil when called by parent |
| luaCharacter::get_ui_signals | ( | ) |
This function returns a comma separated list of signals that the agent is currently willing to accept.
Normally this would just be nil or a simple string, overload this function to build a more complex system
| luaCharacter::get_ui_state_label | ( | ) |
This function returns a string that the DI-Guy Scenario UI will add onto the end of the state name label.
This function will be evaluated frequently when the feature is being used. ui_state_label can either be set at any point in your code or overload this function to build a more complex string.
| luaCharacter::get_user_selected_character | ( | _options | ) |
Function returns a character in the world, picked via the ui.
This function can take time as the user clicks a character. The character effectively goes to sleep until they receive a valid click.
Takes an options table. Optional parameters are:
| options["message"] | what to place in text label; defaults to "Select character with mouse" |
| options["pause_scenario"] | whether the scenario should be paused during click retrieval; set to true or 1 |
| luaCharacter::get_user_selected_path | ( | message | , |
| use_default_ui_draw_function | |||
| ) |
Function returns a string and a path clicked in the world, picked via the UI.
Function returns "ok" or "cancel" and a path in the world. This function can take time as the user clicks points. The character effectively goes to sleep until the right click happens
Takes a message Optional parameters are:
| message | what to place in text label defaults to: Click a path in the World, right click when done |
| use_default_ui_draw_function | set to true to use the build in path drawing function |
| luaCharacter::get_user_selected_point | ( | _options | ) |
Function returns a point in the world, picked via the UI.
Function returns x,y,z - a point in the world. This function can take time as the user clicks a point. The character effectively goes to sleep until they receive a valid click.
Takes an options table. Optional parameters are:
| options["message"] | what to place in text label defaults to "Select Point In World" |
| options["pause_scenario"] | whether the scenario should be paused during click retrieval; set to true or 1 |
| luaCharacter::init | ( | arg0 | , |
| arg1 | , | ||
| arg2 | |||
| ) |
This function is called at t=0 or when a mind is created, currently no ops.
| arg0,arg1,arg2 | optional init arguments passed from c++ via create_lua_mind's additional args. |
| luaCharacter::internal_get_user_selected | ( | options | ) |
Internal support function used by other picking functions.
| luaCharacter::invoke_state | ( | new_state | , |
| cleanup_function | , | ||
| extra_info | |||
| ) |
Convenience function for doing a tail call function invokation.
| new_state | return value from a process messages function |
| cleanup_function | function to run cleaning up the behavior of the current state |
| luaCharacter::is_new_state | ( | ret | ) |
Convenience function for checking if the argument is a new state table.
| ret | return value from a process messages function |
| luaCharacter::one_time_init | ( | ) |
This function is called when a mind is first created, currently no ops.
| luaCharacter::process_messages_enroute | ( | message_obj | ) |
| luaCharacter::reset | ( | ) |
This function resets the luaCharacter representation, called by c++ on scenario reset.
This function resets the luaCharacter representation. It clears out the current state coroutine which will be recreated in the state_manager update function.
This function MUST be called in overloaded derived classes:
| luaCharacter::scheduler_heartbeat | ( | ) |
Experimental - heartbeat function for the post event sceduler.
Send a message from a character to a character, will automatically send message over network.
Send a message from a character to a character. The given "to" and "from" can be a character's name or the (diguy) character itself. This will handle transmitting to a character over the network if necessary.
| luaCharacter::simple_move_to_path_state | ( | path | , |
| message_handler | , | ||
| bg_check_func | , | ||
| bg_check_freq | , | ||
| force_a_star | |||
| ) |
| luaCharacter::simple_move_to_state | ( | x | , |
| y | , | ||
| z | , | ||
| message_handler | , | ||
| bg_check_func | , | ||
| bg_check_freq | , | ||
| force_a_star | |||
| ) |
This function implements a simple move to state.
Given a point in the world it either makes the character head directly there, or uses the navigation mesh to path plan there. The function can also take optional interruption values.
| message_handler | optional, function that receives messages and can decide to override the wait. |
| bg_check_func | optional; a function that runs in the background; runs every bg_freq function should return a value to break out of wait. |
| bg_freq | optional; frequency of background check function; defaults to every 2 seconds. |
| force_a_star | optional; normally an agent that can see the target destination will use idle and set_desired_position(), set true to force the planner to be used |
| luaCharacter::sleep | ( | duration | ) |
This is a simple sleep function, it will put the character to sleep for the duration specified. The function will be interrupted if a message is received.
Set self.print_debug_messages = 1 to cause this function to print debug messages.
| luaCharacter::sleep_ignore_messages | ( | duration | ) |
This is a simple sleep function, it will put the character to sleep for the duration specified. Messages will not be processed.
| luaCharacter::sleep_process_messages | ( | duration | , |
| message_handler | |||
| ) |
This is a sleep function that can take a message_handler function.
When a message is received it is passed to the message_handler. The message_handler is responsible for processing the message and deciding if the sleep should be interrupted.
| duration | how long to sleep |
| message_handler | function used to assess if character should wake up. |
| luaCharacter::sleep_until | ( | wake_time | ) |
This is a simple sleep function, it will put the character to sleep until the absolute scenario time specified. The function will be interrupted if a message is received.
Set self.print_debug_messages = 1 to cause this function to print debug messages.
| luaCharacter::state_manager | ( | sender | , |
| message_type | , | ||
| message | , | ||
| params | |||
| ) |
This is the main entry point from C++ into the lua framework.
Whenever the character wakes up or receives a message, this function is called to resume the underlying coroutine microthread. The lua side of diguyCharacter:agent_accept_message()
This function should not be overloaded.
| sender,message_type,message,params | match the args to agent_accept_message |
| luaCharacter::update_scheduler | ( | ) |
| luaCharacter::wait_for_message | ( | message_to_wait_for | , |
| message_handler | , | ||
| bg_check_func | , | ||
| bg_freq | |||
| ) |
This is a sleep function that will wait a long time and only wake up when a specific message is recieved.
| message_to_wait_for | a string |
| message_handler | optional, function that receives messages and can decide to override the wait. |
| bg_check_func | optional; a function that runs in the background; runs every bg_freq, function should return a value to break out of wait. |
| bg_freq | optional; frequency of background check function; defaults to every 2 seconds. |
| luaCharacter::wait_for_multichoice | ( | ... | ) |
This is a sleep function that will wait a long time and only wake up when one of a few specific messages are recieved.
| userdata luaCharacter::character |
a pointer to the underlying character;
| local luaCharacter::character = this_scenario->find_character("CHARACTER_NAME") |
| luaCharacter::init_code = |
Constructor Template String.
| luaCharacter::MESSAGE_HANDLED = -1 |
| coroutine luaCharacter::state_coroutine |
a microthread that holds the current state of the VM;