Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: spike2k8 on Sun 24/05/2020 01:18:04

Title: looking at objects before interaction
Post by: spike2k8 on Sun 24/05/2020 01:18:04
hi there. now, im totally new to this. im doing a simple little game. no real story, as i just want to get used to the scripting and placing of hotspots and objects. i have managed to create 4 rooms and can get to and from each 1 fine. i can look/interact etc with hotspots/objects and pick objects up.  what i cant get my head around is what to to put in the script to get character to look at object before interacting with it. basically i have a ship with a closed panel housing a circuit board. i can open panel and take board with looking then interacting or i can just interact and do it without. i have got meself confused searching thru posts on here and cant seem to find what im looking for. can some1 either point me in right direction or explain what i need to input in my script.

many thanks
Title: Re: looking at objects before interaction
Post by: Sedgemire on Sun 24/05/2020 05:10:19
You could declare a boolean variable in the beginning of the room script:

Code (ags) Select
bool LookedPanel = false;

After the script what happens after you look at the panel, enter:

Code (ags) Select
LookedPanel = true;

Then check in the interaction command script, whether the variable checks as true or false:

Code (ags) Select
if (LookedPanel == true) {
//Your script if player looked at panel before
} else {
// Your script if player didn’t look
}
Title: Re: looking at objects before interaction
Post by: spike2k8 on Sun 24/05/2020 12:55:35
perfect thank you. slowly getting there. had to do a few tweaks but with some trial and error i managed to get it how i wanted it. didnt help when i wanted to make a copy of my entire script, in case i messed it up, and instead of copying i hit delete. thank you again for ur help.
Title: Re: looking at objects before interaction
Post by: Sedgemire on Sun 24/05/2020 18:53:54
No problem, have a great time designing your game!