Scripting Problem : Multiple Characters

Started by , Sat 15/04/2006 21:36:42

Previous topic - Next topic

vange100

Well , I hve read some topics and the manual but I still don't understand . . .

Look what I'm trying :

character[.......].SetAsPlayer();

and when I'm trying to Test my game it says :

Parse error : unexpected 'character'

=======================================================

Please tell me , what I'm doing wrong . . .
(I just want to have a game with 3 characters - and the player can choose with who character wants to play)

DoorKnobHandle

#1
What version of AGS are you using?

With versions 2.7 or even 2.71, you should use this instead:

Code: ags

cEgo.SetAsPlayer ( );


Of course you'd need to change "cEgo" into "cWhatever_your_characters_name_is"...

Welcome to the forums.

Ashen

#2
The 'unexpected (whatever)' error can also (and usually does) mean you've put your code in the wrong place, so where HAVE you put it?

It'll need to be inside a function (whichever one runs when you change character - probably a GUI Button, but we can get to that later).

While cWhatever.SetAsPlayer() certainly looks neater, character[WHATEVER].SetAsPlayer() should work just as well.
I know what you're thinking ... Don't think that.

vange100

#3
wait a second to test . . . this code !

EDIT:
it says again . . .

unexpected 'c...my character name' !!!!

=======================================================

If you wanted (for example) to change your player , to use instead of character "EGO" to character "SPOT" , in room 2 ,what would you do . . .

========================================================

I have put it in my room's script , line 2 . . . . . . . . . . . .

and I have used both command you say and I still have the "Parse error" . . .

Ashen

#4
You didn't really put c...my character name in the script did you..... ;)

READ THE MANUAL. Please.
If your character's script name is SPOT, you'd use cSpot.SetAsPlayer(); (or character[SPOT].SetAsPlayer(); if you prefer).
However I'm fairly sure the problem is where you've put the code, so again: Where in the script have you got that line?

EDIT: And don't double post - use the 'Modify' link instead. Thanks.
I know what you're thinking ... Don't think that.

vange100

Sorry for the double post . . .

=======================

I have put it in room's script , line 2 . . .

Ashen

So, outside of all functions, just at the top of the room script?
That's your problem - read my first post again, you need to figure out when you want the character to change, and put the command inside the approriate function.
I know what you're thinking ... Don't think that.

vange100

What do you mean "I have to figure out when I want the character to change" . . .

==================================================

I'm playing with ROGER in a room and I want to change character and play with SPOT . . . whenever I want ! like the game "Two of A Kind - something like that"

Ashen

#8
I mean you need to consider where in the script would be the proper place for the command (or, if you prefer, what the player has to do to change characters) See the Placing your code entry in the BFAQ for more detail.
So the player can choose at will when to change? In that case the room script is probably the wrong place for it, since that'd mean you can only change in that room (not a problem if it's a one room game, obviously). You'll probably (like I said in my first post) be best doing this with GUI buttons (one for each character to change to). (I think that's how it was done in ToaK, anyway.)
So make the GUI, make the buttons (or add them to an existing GUI), and set them to run the code when you click 'em. (Do a forum search for how to make GUIs, if you're not sure.)

An other option would be to put it in on_key_press, and have keyboard interaction change characters (e.g. press "1" for cEgo, "2" for cSpot, etc).
I know what you're thinking ... Don't think that.

vange100

I understood what you are saying . . .

I'll try it and I'll post a reply tommorow !!!

=========================================

THANKS A LOT FOR YOUR HELP !!!

vange100

#10
I made a GUI with ( 5 buttons - 5 characters ) but I don't know how to put the command so the charactes can change . . .

(Do I use scripting and if yes where ?)

Is there a Tutorial for this ?

Ashen

Yes, you'll have to use scripting. You should be able to find more detailed help by searching the forums, but basically:
1) Name the buttons. (The 'Script name' property on the floating Properties window.)
2) Double-click the button in the editor. This will create (the first time) and open for editing the button's Control function. This is where you need to put the code to be run when the button is clicked in-game.

(The same principal is used for almost all GUI Control types.)
I know what you're thinking ... Don't think that.

vange100

Thanks . . . (that worked) !!!

======================================================

Something else . . .
How will I make a pop up window when my character gets in an elevator (so the player can choose which floor he wants to go) - (like seven days a sceptic) ???

Ashen

Two ways come to mind. Firstly, you could make a seperate room, with the panel drawn onto the background and use hotspots/objects for the buttons. Secondly (my preference and I think what was done in 7DaS, but it's been a while) you once again use a GUI, and just have it turn on when the player uses the lift (see the GUI.Visible propertry - in fact you'll probably want to learn MOST of the GUI commands at some point).
I know what you're thinking ... Don't think that.

vange100

Hello again !

I have worked with the GUI and the changing character but now I have to know something else . . .

I have the character EGO and when he interacts with a hotspot he is changing room , the new room is loaded but now I want a new character to play as just for this room !!!

Were I must put the code ???

( for more information . . . my character interacts a hotspot (car) and he is changing room , in the next room he is inside the car and when you move the car to the right edge he is in another room himself , without the car )

Ashen

The easiest way to do it is probably to change EGOs view in the 'Player enters room (before fadein)' interaction of the room where he's in the car, and back again in 'Player leaves room'. This way is certainly easier if you're not sure which one of the playable characters it'll be.

The other way would be to have EGO-in-the-car as a seperate character and make them the player when EGO interacts with the car (AGS should switch to the room they're in). Then move EGO to the room you want him to end up in, and switch back when the car character cross the right edge.
I know what you're thinking ... Don't think that.

vange100

THANKS A LOT FOR YOUR HELP !!!

In the end of my game I want to have an animation . . . but is too big to play  it with the "Animate Background" . . .

Is there a way to do it ???

Ashen

Depends what the animation is of. If it's just text credits, the Credits module might be useful. Otherwise you'll need to use a couple of animated objects/characters, or if you can save it as a video or flc file in an external program you could use PlayVideo/PlayFlic.

And you know, you ARE allowed to start a new thread for new, unrelated questions ...
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk