pokemon escape rope?

How do I make an item like the "escape rope" in pokemon.  If you're in a dungeon you just use it and go to the entrance.
This is really simple to do. All you need really is variable. Give each dungeon a numerical id (dungeon #1 = variable id of 1 ect.) and have it to where on the entrance transfer event to each dungeon you change the variable to == that of the dungeon you are entering. Then you have your item call a common event that runs through a list of conditional branches to get the variable's worth and transfer the player accordingly to whatever dungeon he/she is currently in. Make sure on all transfer events that exit the dungeon you set the variable to 0 or something unique so that you can't teleport from not in a dungeon to the last dungeon you visited, maybe make the conditional value for that say you cannot use it here and add 1 of said item back to inventory so that you won't waste it on accident.
That sounds pretty confusing..

I'll try that out, thanks!
^The only really confusing part about it is remembering which dungeon each value is = to, and for that there are spreadsheets.

Original thread: https://forums.rpgmakerweb.com/threads/pokemon-escape-rope.25052/