Has player looked at hotspot/object in another room. (SOLVED).

Started by RetroJay, Fri 20/06/2008 22:11:32

Previous topic - Next topic

RetroJay

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.

Dualnames

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);
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

RetroJay

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.

TwinMoon

#3
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.

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

RetroJay

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.

Khris

Don't forget to import and export the variable; otherwise it won't be visible to the room script:
Code: ags
// script header 
import bool hotspotlooked;

// global script

bool hotspotlooked;  // is false by default
export hotspotlooked;

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

RetroJay

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.

Khris

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.

RetroJay

Thanks Khris.

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

Thanks again for your help.

Jay.


RetroJay

Hi all.

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

Code: ags
// 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.


Khris

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.

RetroJay

Hi Khris.

Sorry. I think I have solved the problem.
Code: ags

  // 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.

SMF spam blocked by CleanTalk