change playable character

Started by croquetasesina, Thu 17/01/2019 19:21:22

Previous topic - Next topic

croquetasesina

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
cCharacter.SetasPlayer();


So, I introduce in my Room Script this:

Code: ags
function cSofia.SetasPlayer();



To change cAlfred character to CSofia.

What is wrong?

dayowlron

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:

Code: ags

function cSofia_click() 
{
  cSofia.SetasPlayer();
}
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Crimson Wizard

#2
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

NickyNyce

https://youtu.be/_lghOGrET2A

These videos might help. They are old, but they will give you an idea of how things work.

croquetasesina

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.

SMF spam blocked by CleanTalk