DI-Guy Lua AI SDK
 All Classes Files Functions Variables Groups Pages
luaSmartProp Class Reference

A base class for creating movable props with auto tagging features. More...

Inheritance diagram for luaSmartProp:
luaCharacter luaFoodStand luaLounge luaMosque luaUrbanSite

Public Member Functions

Standard Infrastructure
 init_package ()
 this function is called at time 0 More...
 
 reset_package ()
 this function is called at reset More...
 
 init_package ()
 
 get_ui_signals ()
 
 serialize_instance ()
 Called by C++ on save. Writes out the list of people that the prop owns plus position info. More...
 
 deselected ()
 Called by C++ on deselection. More...
 
 selected ()
 Called by C++ on selection. More...
 
 init ()
 Standard mind function. More...
 
 reset ()
 Standard mind function. More...
 
 first_update ()
 Called from entry_point(). Opens interface for placement if prop has not been positioned yet. More...
 
 destroy ()
 Erases the tagged regions. More...
 
UI Functions
 show_ui_label (message)
 
 hide_ui_label ()
 
Messages and States
 process_callback (message_object)
 
 process_messages (message_object)
 
 process_broadcast (message_object)
 
 process_signal (message_object)
 
 idle_state ()
 
 entry_point ()
 Standard mind function: the initial state of the Lua character. More...
 
 position_building_state ()
 High-level state for positioning building/prop. More...
 
 reposition_state (args)
 Main state for positioning building/prop. User sees a position interface and uses mouse to control. More...
 
Draw Functions
 draw_highlighted ()
 
 draw_building_subregion_boundaries (repositioning)
 Draws subregions associated with building. 'repositioning' is true if user currently repositioning. More...
 
 draw_building_outline_highlighted ()
 Draws building outline when building is selected. More...
 
 draw_building_outline_translational ()
 Draws building outline when building is being moved. More...
 
 draw_building_outline_rotational ()
 Draws building outline when building is being rotated. More...
 
People Management
 add_person_to_building (new_diguy_name)
 Adds the named character (who must exist and have a Lua mind) to building. More...
 
 person_died_callback (building_name)
 Informs the building that an associated character has died. More...
 
 revive_dead_person (data)
 Revives a dead human character that was associated with the building. More...
 
 find_or_create_character (params)
 Associates a human character with the building/smart prop. More...
 
 get_character_actions (character_name)
 
Helper Functions

Bump building up (vertically) by specified amount

 bump_building (delta)
 
 setup_subregions (erase)
 Create subregions automatically associated with building/prop. Subregions represent things like where customers stand. More...
 
 normalize_dist (appearances)
 Convert a table of appearances and their weights to forms suitable for random selection. More...
 
 distributed_choice_clear (appearances)
 Goes through a table of appearances and distributions, and clears count values. More...
 
 distributed_choice (appearances, force_uniqueness)
 Given a table of appearances and their frequency weights, choose a random appearance. More...
 
 on_creation ()
 Called from luaLifeFormServer. Creates human characters associated with prop. More...
 
 should_create_people ()
 Returns true if people should be created along with smart prop (e.g. shopkeepers) More...
 
To Be Removed
 roof_takeover_state (luaChar, optional_delay)
 This function has to do with people going up on the roof a building. Should be removed. More...
 
- Public Member Functions inherited from luaCharacter
 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...
 
 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...
 
 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...
 
 state_manager (sender, message_type, message, params)
 This is the main entry point from C++ into the lua framework. More...
 
 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...
 
 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...
 
 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)
 
 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...
 
 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

Static Members
string display_name = "Generic Building"
 
string movement_signals = "Move, >, translate, rotate, bump down, bump up, - , destroy, < "
 
luaSmartProp regions tostring = function(obj) return table.len(obj) -2 .. " Regions" end
 Default region info. More...
 
luaSmartProp regions string shop1 = {x= 1, y=0, z=0, type="circle", radius=1.5, subregion_index = DIGUY_SUBREGION_GREEN}
 
 people_to_string = function(obj)
 
local num = 0
 
 num = num +1
 
Template Code for Subclasses
string package_init_code = diguy_package_registry.package_init_code ..
 Modify the package constructor string so that subclasses of this class have a modified template. More...
 
- Public Attributes inherited from luaCharacter
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
 
 init_code =
 Constructor Template String. More...
 
local character = this_scenario->find_character("CHARACTER_NAME")
 
 DERIVED_CLASS = BASE_CLASS->new(character)
 

Detailed Description

A base class for creating movable props with auto tagging features.

This class can be used for interactive objects, buildings, or areas, such as food stands, lounges, or religious sites.

Member Function Documentation

luaSmartProp::add_person_to_building ( new_diguy_name  )

Adds the named character (who must exist and have a Lua mind) to building.

luaSmartProp::bump_building ( delta  )
luaSmartProp::deselected ( )

Called by C++ on deselection.

luaSmartProp::destroy ( )

Erases the tagged regions.

luaSmartProp::distributed_choice ( appearances  ,
force_uniqueness   
)

Given a table of appearances and their frequency weights, choose a random appearance.

Each entry in the original table will be in the form of:

{appearance=x, dist=y, count=z}

The highest-weighted appearances (the weight is in dist) will be more likely to be chosen.

Parameters
appearancestable in the form described above.
force_uniquenessif true, only appearances not previously selected will be selected. distributed_choice_clear() will reset the flags for this.
Returns
The chosen appearance (maybe the name for it?)
luaSmartProp::distributed_choice_clear ( appearances  )

Goes through a table of appearances and distributions, and clears count values.

luaSmartProp::draw_building_outline_highlighted ( )

Draws building outline when building is selected.

luaSmartProp::draw_building_outline_rotational ( )

Draws building outline when building is being rotated.

luaSmartProp::draw_building_outline_translational ( )

Draws building outline when building is being moved.

luaSmartProp::draw_building_subregion_boundaries ( repositioning  )

Draws subregions associated with building. 'repositioning' is true if user currently repositioning.

luaSmartProp::draw_highlighted ( )
luaSmartProp::entry_point ( )

Standard mind function: the initial state of the Lua character.

luaSmartProp::find_or_create_character ( params  )

Associates a human character with the building/smart prop.

Will create the character or use an existing one.

Parameters
paramstable describing the character
params.mindname of mind
params.name_suffixlast name of character
luaSmartProp::first_update ( )

Called from entry_point(). Opens interface for placement if prop has not been positioned yet.

luaSmartProp::get_character_actions ( character_name  )
luaSmartProp::get_ui_signals ( )
luaSmartProp::hide_ui_label ( )
luaSmartProp::idle_state ( )
luaSmartProp::init ( )

Standard mind function.

luaSmartProp::init_package ( )

this function is called at time 0

luaSmartProp::init_package ( )
luaSmartProp::normalize_dist ( appearances  )

Convert a table of appearances and their weights to forms suitable for random selection.

Each entry in the original table will be in the form of:

{appearance=x, dist=y}

...where dist is a weight indicating frequency of appearance. Normalization will create a table in which each entry has a value between 0 and 1. The function will also produce an "integrated" version of the normalized table, in which each entry n contains the integral of the normalized table between 0 and n.

Parameters
appearancestable in the form described above.
Returns
Normalized table
Integrated table
luaSmartProp::on_creation ( )

Called from luaLifeFormServer. Creates human characters associated with prop.

luaSmartProp::person_died_callback ( building_name  )

Informs the building that an associated character has died.

Called via the die_callbacks table associated with a human character. Because of how the callback system works, the 'self' reference will point to the human character.

Parameters
self(automatic Lua argument) reference to human Lua character who has died.
building_namename of building character
luaSmartProp::position_building_state ( )

High-level state for positioning building/prop.

luaSmartProp::process_broadcast ( message_object  )
luaSmartProp::process_callback ( message_object  )
luaSmartProp::process_messages ( message_object  )
luaSmartProp::process_signal ( message_object  )
luaSmartProp::reposition_state ( args  )

Main state for positioning building/prop. User sees a position interface and uses mouse to control.

luaSmartProp::reset ( )

Standard mind function.

luaSmartProp::reset_package ( )

this function is called at reset

luaSmartProp::revive_dead_person ( data  )

Revives a dead human character that was associated with the building.

Arguments:

Parameters
datatable containing reference to human character (in obj)
luaSmartProp::roof_takeover_state ( luaChar  ,
optional_delay   
)

This function has to do with people going up on the roof a building. Should be removed.

luaSmartProp::selected ( )

Called by C++ on selection.

luaSmartProp::serialize_instance ( )

Called by C++ on save. Writes out the list of people that the prop owns plus position info.

luaSmartProp::setup_subregions ( erase  )

Create subregions automatically associated with building/prop. Subregions represent things like where customers stand.

luaSmartProp::should_create_people ( )

Returns true if people should be created along with smart prop (e.g. shopkeepers)

luaSmartProp::show_ui_label ( message  )

Member Data Documentation

string luaSmartProp::display_name = "Generic Building"
string luaSmartProp::movement_signals = "Move, >, translate, rotate, bump down, bump up, - , destroy, < "
local luaSmartProp::num = 0
luaSmartProp::num = num +1
string luaSmartProp::package_init_code = diguy_package_registry.package_init_code ..

Modify the package constructor string so that subclasses of this class have a modified template.

luaSmartProp::people_to_string = function(obj)
luaSmartProp regions string luaSmartProp::shop1 = {x= 1, y=0, z=0, type="circle", radius=1.5, subregion_index = DIGUY_SUBREGION_GREEN}
luaSmartProp regions luaSmartProp::tostring = function(obj) return table.len(obj) -2 .. " Regions" end

Default region info.


The documentation for this class was generated from the following file: