Leave room scripts

codingmasters
30 Oct 2003, 19:16
On many ocasions in my new game, I have needed a Leave room script. To compensate, I have had to make do with a script exit in the rooms where I need a leave room script. How it would work:

The leave script would be under the Scipts tag in the room properties. Under the compass tag, when you wanted to make a script exit, you could have a checkbox that made it override the leave room script!

How many great ideas have I come up with?!

Matthew G.

GameBoy
31 Oct 2003, 02:38
im not following. if you want a script to run when u leave the room, made a script setup from the compass control, do your script, and have it so it just goes to the room <direction> after the script is done

codingmasters
31 Oct 2003, 05:43
That can be done, but it's a pain to have to write a script for each one when you might have multiple exits

Matthew G.

paul_one
31 Oct 2003, 12:15
Why not have it go through an exitroomname procedure?
Then just have the procedure go through if's to sort out the direction and where to move the player.

Alex
31 Oct 2003, 13:28
I think I've covered this before, but one way to do an "exit room" script is:

1. In your game start script, set a string variable called "prevroom" (or whatever you want) to nothing.
2. Set up an afterturn script for the game
3. Check whether "prevroom" contains the name of the room you want the "exit room" script for.
4. If it does, check whether #quest.currentroom# is different to #prevroom#. If it is, then the player has left that room, so do whatever script you want.
5. Store #quest.currentroom# in the "prevroom" string, ready for the next time the afterturn script runs.

Here's some ASL code to do the above. For QDK, try and work it out from the above instructions or paste this in using a text editor:

In your define game block:

startscript set string <prevroom; >

afterturn {
if ( #prevroom# = ENTER NAME OF THE ROOM PLAYER LEAVES HERE ) then {
if ( #prevroom# <> #quest.currentroom# ) then {
' ENTER SCRIPT TO RUN HERE
}
}
set <prevroom; #quest.currentroom#>
}

paul_one
31 Oct 2003, 14:33
That get's a bit tiring after writing 50:
else {
if (#prevroom# = roomname) then {
code
}
else {
if (

codingmasters
31 Oct 2003, 22:20
Thanks, but I don't hand code ASL. I'll try and work it out from the above instructions, and hopefully it should work.

But a Leave Room script wouldn't hurt would it Alex?

Matthew G.

Alex
01 Nov 2003, 04:30


That get's a bit tiring after writing 50:



You could adapt that example and get it to use an action instead perhaps - then you could set up the script in the room definition and not have a massive afterturn script.

paul_one
01 Nov 2003, 11:51
Actually Alex that's quite nice!

I like that idea, nice, simple, compact. I can't believe I didn't think of it since I'm all for room actions, love 'em!