Opening doors

Lennart
03 Nov 2014, 14:02
Hi all,
I'm new to this and I only have a question about doors. If I create a door object in my room and I want to open it, everything works fine.
But if I open it again, (while it's open) my player opens the door again instead of saying: "but the door is already open". What do I do wrong?

Silver
03 Nov 2014, 15:17
You need to set a flag on the door. So opening a door will check for the flag first then say you open the door (this is where you set a flag which you could call 'door open') then set the else to print 'but the door is already open'.

Then you'd need to remove the flag with 'close door'.

Silver
03 Nov 2014, 15:19
I've probably explained that really badly cos on phone. Look at the tutorial on flags (bob and the defibrillator).

http://docs.textadventures.co.uk/quest/ ... jects.html

Lennart
04 Nov 2014, 19:57
Thanks for your reply! I already tried flags... and I did it again. As you can see on my screenshot, everything must be ok if I open the door.
But when I open the door in the game it says "it's already open!"

opendoor.jpg

jaynabonne
04 Nov 2014, 20:37
Unfortunately, there already is an existing attribute on your door called "open", which is used by Quest to signify it can be opened (not the best name, but...). In your case, since it can be opened, that flag is set to true.

Call your flag something else (e.g. "isopen"), and it should work fine.

Silver
04 Nov 2014, 22:23
I didn't realise that you'd made your door a container. That kind of confuses the issue.

Lennart
05 Nov 2014, 13:59
Thanks for your help silver! I didn't realise there was already an attribute called "open".
I've made my door a container because I didn't know what else to do. Are there easier ways?

Silver
05 Nov 2014, 14:50
Well if (for example) you want a door that leads to another room you could create an object (or scenery object if you want to describe it yourself in the room description) and then add a verb called 'open' to it. Click on the verb and choose run script.

Select an If script it would be something like:
If door has flag 'dooropen' then print msg 'the door is already open'.

Else set flag 'dooropen' to object door
Print msg 'you pull the door and it slowly creeps open'
(Then you would also have to add how you would want the game world to change such as create an exit or make an exit visible).

Then you need to create a verb in the door object called close and do it all again.

If door has flag 'dooropen' print msg 'you push hard against the door and it creaks closed'
Unset flag 'dooropen' from object door
(Then do the opposite as before such as make exit invisible etc)

Else print msg 'the door is already closed'
____________________

That's the best I can explain it ATM as posting from tablet at work but if you're still struggling I'll make a small test game or something later.

Pertex
05 Nov 2014, 15:27
Silver wrote:Well if (for example) you want a door that leads to another room you could create an object (or scenery object if you want to describe it yourself in the room description) and then add a verb called 'open' to it. Click on the verb and choose run script.


You can't add the verb 'open' to an object which is not a container. But perhaps you coud add a command 'open door' and 'close door' to the room of the door

Silver
05 Nov 2014, 15:42
Oh right I didn't know that. Then yeah do what Pertex suggests then highlight the commands and add the script I suggested.

Silver
05 Nov 2014, 15:45
I'm sure I didn't get these issues when working with a container. Need to check when I get home.

jaynabonne
05 Nov 2014, 17:25
A discovery (for me): when I suggested to use "isopen" for your attribute name, it didn't even occur to me that there already was an attribute used to signify that a container is open - and that it already is named "isopen". It turns out that if you have the open script for the door set "isopen" to true, then Quest will automatically print out "It is already open" if you try to open it again. You don't need to put in logic to test for it being open yourself.

So: just set "isopen" to true in your open script and to false in your close script, and you'll get the built-in messages with no additional logic needed.

Silver
05 Nov 2014, 17:50
For some reason I thought Quest already did that with containers. But if not, yes with jay's code tweak I can't see any reason why you can't use a container as a door.