Run a script every time a player exit's a room?
ty13r
22 May 2016, 00:30I see there's global way to run a script every time a player enter's a room.
What's the easiest way to run a global script every time a player exits a room?
I know I can add this for every room, but I have a lot of rooms and would like to do this easily in one fell swoop.
What's the easiest way to run a global script every time a player exits a room?
I know I can add this for every room, but I have a lot of rooms and would like to do this easily in one fell swoop.
HegemonKhan
22 May 2016, 03:33every time you exit a room, you're entering another room, lol. As you can't exist not within a room, lol.
so the global 'on entering room', would apply for both entering and exiting a room, as they're the same thing.
------
another way is scripting when the built-in 'parent' Object Attribute changes, via the special 'changed' Script:
create/add a Script Attribute on your 'player' Player Object and name it:
changedYOUR_ATTRIBUTE_NAME
so, for the 'parent' Object Attribute, the Script would be named:
changedparent
for a stupid example:
and then for adding its scripts, they're what occurs when the 'parent' Object Attribute changes (which occurs when you move from room to room)
------
another way is using a global Turnscript:
(this also requires using a second Attribute to store the old location)
so the global 'on entering room', would apply for both entering and exiting a room, as they're the same thing.
------
another way is scripting when the built-in 'parent' Object Attribute changes, via the special 'changed' Script:
create/add a Script Attribute on your 'player' Player Object and name it:
changedYOUR_ATTRIBUTE_NAME
so, for the 'parent' Object Attribute, the Script would be named:
changedparent
for a stupid example:
<object name="player">
<attr name="parent" type="object">room</attr>
<attr name="changedparent" type="script">
msg ("You exited a room and entered a new room")
</attr>
</object>
and then for adding its scripts, they're what occurs when the 'parent' Object Attribute changes (which occurs when you move from room to room)
------
another way is using a global Turnscript:
(this also requires using a second Attribute to store the old location)
<game name="blah">
</game>
<object name="room">
</object>
<object name="player">
<attr name="parent" type="object">room</attr>
<attr name="old_parent" type="object">room</attr>
</object>
<turnscript name="blah">
<enabled />
<script>
if (not player.parent = player.old_parent) {
player.old_parent = player.parent
msg ("You exited a room and entered a new room")
}
</script>
</turnscript>

jaynabonne
25 May 2016, 18:51Keep in mind that the default player object already has a "changedparent" script, which does things like handling the "OnEnterRoom" script calls and some map management. If you wish to use it, you'd be better off copying the default script into your game and then adding your own script, so that you don't lose the existing functionality.
HegemonKhan
25 May 2016, 18:55never realized that, thank you for the information, Jay