How to change character name using the IF statement?

Started by MikeDraven, Thu 06/05/2021 15:11:12

Previous topic - Next topic

MikeDraven

Hi!
I've started using AGS a few days ago, but I'm a quick learner.

My question is: how can you change the name of a character (RealName) using the IF statement?

I'll show you my example and what I want to achieve.

I've got an NPC, let's say he's described as "Little guy" (RealName) and his ScriptName is cGuy. The player talks to him and asks who is he (Dialog option #1). The NPC responds that his name is "John".

And now I want the RealName of this character to be "John" (or at least that should be displayed as hotspot, so maybe I'm overthinking it?).

I've tried something like this:

Code: ags

function cGuy_Identity()
{
  if(dGuyStart.HasOptionBeenChosen(1)) {
    cGuy.Name = "John";
  }
}




But it doesn't seem to work.
Any ideas? :)

eri0o

What do you mean with "doesn't work"?

Suggestion for if statements: put either a Display ("TEST"); or breakpoint and run through the debugger to check if the condition is working as you expect.

Your function 'cGuy_Identity' , where it's being called? Is it really being called?

Easier way would be to place cGuy.Name = "John"; directly in the dialog script.

MikeDraven

Quote from: eri0o on Thu 06/05/2021 15:22:04
Easier way would be to place cGuy.Name = "John"; directly in the dialog script.

Heh, I guess I was thinking too hard. Your way worked like a charm! Thanks!

(and the function was called by cGuy event Usermode 1 - but I probably used it wrong, like I said, I started with AGS a few days ago ;) )

SMF spam blocked by CleanTalk