Need assistance with setting a narrator screen message with voice

Started by Gal Shemesh, Wed 21/06/2023 11:21:46

Previous topic - Next topic

Crimson Wizard

Quote from: Gal Shemesh on Tue 25/07/2023 22:56:26And thanks for pointing this out! I didn't understand at first why I couldn't just use cCharacter along with my new custom function name and make it to work. So that extender you mention is the 'this' word before the Character*?

This is a respective manual entry:
https://adventuregamestudio.github.io/ags-manual/ExtenderFunctions.html

'this' in function argument defines which object type this function will belong to, while 'this' keyword in statements is a reference to "current object".

There's an article that overviews the object functions with 'this':
https://adventuregamestudio.github.io/ags-manual/OOProgramming.html

Khris

In the engine there's code similar to this:

Code: ags
class Character {
  int x, y;

  function Move(...) {
    ...
  }

  function Say(...) {
    ...
  }

  ...
}

An extender function allows you to "extend" this character class by your own functions, this way you can use them in your scripts like the built-in ones, using dot notation.

When you call player.SayNew(...), "this" refers to the player. When you call cNPC.SayNew(...), "this" refers to cNPC, and so on.

SMF spam blocked by CleanTalk