Opening a cabinet and looking inside.

Started by freeplayer, Sun 09/03/2014 19:16:44

Previous topic - Next topic

freeplayer

Hello.

Let's say i have a cabinet, which i want my character to be able to open it up. Once he opens the cabinet, i want him to look inside.

1. The cabinet (closed). The character can look at the cabinet (maybe sayin something), and when pointing the cabinet door with the use hand he can open it.


2. After he opens it, the cabinet will look like this, (than, he can use the Eye tool to look inside):


3. After the cabinet is opened, he will use the Eye to look inside, than the imagine of the "inside cabinet" will appear on whole screen:


Later, i will add some stuff inside the cabinet, some objects (i know how to do that since i've managed to add an object in my room).

Is that achievable?

Ghost

#1
Absolutely, yes, and relatively easy.

Create an object, call it "oCabinet". Assign the sprite for the "closed" version to it. Then create a "look at" event and an "interact" event.

In the look-at event, you can check against the cabinet's graphic to trigger responses:

Code: ags

if (oCabinet.Graphic == 11) // closed graphic
{
  player.Say("It's closed but not locked. I can easily open it.");
}
else // otherwise...
{
  player.Say("Let's have a look inside...");
  // add more code to actually SHOW the cabinet now.
}


In the interact event, you can make it like this:
Code: ags

if (oCabinet.Graphic == 11) // closed graphic
{
  oCabinet.Graphic = 12 // switch to open graphic
  player.Say("Alright, it's open.");
}
else
{
  oCabinet.Graphic = 11 // switch to closed graphic  
  player.Say("And closed again.");
}


As for the close-up view, I'd create a new room, set the background graphic to the "cabinet background", and create all things to store in there as objects that are initially set to invisible. Then you can make them "appear" by setting them to visible from anywhere in your script. A "pick-up/interact command" for such an object would then use player.AddInventory() to add a new item to the player's pockets.

Khris

Of course.
In order to open the door, all you need to do is implement it as object and change its graphic.
The inside is a hotspot covered by the closed door.
For the closeup, just send the player to a new room and turn "show player character" off. This will also disable the walk cursor.

(Also, in case you aren't doing this: please use the search function first. The questions you ask have been asked and answered many many times already. The threads might not be that easy to find but most of what you ask is really trivial. The tech forums are not meant to replace the tutorial and manual, they are basically the last resort only, when you are stuck and have tried to figure it out yourself for some time.)

freeplayer

Ghost, thank you very much. Your explanations helped me do it!
I even put 2 sounds. One when door opens, and one when door closes.

Khris, thank you very much also. I made "show player charater" off and everyting is ok.

About the search function, you are right! I should use the search button more often, just i am too anxious to learn fast some new tings. Sorry.

Thank you guys.

Monsieur OUXX

Quote from: Khris on Sun 09/03/2014 21:09:19
turn "show player character" off. It disables the walking cursor.

I had no idea that option exists. I've learnt something.
 

SMF spam blocked by CleanTalk