ICharacter - carenalgas/popochiu GitHub Wiki

Description

Inherits PopochiuClickable.

Use it to make characters do actions. Is the shortcut for ICharacter.gd, and can be used (from any script) with C (i.e. C.walk_to_clicked() or C.Glottis.walk_to_prop('CoffeeMachine')).

Some things you can do with it:

  • Access the player character (PC) directly.
  • Get any character.
  • Make characters move or say something.

Examples

C.face_clicked() # Makes the PC look at the clicked node (of type Clickable)
C.character_say('Glottis', 'Hi Manny!') # Makes character Glottis greet
C.connect('character_spoke', self, '_do_something_after_spoke') # 
C.player.face_left() # Makes the PC look left

⬇️ Since version 1.9.0 ⬇️

C.Glottis.say('Hi Manny!')
C.Manny.face_right()
C.Meche.walk_to_hotspot('Window')

Properties

Signals

  • character_move_ended( PopochiuCharacter character ). Emitted when a character finishes moving through a room. This happens in the _clear_navigation_path() method of PopochiuRoom.

  • character_spoke( PopochiuCharacter character, String message ). Emitted when a character says message. This is what makes the graphic interface display the text of what the character is saying. Emitted by the say() method in PopochiuCharacter.

Public

Methods

Public

  • change_camera_owner( PopochiuCharacter c, bool is_in_queue = true ) void

    Defines which PopochiuCharacter c will the camera follow. If you want to use it outside a E.run(), send is_in_queue as false. Can be yield.

  • character_say( String chr_name, String dialog ) void

    🍑 Intended to be used inside an E.run() (a.k.a. queue of instructions) 🍑

    Makes the PopochiuCharacter with chr_name (script_name) say a line of dialog. Can be yield.

    func on_room_transition_finished() -> void:
      # Glottis greets Manny and the code pauses until the player clicks anywhere
      yield(E.run([
        C.character_say('Glottis', 'Hi Manny'),
        C.character_say('Glottis', 'What are you doing here?')
      ]), 'completed')
    
  • character_say_no_block( String chr_name, String dialog ) void

    Makes the PopochiuCharacter with chr_name (script_name) say a line of dialog immediately. Can be yield.

    func on_room_transition_finished() -> void:
      # Glottis greets Manny
      C.character_say_no_block('Glottis', 'Hi Manny')
    
  • character_walk_to( String chr_name, [Vector2](https://docs.godotengine.org/en/stable/classes/class_vector2.html) position, [bool](https://docs.godotengine.org/en/stable/classes/class_bool.html) is_in_queue = true` ) void

    Makes the PopochiuCharacter with chr_name (script_name) move to position in the current room. If you want to use it outside a E.run(), send is_in_queue as false. Can be yield.

    # This is the CharacterGlottis.gd script file
    func on_item_used(item: PopochiuInventoryItem) -> void:
      if item.script_name == 'Mice':
        # Make this character walk to the point with name Exit.
        yield(
          C.character_walk_to(self.script_name, room.get_point('Exit'), false),
          'completed'
        )
        C.character_say(self.script_name, 'What are you doing!!!???', false)
    
  • face_clicked( bool is_in_queue = true ) void

    Makes the PC (player character) look at the last clicked PopochiuClickable. If you want to use it outside a E.run(), send is_in_queue as false. Can be yield.

  • get_character( String script_name ) PopochiuCharacter

    Looks for a PopochiuCharacter whith script_name and returns it, otherwise returns null.

    It looks for the PopochiuCharacter in the array of characters in Popochiu.

  • get_character_ignore_walkable_areas( String chr_name ) bool

    Gets the ignore_walkable_areas property value for the specified character. When this property is true, the character can move ignoring walkable areas boundaries. Useful in rooms with multiple walkable areas, when only certain actions may allow to walk from one to the other.

  • get_runtime_character( String script_name ) PopochiuCharacter

    Returns the instance of the PopochiuCharacter identified with script_name. Otherwise returns null. This method is used to assign the instace of characters in the A singleton, in order to make work calls like C.Glottis.face_left().

  • is_valid_character( String script_name ) bool

    Checks if the character with script_name exists in the array of PopochiuCharacter instances in this class.

  • player_say( String dialog ) void

    🍑 Intended to be used inside an E.run() (a.k.a. queue of instructions) 🍑

    Makes the PC (Player-controlled Character) say dialog. Can be yield.

    func on_room_transition_finished() -> void:
      E.run([
        C.player_say("I'm in a run")
      ])
    
  • player_say_no_block( String dialog ) void

    Makes the PC (Player-controlled Character) say dialog immediately. Can be yield.

    func on_room_transition_finished() -> void:
      yield(C.player_say_no_block("I'm not in a run", false), 'completed')
    
      # Do something once players click anywhere to finish the dialogue line
    
  • player_walk_to( Vector2 position, bool is_in_queue = true ) void

    Makes the PC (player character) walk to a position in the current room. If you want to use it outside a E.run(), send is_in_queue as false. Can be yield.

    func on_room_transition_finished() -> void:
      yield(
        C.player_walk_to(room.get_hotspot('Stairs').walk_to_point, false),
        'completed'
      )
    
      E.run([
        'Player: What!?',
        'Player: I have to climb all those steps?'
      ])
    
  • set_character_emotion( String chr_name, String emotion, bool is_in_queue = true ) return_type

    Sets the PopochiuCharacter with chr_name to have its emotion identifier as emotion. If you want to use it outside a E.run(), send is_in_queue as false.

  • set_character_ignore_walkable_areas( String chr_name, bool value ) void

    Sets the ignore_walkable_areas property for the specified character. When this property is true, the character can move ignoring walkable areas boundaries. Useful in rooms with multiple walkable areas, when only certain actions may allow to walk from one to the other.

  • walk_to_clicked( bool is_in_queue = true ) void

    Makes the PC (player character) walk to the walk_to_point position of the last clicked PopochiuClickable (e.g. a PopochiuProp, a PopochiuHotspot, another PopochiuCharacter) in the current room. If you want to use it outside a E.run(), send is_in_queue as false.

    C walk_to_clicked

    ☝️ The clicked prop (the file cabinet) and hotspots (the blueprint and the window) in this room have this: ☝️

    func on_interact() -> void:
      C.walk_to_clicked(false)
    

Set and get

  • set_player( PopochiuCharacter value ) void

    Sets value as the current player (Player-controlled character). It also assigns value to camera_owner.

Private

  • _character_say( String chr_name, String dialog ) void

    Internally used to make the PopochiuCharacter with chr_name say a line of dialog. This method is called by character_say() and character_say_no_block().