Object On Hotspots like doors

Started by , Sat 14/10/2006 10:53:51

Previous topic - Next topic

gilp

Hi!I'm New In this,so I need help from anyone.
I have a key(object number 1).
And a room with hotspot named door.
How can I make the key works on the door,i mean open the door and closed it.
I need a precise guide to do this in AGS version 2.72.
Thank You Very Much!!!

Mel_O_Die

Hi!

For that, first select your door hotspot in the areas room editor and click on "interaction" button

right click on "use inventory on hotspot" and select "new run script action"


Code: ags

if (player.ActiveInventory == inventory[x])Ã,  Ã, {Ã, 
 // x is the number of the key in "inventory item", this line will check if the key item is used on the door

Ã,  Ã,  if (object[n].Visible== true)Ã,  {Ã,  
Ã,  Ã,  // here is a nested condition for check if the door is opened or closed, n is the number of the object corresponding at the closed door in object room editor (you need to create the door separately and put in as an object in the room and have your door already opened in the background you have importated (this is for a door that opens outside))


Ã,  Ã,  object[n].Visible = false;Ã,  Ã,  
Ã,  Ã,  // if the door is visible and key used on it, so close the door

Ã,  Ã,  }

else object[n].Visible = true;Ã,  
// else, close the door


}


hope that will helps you! (and sorry for my poor englishÃ,  :-\
----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

Cinfa

Quote from: Mel_O_Die on Sat 14/10/2006 18:50:31
Code: ags

if (player.ActiveInventory == inventory[x])   { 
 // x is the number of the key in "inventory item", this line will check if the key item is used on the door

That code helped me too, thanks! But maybe there's a small error, it works with:
Code: ags

if (player.ActiveInventory == iITEMNAME)   { 

Mel_O_Die

#3
happy for helping you :)

and it's not an error, but just an other way to do the same thing :)

it's the same with object[ x ] who works exactly like oOBJECTNAME

you can do that in your prefered way :)

----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

gilp

The Code You Gave Me Is Must Be Right, but how can I
Change the door from being closed to being open.
I Mean that I want the player to see that when he use the key on door the door will be opened and the player will see  the open door.

Candall

You can do this by changing the object's graphic number to a different sprite slot.  For instance:

Code: ags

oDoor.Graphic=25;


Obviously, the "25" is just for example.

Ashen

Merged topics. Gilp, please DON'T start a new topic, when you've already asked the question somewhere else.

There're two methods here - either remove the opject from the room as Mel_O_Die has or change its Graphic as Candall suggests, and the basic code is similar for both (toggle between the 'Open' and 'Closed' graphics with Object.Graphic instead of using Object.Visible).
I know what you're thinking ... Don't think that.

gilp

Thanks You For Your Great Help!
Now I Need A Little More Help.
After I Open The Door And The Graphic Image Changes To A Open Door , How I Make The Player Enter To The Next Room By Passing The Open Door?

Khris

Why didn't you post this in the old thread?

Look up regions and walkable areas in the manual, do the tutorial, search the forums.
If you absolutely can't find any pointers on how to achieve this (really simple thing), then we'll help you here.

But you have to learn to figure out things like that yourself; if you can't, maybe AGS isn't exactly the right tool for you.

gilp

It Isn't As Easy as you think and no you are wrong I Can handle with AGS perfect.
Maybe You Just Don't Know The answer.

Khris

You got me there. I have absolutely no clue how to draw a region on the "behind the door"-part of the walkable area, then click on interactions and add a "Go to a different room at specific coordinates"-action to the "player walks on region"-interaction or the scripting equivalent "player.ChangeRoom(...);" to a RunScript-interaction.

Maybe you can enlighten me, since you can "handle with AGS perfect"?
Oh, wait...

Ashen

#11
Topics merged. gilp, once again there was NO NEED to start a new topic for this question, as KhrisMUC said.

You may get more useful replies if you're clearer about what exactly you're asking. Do you want the player to automatically walk through the door and into the new roomm, when it opens? Or do you just want them to be ABLE TO walk through, after it is? If it's the second, Khris' original advice should point you in the right direction, and his second post should get you even nearer - despite the unnecessary sarcasm. Although it should be noted, he actually missed out the part were you need to disable and enable the walkable area behind the door, so you can't use it BEFORE the door opens. Check the Manual (or read through all the Interaction Editor commands, if you're using them) for how.
I know what you're thinking ... Don't think that.

gilp

Thanks For Your Help.
Now To finish the door section I need help.
this is very confusing.
I Have Hotspot named closed door.
I have 3 objects:object 0 is the key.
object 1 is a open door image.
object 2 is a closed door image (both are'nt initially visible)
when I use the key on the closed door(hotspot) at the
first time it is opened and at the second time it is closed.
But the problem is that when the door is opened I can't
Display a message that Now it is open and likewise when the door is closed.

Ashen

Topics merged. Again.
gilp, for the THIRD time - There is no need to start a new topic, when an existing and fairly recent one will do. This question is still about getting your door to work, so it should've gone in your previous thread.

What code are you currently using? We need to see what you've got, to be able to tell you how to change it. Assuming you're using something like Mel-O-Die's code from a few posts back, it should already be able to open or close the door on alternate uses - that bit works, right? You just need to change it to display a message?. READ THE MANUAL. The Display or Character.say commands should do what you want. If you need to know exactly what to do with them - again, it'd help to know exactly what you've got so far.
I know what you're thinking ... Don't think that.

gilp

First of all It Won't Happen Aggain.
Now,For The Object 1:opened door i use the interact object- run script:oDoor.Graphic=26;   
And use Inventory On Object-run Script:

if (player.ActiveInventory == inventory[1])   {
// x is the number of the key in "inventory item", this line will check if the key item is used on the door

    if (object[2].Visible== true)  { 
    // here is a nested condition for check if the door is opened or closed, n is the number of the object corresponding at the closed door in object room editor (you need to create the door separately and put in as an object in the room and have your door already opened in the background you have importated (this is for a door that opens outside))


    object[2].Visible = false;   
    // if the door is visible and key used on it, so close the door

    }

else object[2].Visible = true; 
// else, open the door

}

For The Object 2:Closed Door I use The Same Thing Just diffrent numbers doorgraphic=25 and object(1).

For The Hotspot:Closed Door I use Inventory on object-
run script:
if (player.ActiveInventory == inventory[1])   {
// x is the number of the key in "inventory item", this line will check if the key item is used on the door

    if (object[2].Visible== true)  { 
    // here is a nested condition for check if the door is opened or closed, n is the number of the object corresponding at the closed door in object room editor (you need to create the door separately and put in as an object in the room and have your door already opened in the background you have importated (this is for a door that opens outside))


    object[2].Visible = false;   
    // if the door is visible and key used on it, so close the door

    }

else object[1].Visible = true; 
// else, close the door


}

  and one more run script with 2,1,2 (this order).







SMF spam blocked by CleanTalk