Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sat 05/08/2006 14:02:43

Title: Looking at item before picking it up [SOLVED]
Post by: on Sat 05/08/2006 14:02:43
Hi there,
Ã,  I am the new girl on the block and am very new to AGS and to scripting.Ã,  Just starting out with a game and was wondering if there is a way to have a character look at an item or hotspot before he/she is able to interact with it.Ã,  I have tried several different scripts (that I found in the forums), but none seem to be what I need.Ã,  Right now, all I have is a blank slate.Ã,  Any and allÃ,  help would be greatly appreciated...
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Many thanks in advance

Title: Re: Looking at item before picking it up
Post by: limeTree on Sat 05/08/2006 14:45:35
There is already a face poition option,and depending the AGS version you are using,you can set that on the settings meanu.
But,meaby i misunderstood you.
What exactly do you want?
Title: Re: Looking at item before picking it up
Post by: on Sat 05/08/2006 15:03:46
Thank-you for responding so quickly...

   If it can be done, I want to be able to have the player look at an item or hotspot using eModeLook before he/she actually can interact with it.  That way, the player can't just pick up items at random.
Title: Re: Looking at item before picking it up
Post by: Ali on Sat 05/08/2006 15:51:07
I think you need to define some kind of integer to store information about whether the player has looked at the hotspot. I'm no expert but I'd try something like this...

When the player looks at the hotspot/object:

cEgo.Say ("Oh look, a bucket of prawns");
LookPrawns=1;

And when they interact with the hotspot:

if (LookPrawns!=(1)) cEgo.Say ("I'd better look at them first");
if (LookPrawns==(1)) {cEgo.Say ("Mmm, delicious prawns!");
cEgo.AddInventory (iPrawn);}

You'd also need to define:

int LookPrawns;

I think in the Global Header, but I don't have AGS to hand so I can't check.

As I say, I'm no expert. Something like this should work, but I'm sure someone cleverer will correct any mistakes I've made here.

Title: Re: Looking at item before picking it up
Post by: Alynn on Sat 05/08/2006 16:48:39
You could do this a few ways...

One create a bool for each item
bool ItemOneLookedAt = false;
bool ItemTwoLookedAt = false;

and so on... once each item is looked at change the variable to true, and for the interaction check if it's true, and if it is, then allow it to be picked up.

The other way is to create a custom property for each item that bascially does the same exact thing. Fairly similar to what Ali said execpt it would be

if (PrawnLookedAt) {
cEgo.Say("MMM Prawns");
cEgo.AddInventory(iPrawn);
}
else Say("Maybe I should look at them first.");

Hope it helped
Title: Re: Looking at item before picking it up
Post by: on Sat 05/08/2006 19:31:36
Thank-you both very much!!!

I tried Ali's suggestion and it worked perfectly!!!  Now, the game goes on...
Title: Re: Looking at item before picking it up [SOLVED]
Post by: Ali on Sat 05/08/2006 19:46:19
I'm glad I helped, but bear Alynn's suggestions in mind for the future. They look a little more elegant than mine.