Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: croquetasesina on Thu 17/01/2019 19:21:22

Title: change playable character
Post by: croquetasesina on Thu 17/01/2019 19:21:22
Hello!!
I'm a new user of the forum.
I've started to use AGS yesterday. I've read in the tutorial about change the playable character with this code:

Code (ags) Select
cCharacter.SetasPlayer();

So, I introduce in my Room Script this:

Code (ags) Select
function cSofia.SetasPlayer();



To change cAlfred character to CSofia.

What is wrong?
Title: Re: change playable character
Post by: dayowlron on Thu 17/01/2019 19:40:00
That doesn't even make sense.
What event do you want to have happen to make the player change character? Then you put the cSofia.SetasPlayer(); line in that function.
something like:


function cSofia_click()
{
  cSofia.SetasPlayer();
}
Title: Re: change playable character
Post by: Crimson Wizard on Thu 17/01/2019 21:38:45
Hello.

First of all, it's SetAsPlayer, the script is case sensitive.

Regarding where to place this command, as dayowlron mentioned you need to put it in a function.
AGS script is function-based, which means that all commands must be in some function. Functions are called either by events or other functions.
Events can be like game start, entering the room, clicking on character or button, and so on.

How do you connect events to functions? Bunch of events look for certain function names which cannot be changed, like "game_start". They are listed here: https://www.adventuregamestudio.co.uk/manual/ags40.htm#TextScriptEvents

Room and object-related events (also for characters, GUI, inventory items etc) are configured on their respective property pane, on the "events" tab. You can go there by clicking on the "lighting" tool button when an object is currently selected in the editor.
https://www.adventuregamestudio.co.uk/manual/acintro3.htm
Title: Re: change playable character
Post by: NickyNyce on Thu 17/01/2019 22:01:09
https://youtu.be/_lghOGrET2A

These videos might help. They are old, but they will give you an idea of how things work.
Title: Re: change playable character
Post by: croquetasesina on Fri 18/01/2019 10:06:18
Thanks you very much at all.

Yesterday I found a solution. I used an event called room_AfterFadeIn() in the room2 and made the function CharacterAsPlayer.

Thanks you another time.