Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Icey on Tue 08/02/2011 05:57:17

Title: How do I fix this.[S]
Post by: Icey on Tue 08/02/2011 05:57:17
I really have know clue how to title this but I was hoping for hint at how to fix it.
(http://www.pictureshoster.com/files/9wxfd8zci987pzjdno1t.png)
Before when I pressed (Z) to bring up the party menu I was able to set my player. Then when I talked to someone or something AGS reconized the player and called the Speech txt for that player. Basicly it worked but now it keeps setting dave as the player and only calling his Speech txt?


This error occurred I think after I added
-Background to room3
-2 obj in room3
-SayAt for character in room 2
-new gui
-label on new gui/ it's txt: @overhotspot@
-Change label font
-When player changes chr it also changes label on new txt color to match the 1 of the selected 4 players speech color


A temped fix Noticed:

-Removing else makes AGS call every ones Speech txt for that function.
Title: Re: How do I fix this.
Post by: ddq on Tue 08/02/2011 06:05:09
You have to check which button you click to select a player first, use SetAsPlayer() there, and then check which is player later.
if (player.ID == Dave.ID)    or    if (player.Name == Dave.Name)
Keep the elses.
Title: Re: How do I fix this.
Post by: Icey on Tue 08/02/2011 06:10:48
Thanks ddq I will try this.

It was working before and now I dont what hapend  :(
Title: Re: How do I fix this.
Post by: Gilbert on Tue 08/02/2011 06:19:31
To elaborate, you need to check player.ID (I think it actually works just with the character pointers, not necessarily the IDs) for the current player like ddq has mentioned. DON'T use SetAsPlayer() in the if...else conditions, as this function literally SET (not CHECK, got it?) the current player character.

The reason you got this problem is that, in the first if clause 'if (Dave.SetAsPlayer(blah)){blah bla}' the engine has set the player character to Dave already. You just need to check it like:

if (player==Dave){
  blah bla
} else if (player==chris){
  blah bla bla
} else ... etc.

Title: Re: How do I fix this.
Post by: Icey on Tue 08/02/2011 06:51:50
Ahh, Ok I get now. Thanks