Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: RetroJay on Fri 20/06/2008 22:11:32

Title: Has player looked at hotspot/object in another room. (SOLVED).
Post by: RetroJay on Fri 20/06/2008 22:11:32
Hi Peeps.

First of all I am using AGS 2.72.
I am really pleased with myself cos I just sorted a prob all by myself. ;D Well I can't take full credit as the manual did help.
But I have another prob that I can't find the answer to.
Lets say for instance I have two rooms (lets be clever and call them 1 and 2). Now I start in room1 and can't find anything to look at. So I go into room2 and look at a picture (Hotspot/object) which gives me some dialog. This part is not a prob. But now when I go back into room1 a Hotspot that was hidden before is now visible.
The thing is I only want the hotspot in room1 to become visible only if the player has looked at the (Hotspot/object) in room2.
Is there a way of doing this.
Many Thanks.
JAY.
Title: Re: Has player looked at hotspot/object in another room.
Post by: Dualnames on Fri 20/06/2008 22:24:28
yes there is.
Go to the global script header and put this:
bool hotspotlooked=false;

Then at the hotspot interaction at room 2 put this:
hotspotlooked=true;

then at the room1 before fade in put this:
if (hotspotlooked==false) {
DisableHotspot(1);
}
if (hotspotlooked==true) {
EnableHotspot(1);
}
Title: Re: Has player looked at hotspot/object in another room.
Post by: RetroJay on Fri 20/06/2008 23:46:07
Hi Dualnames.

Thanks for your reply. However I can't seem to get it to work. It didn't even like the "Enable/DisableHotspot" lines I Had to change them to
"hotspot[1].Visible = true" before it would even test my game. I have gone over and over it to make sure I have done it right.
I have done exactly what you told me to do (and type) but no luck. The hotspot in room1 just stays off.
Just one thought.  "hotspotlooked" is that how it is or should that be the name of my hotspot.
Sorry and thanks.
JAY.
Title: Re: Has player looked at hotspot/object in another room.
Post by: TwinMoon on Sat 21/06/2008 00:09:43
You have to use hotspot.Enabled instead of hotspot.Visible, that ought to do it.

I use 3.0 and in my manual is says that this doesn't get reset when you leave the room, if it also says that in the 2.72 manual that might also solve your problem.
Title: Re: Has player looked at hotspot/object in another room.
Post by: Dualnames on Sat 21/06/2008 00:43:16
I couldn't remember the function exactly. hotspotlooked is a boolean variable(gets either true or false) that we place on the global script header so we can use to all rooms. When the game starts it gets the value false.

instead of disable enable put this
as Twin moon pointed out.
in the place of enable:
hotspot[1].Enabled=true;
and in the place of disable:
hotspot[1].Enabled=false;

I used to use ags 2.72 a lot. So this will work.
Title: Re: Has player looked at hotspot/object in another room.
Post by: RetroJay on Sat 21/06/2008 01:29:35
Hi again.

I thank you both.
You have been most helpfull.
I haven't tried this yet but I can see my error in putting "visible" instead of "Enable".
I will have to try this monday now as I have to work weekend and must try (if possible) to get some sleep.
I will let you know if it works Monday (All being well).

Thankyou and good night.
JAY.
Title: Re: Has player looked at hotspot/object in another room.
Post by: Khris on Sat 21/06/2008 14:47:15
Don't forget to import and export the variable; otherwise it won't be visible to the room script:
// script header
import bool hotspotlooked;

// global script

bool hotspotlooked;  // is false by default
export hotspotlooked;
Title: Re: Has player looked at hotspot/object in another room.
Post by: Dualnames on Sun 22/06/2008 10:34:14
Thanks for filling in the gaps Khris. I wasn't sure if boolean variables get false by default so I decided to set it to false.
Title: Re: Has player looked at hotspot/object in another room.
Post by: RetroJay on Mon 23/06/2008 08:08:21
Oh Yes!!

This is fantastic.
Thank you all ever so much.
This is just how I needed it to work and now it works wonderfully. ;D

Can this also be done with Interact by changing "hotspotlooked" to something like (I don't know) "hotspotinteracted"?
Also can this script be used with Objects in the same way?
Once again Thank you all very much.
JAY.
Title: Re: Has player looked at hotspot/object in another room.
Post by: Khris on Mon 23/06/2008 08:23:22
Uh, wait, let me think for a moment, can this be done...? I'm not sure... hmmm.... wait, wait, wait...

OF COURSE.

And you can name your variables whatever you want (except predefined AGS functions and the like).
So if it's a lamp, you might want to use "lamp_interacted" or something similar. It's completely up to you.

Welcome to the wonderful world of variables (http://americangirlscouts.org/agswiki/index.php?title=Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics).
Title: Re: Has player looked at hotspot/object in another room.
Post by: RetroJay on Mon 23/06/2008 09:39:14
Thanks Khris.

I see it all now, some of it. ;)

Thanks again for your help.

Jay.
Title: Re: Has player looked at hotspot/object in another room. [SOLVED]
Post by: Khris on Mon 23/06/2008 14:47:48
You're welcome :)
Title: Re: Has player looked at hotspot/object in another room. [SOLVED]
Post by: RetroJay on Thu 26/06/2008 06:13:00
Hi all.

I need some more help. :(
When you script "Bools" is this how its done or am I missing something.

// main global script file

// look at hotspot in another room
bool hotspotlooked;
export hotspotlooked;

// look at object in another room
bool objectlooked;
export objectlooked;


You see the prob I have is if I just put the first two lines and test my game then it works fine.
But by adding the next two lines for my object and test my game the first two lines are ignored and only the object is recognised.
I thought I had this worked out but alas not.
Any help would be wonderful.

P.s. What I am trying to do is: I have a wardrobe in one room with two doors. Now one door doesn't open and is just a Hotspot. The other door is an Object and animates (later) to open. I want to be able to look at either door and that makes a Hotspot in another room become visible.
Thanks.
JAY.

Title: Re: Has player looked at hotspot/object in another room.
Post by: Khris on Thu 26/06/2008 09:19:31
All you've done in the snippet you posted is declare two boolean variables.
We need to see the room script(s) to tell what's wrong.

Btw, there's no way the first two lines are ignored.
Title: Re: Has player looked at hotspot/object in another room.
Post by: RetroJay on Thu 26/06/2008 12:48:29
Hi Khris.

Sorry. I think I have solved the problem.

  // script for Room: Player enters room (before fadein)
   object[0].SetView(7,0,8);
   object[3].Visible = true;
   
  // script for looking at wardrobe door hotspot in living room
if (hotspotlooked==false) {
   hotspot[1].Enabled=false;
}
if (hotspotlooked==true) {
   hotspot[1].Enabled=true;
}
  // script for looking at wardrobe door object in living room
else if (objectlooked==false) {
   hotspot[1].Enabled=false;
}
if (objectlooked==true) {
   hotspot[1].Enabled=true;
}
  // end of lookat script


See originally I had them all set to "If".
Then I thought to myself that maybe the first line of the "objectlooked" section should be "else if".
I tried it and now it seems to work just fine.
When I had them all set to "If" AGS ignored the "hotspotlooked" section and only the "objectlooked" worked for some reason.
However if you can still see something wrong or a better way then please let me know.
That should be all for now....I hope. Sorry if I've been a pain in the arse.
Thanks.
JAY.