Need help with global/character values, in paticular booleans [SOLVED]

Started by darkshadow, Sun 13/02/2005 13:28:11

Previous topic - Next topic

darkshadow

My problem is thus: I need to make it so that my character can be either marked as human or cat (and no, there's no strange shape-shifting in this. I like the laws of physics) and depending on if the value is true or false, different things should react in different ways, such as the all he views changing between cat and human, or starting different topics. The player can't change constantly, just after certain triggers, such as the first time he puts on the suit. (cat --> human) I looked through the help and tutorial, but I'm still not quite sure how to do it. Any hints?

DoorKnobHandle

You'd realize things like this with variables.

You add a variable "int playerishuman = 1" which is 1 if the player is human and 0 if the player is a cat.

Then you change the characters appearance depending on this var.

If you have further questions, ask...

darkshadow

I know the principle, but not the specifics.
Should it be character? Global?
What commands do I use, and where?
How do I structure the tree?
Can someone make me a short example?

Scorpiorus

Are you using the Interaction Editor commands or scripting it?

DoorKnobHandle

okok.

at the beginning of your script you add:

Code: ags

int playerishuman;


This introduces a global int variable which holds 0 or 1 depending on whether the player is a human or a cat right now.

Then you code the initial value of this var (lets say your player begins the game being a human...).

You add in the game_start func:

Code: ags

playerishuman = 1;


ok, then you have a inventory item which you can use and it changes your appearance...

so you go to the inventory item editor, select your item and click "on use:"

in this script you write simply:

Code: ags

if (playerishuman = 0)
{
 Ã, playerishuman = 1;
 Ã, SetCharacterView (EGO, NUM_OF_VIEW_WITH_PLAYER_AS_HUMAN);
}
else
{
 Ã, playerishuman = 0;
 Ã, SetCharacterView (EGO, NUM_OF_VIEW_WITH_PLAYER_AS_CAT);
}



which basically just changes the variable to 0 if its 1 or to 1 if it used to be 0 and then changes your view.

now you have this var set up correctly.

now lets say you want the player to only be able to do something if he's a cat. then you would write:

Code: ags

if (playerishuman == 0)
{
 Ã, // what the player should do...
}


thats it.

hope it helps.

darkshadow

Thanks. That's oh-so-helpful. I shall add your name to my credits list under "special thanks". And a thumbs-up.

DoorKnobHandle


darkshadow

Entirely necessary, I'd have left my project as foobar if it wasn't for you, I was about to give up hope on what I hope will be a rather splendiferous adventure game, M'SS.
I think your name goes in "Coding Help".
And I reckon I'll be on the forum a lot... Not so hot with the coding, my mind's still left behind in the days of QB!

Would be nicer not to have to fiddle around in the code, though, but I'm sure I can manage... Oops!

SMF spam blocked by CleanTalk