Unlock interaction.

Started by Theyeyboss, Fri 24/02/2017 18:25:20

Previous topic - Next topic

Theyeyboss

Hello. I need help to solve my problem. I've tried looking for a solution to this problem but I have found none. Basically, the player needs to go to bed, but before he can do that, he needs to talk to another character, but only after talking to that character. It's hard to explain, but basically, if the player doesn't talk to the other character, when he clicks the bed, he says he needs to talk to the other character first. After talking to the other character, when the player clicks the bed the room changes. How do I do that?

Cassiebsg

Create a global bool variable called talkedToCharacter, set it to false. Once you talk to the character, add talkedToCharacter=true;

Then find your your bed code, and add
Code: ags

if (talkedToCharacter) // if he has talked to the character
{
    // sleep code
}
else  // else he has not talked to the character
{
    // he says he needs to talk to the other character first code
}
There are those who believe that life here began out there...

Theyeyboss

But what do I do if the bed is a hotspot? (Sorry for being a noob, but I forgot to include that detail in the original post).

Slasher

#3
Quote from: Theyeyboss on Fri 24/02/2017 19:23:08
But what do I do if the bed is a hotspot? (Sorry for being a noob, but I forgot to include that detail in the original post).

Just add it to the bed Hotspot properties.

When you try to get in it..

Code: ags

function hHotspot3_Interact() // Bed hotspot's name
{
 if (talkedToCharacter) // if he has talked to the character
{
    // sleep code
}
else  // else he has not talked to the character
{
    // he says he needs to talk to the other character first code
}
}



Khris

Theyeyboss, nothing in the explanation you got changes depending on what kind of game object the bed is.

The extremely common and basic beginner's problem you have is solved by using a variable. This variable is tested in whatever the interaction happens to be you want to have different outcomes depending on the variable's value.

Cassiebsg's code goes into the event's function, whether the bed is a hotspot or not, just like with any other interaction.

I'll repeat the code, this time with proper indentation:
Code: ags
function hBed_Interact()
{
  if (talkedToCharacter)
  {
    // sleep commands
  }
  else
  {
    Display("I have to talk to X first.");
  }
} 


(I would also ask all tech support posters TO DO THE SAME.)

SMF spam blocked by CleanTalk