I was curious to see if I could hook an event to the point when the player selects one of the exits...and yay I found it!
Then it took me a while searching this forum to figure out how to do it.
Now, if someone else knows how to do it it means one of two things!
For example, what should I do if I encounter this situation again and I need to find more info about scripts such as onexit
, like what would this
refer to, who do the parameters do in the buit-in internal functions and so on..
PS. I still haven't figured out on-exit! How do I make it "blocking"? What I want to do is to perform a certain check and if the check fails inform the player that they failed to exit and basically prevent the exiting. I guess I could just trick this thing into the needed behavior somehow with other scripts, but anyway some docs on these functions would really help!
PPS. It would be great if there was a build in search option in http://docs.textadventures.co.uk/quest ! I use google's "site:http://docs.textadventures.co.uk/quest onexit" command whenever I need to do something, but it's not very comfortable and not everyone will figure it out..
http://docs.textadventures.co.uk/quest/attributes.html
http://docs.textadventures.co.uk/quest/attributes/onexit.html
You can set up a script on the exit.
This one just moves the player through the exit, but you could add whatever you like to the script:
Example
If you had a Boolean attribute named "readytoleave" set on the player object, you could do this:
if(not game.pov.readytoleave){
msg("You can''t leave yet. There is something you must do first!")
}
else{
MoveObject(game.pov,this.to)
}
There's a search on the main documents page, too (but it works just like your method):
http://docs.textadventures.co.uk/quest/#Search
Oh thanks, I didn't notice the search field at the bottom! Still faster than what I was doing before!
When took over Quest nearly a year ago, updating the docs was one of the things I wanted to do. It is happening, but slowly. This is something that has not come up on the forums before and I have not had an issue with, so has not been addressed yet. I am not too sure where I would add it, to be honest...
The onexit
script is attached to a room, and fire when you leave the room. Moving the player in any of the the room scripts is a bad idea, because Quest is already part way through the move when they fire, and it gets messy. As KV says, it is better to block the player on the exits.