Door

Class for representing a Door.
 wooden_door = am.door.new("map1_door")
 wooden_door:name("Fantastic Wooden Door")
Return to Index
static new ( string game_id = "" )
__gc ( )
__eq ( am.character rhs ) -> ( boolean )
tile_type ( ) -> ( am.tile_type )
tile_type ( am.tile_type tile_type ) -> ( am.door )
can_open_by ( am.character character ) -> ( boolean )
opened ( ) -> ( boolean )
opened ( boolean opened ) -> ( am.door )
lock ( ) -> ( string )
lock ( string lock_name ) -> ( am.door )
graphic ( ) -> ( am.sprite )
graphic ( am.sprite sprite ) -> ( am.door )
graphic ( string asset_name ) -> ( am.door )
name ( ) -> ( string )
name ( string name ) -> ( am.door )
description ( ) -> ( string )
description ( string description ) -> ( am.door )
location ( ) -> ( number , number )
location ( number x , number y ) -> ( am.door )
grid_location ( ) -> ( integer , integer )
grid_location ( integer x , integer y ) -> ( am.door )
move ( number x , number y ) -> ( am.door )
move_grid ( integer x , integer y ) -> ( am.door )
talk_to ( string id ) -> ( boolean )
talk_to ( am.game_object talkee ) -> ( boolean )
fixed_to_grid ( ) -> ( boolean )
fixed_to_grid ( boolean fixed ) -> ( am.door )
map ( ) -> ( am.map )
map ( am.map map ) -> ( am.door )
original_map ( ) -> ( am.map )
original_map ( am.map map ) -> ( am.door )
add_passible_type ( am.tile_type tile_type ) -> ( am.door )
add_passible_type ( string tile_type_name ) -> ( am.door )
remove_passible_type ( am.tile_type tile_type ) -> ( am.door )
remove_all_passible_types ( ) -> ( am.door )
has_passible_type ( am.tile_type tile_type ) -> ( boolean )
get_passible_types ( ) -> ( table )
game_id ( ) -> ( string )
game_id ( string game_id ) -> ( boolean )
static find ( string game_id ) -> ( am.door )
dialogue_component ( ) -> ( am.dialogue_component )
dialogue_component ( am.dialogue_component comp , boolean set_attached = true ) -> ( )
interact_with ( ) -> ( function )
interact_with ( function func ) -> ( am.door )
interact_dialogue ( am.game_object interacter , bool by_movement ) -> ( am.code )
on ( string event_type , function listener , table content = nil ) -> ( boolean )
off ( string event_type , function listener , table context = nil ) -> ( boolean )
has_event_listener ( string event_type ) -> ( boolean )
attrs ( boolean create_table = false ) -> ( am.data_table )
attrs ( am.data_table attr_table ) -> ( am.door )
static new ( string game_id = "" )
Creates or wraps a door instance.
Parameters:
string game_id = "" : The game id to create the door with or the game id of an existing door.
Returns:
am.character : The newly created door or returns an existing door with the same game_id.
boolean : True if the door was newly created or is just wrapped an existing one.
__gc ( )
Releases the reference of this door.
__eq ( am.character rhs ) -> ( boolean )
Compares this character with another character reference. Will not return true for equivalent characters.
Parameters:
am.character rhs : The other character to compare with.
Returns:
boolean : True if the characters are the same entity.
tile_type ( ) -> ( am.tile_type )
Returns the tile type that's appied to the tile when this door is closed. When the door is opened the door does not affect the tile type.
Returns:
am.tile_type : The door tile type.
tile_type ( am.tile_type tile_type ) -> ( am.door )
Sets the door closed tile type. When the is closed this tile type is applied to the tile the door is over. When the door is opened the tile type is unaffected.
Parameters:
am.tile_type tile_type : The tile type to set.
Returns:
am.door : This
can_open_by ( am.character character ) -> ( boolean )
Returns true if the given character can open this door.
Parameters:
am.character character : The character to check.
Returns:
boolean : True if the given character can open this door.
opened ( ) -> ( boolean )
Returns true if this door is opened.
Returns:
boolean : True if the door is open.
opened ( boolean opened ) -> ( am.door )
Sets is the door is opened.
Parameters:
boolean opened : If the door should be opened.
Returns:
am.door : This
lock ( ) -> ( string )
Returns the lock type as a string.
Returns:
string : The lock type.
lock ( string lock_name ) -> ( am.door )
Sets the lock type by lock name.
Parameters:
string lock_name : The name of the lock type.
Returns:
am.door : This
graphic ( ) -> ( am.sprite )
Returns the graphic attached to this door, can be nil.
Returns:
am.sprite : The door sprite.
graphic ( am.sprite sprite ) -> ( am.door )
Sets the door graphic, can be nil.
Parameters:
am.sprite sprite : The graphic to set.
Returns:
am.door : This
graphic ( string asset_name ) -> ( am.door )
Sets the door asset graphic. Sets the asset_name of the graphic for this door.
Parameters:
string asset_name : The asset name to the graphic.
Returns:
am.door : This
name ( ) -> ( string )
Returns the name of the door. A nil return indicates that there was an error.
Returns:
string : The name of the door.
name ( string name ) -> ( am.door )
Sets the name of the door.
Parameters:
string name : The name to set the door.
Returns:
am.door : This.
description ( ) -> ( string )
Returns the description of the door. A nil return indicates that there was an error.
Returns:
string : The description of the door.
description ( string description ) -> ( am.door )
Sets the description of the door.
Parameters:
string description : The description to set the door.
Returns:
am.door : This.
location ( ) -> ( number , number )
Returns the doors current map location.
Returns:
number : The doors x map value
number : The doors y map value
location ( number x , number y ) -> ( am.door )
Sets the doors map location.
Parameters:
number x : The x map value
number y : The y map value
Returns:
am.door : This
grid_location ( ) -> ( integer , integer )
Returns the doors currnet map grid location.
Returns:
integer : x The x grid value
integer : y The y grid value
grid_location ( integer x , integer y ) -> ( am.door )
Sets the doors current map grid location.
Parameters:
integer x : The x grid value
integer y : The y grid value
Returns:
am.door : This
move ( number x , number y ) -> ( am.door )
Moves a door by {x, y} amount. If the new location isn't valid, the door isn't moved.
Parameters:
number x : The x amount to move by
number y : The y amount to move by
Returns:
am.door : This
move_grid ( integer x , integer y ) -> ( am.door )
Moves a door by {x, y} grid amounts. If the new location isn't valid, the door isn't moved.
Parameters:
integer x : The x grid amount to by move by
integer y : The y grid amount to by move by
Returns:
am.door : This
talk_to ( string id ) -> ( boolean )
Initiates a conversation between this door and the game object id passed in. Returns true if the conversation was initiated. False can mean that the game object id was invalid or that either this door or the game object did not have a dialog component attached.
Parameters:
string id : The game object id.
Returns:
boolean : True if the conversation was initiated.
talk_to ( am.game_object talkee ) -> ( boolean )
Initiates a conversation between this door and the game object passed in. Returns true if the conversation was initiated. False can mean that the game object was nil or that either this door or the game object did not have a dialog component attached.
Parameters:
am.game_object talkee : The game object to start a converstation with.
Returns:
boolean : True if the conversation was initiated.
fixed_to_grid ( ) -> ( boolean )
Returns true if this door is fixed to the game grid or false if the door is able to move freely about the map.
Returns:
boolean : True if the door is fixed to the grid.
fixed_to_grid ( boolean fixed ) -> ( am.door )
Sets if the door is fixed to the grid or not. If a door is fixed to the grid, they cannot move to positions other than the center of each grid space.
Parameters:
boolean fixed : Sets the fixed to grid value.
Returns:
am.door : This
map ( ) -> ( am.map )
Returns the current map that this door is on, can be nil.
Returns:
am.map : The map the door is on.
map ( am.map map ) -> ( am.door )
Sets the map that the door is on, can be nil.
Parameters:
am.map map : The map to put the door on.
Returns:
am.door : This
original_map ( ) -> ( am.map )
Returns the original map that this door was on, can be nil.
Returns:
am.map : The map the door was originally on.
original_map ( am.map map ) -> ( am.door )
Sets the map that the door was originally on, can be nil. This is usually set automatically the first time a door is added to a map. This is primarily used for reloading the door and knowing where to find likely find any event handlers and additional information relating to the door that is not stored directly on the door.
Parameters:
am.map map : The map the door was originally was on.
Returns:
am.door : This
add_passible_type ( am.tile_type tile_type ) -> ( am.door )
Adds a tile type to the list of tile types that this door can move freely on. TileTypes can be added multiple times.
Parameters:
am.tile_type tile_type : The type to add to the list.
Returns:
am.door : This
add_passible_type ( string tile_type_name ) -> ( am.door )
Adds a tile type to the list of tile types that this door can move freely on. Tile types can be added multiple times.
Parameters:
string tile_type_name : The name of the type to add to the list.
Returns:
am.door : This
remove_passible_type ( am.tile_type tile_type ) -> ( am.door )
Removes a tile type from the list of passible tiles.
Parameters:
am.tile_type tile_type : The tile type to remove.
Returns:
am.door : This
remove_all_passible_types ( ) -> ( am.door )
Removes all tile types from this doors passible list.
Returns:
am.door : This
has_passible_type ( am.tile_type tile_type ) -> ( boolean )
Returns true if the given tile type is found on this doors passible list.
Parameters:
am.tile_type tile_type : The tile type to search for
Returns:
boolean : True if the tile type is found
get_passible_types ( ) -> ( table )
Returns a table of all the passible tile types for this door.
Returns:
table : Table of all the tile types.
game_id ( ) -> ( string )
Returns the game id for this door.
Returns:
string : The doors game id.
game_id ( string game_id ) -> ( boolean )
Sets the doors game id, this is used to refer to this door from the game engine. Should be unique.
Parameters:
string game_id : The doors unique game id.
Returns:
boolean : True if the game id change was successful or if game id was the same as the given game_id. False indicates that either there is no current game engine or there is another game object with the same game id.
static find ( string game_id ) -> ( am.door )
Looks up an door in the current game engine with the given game id.
Parameters:
string game_id : The game id to look up.
Returns:
am.door : The found door or nil.
dialogue_component ( ) -> ( am.dialogue_component )
Returns the dialogue component attached to this door, can be nil.
Returns:
am.dialogue_component : The attached dialogue component
dialogue_component ( am.dialogue_component comp , boolean set_attached = true ) -> ( )
Sets a dialogue component onto this door, can be nil.
Parameters:
am.dialogue_component comp : The dialogue component to attach to this door, can be nil.
boolean set_attached = true : When true it also sets that this door is the game object attached to the dialogue component.
interact_with ( ) -> ( function )
Returns the interacting with function, returns nil if no Lua function was set.
Returns:
function : The interact with function.
interact_with ( function func ) -> ( am.door )
Sets the interact with function. This can be used to override the default interaction behaviour. If this function does not specify that it the game object was interacted with, then the default behaviour is executed.
Parameters:
function func : The new interact with functionality.
Returns:
am.door : This
interact_dialogue ( am.game_object interacter , bool by_movement ) -> ( am.code )
Executes dialogue interactions with the object. This can be used during an interact with function callback to start dialogue. This will work with any game object, unless it does not have a dialogue component.
Parameters:
am.game_object interacter : The game object that initiated the interaction.
bool by_movement : Flag that indicates if the interaction started because of movement or because of other reasons, such as mouse input.
Returns:
am.code : Standard interaction results:
did_interact Interaction occured, perform no further actions.
did_not_interact Interaction did not occur, can perform further actions.
do_not_interact Interaction did not occur, but do not perform any further actions.
on ( string event_type , function listener , table content = nil ) -> ( boolean )
Adds an event listener for an event fired on this door. eg:
 door:on("talkTo", function(event)
     am_log("Character talked to")
 end)
Parameters:
string event_type : The event type or name to trigger on
function listener : The function to call when the event is fired.
table content = nil : An option context for the listener to be called with.
Returns:
boolean : True if the event was added successfully.
off ( string event_type , function listener , table context = nil ) -> ( boolean )
Removes an event listener from this door. eg:
 function talkToOnce(event)
     am_log("Character talked to once")
     door:off("talkTo", talkToOnce)
 end
 door:on("talkTo", talkToOnce)
Parameters:
string event_type : The event type the listener was listening for.
function listener : The listener function to remove.
table context = nil : The context which the listener was going to be called with, this is only optional if the listener was added with no context.
Returns:
boolean : True if the event listener was successfully removed.
has_event_listener ( string event_type ) -> ( boolean )
Returns true when there is an event listener for the given event_type.
Parameters:
string event_type : The event type to look up.
Returns:
boolean : True if there is any event listener that will be trigged by this event type.
attrs ( boolean create_table = false ) -> ( am.data_table )
Returns the doors attribute data table. By default if no attribute data table is present nil is returned unless true is passed as the first argument, then a data table is created if one is not present.
Parameters:
boolean create_table = false : Create a data table if one didn't exist.
Returns:
am.data_table : The data table on this character.
attrs ( am.data_table attr_table ) -> ( am.door )
Sets the data table on this door, can be set to nil.
Parameters:
am.data_table attr_table : The data table to set on the door.
Returns:
am.door : This