History stack - PneumatiCraft/OpenWarp GitHub Wiki

Most warp plugins provide a /back command or a close sibling - it takes you to the last place you teleported from. This is usually helpful if you warp somewhere you don't need to be, or you've forgotten exactly where you came from and need to head back without searching around. The big limitation on these commands is that they're only good for one teleport - if you're moving between three places, or you accidentally jump again, tough cookies.

But what if we extend that idea, of being able to move backwards in warps, to multiple teleports? Suddenly, you're free to warp wherever you like, with no fear of losing your way or forgetting where you were. This is the concept behind personal history stacks.

What are history stacks?

A history stack is simple - it's a list of the places you've been. It can contain warps, special places, or just somewhere you visited and decided to leave a checkpoint.

Why is it called a "stack"? Think of doing laundry - as you clean and fold clothes, you put them down one at a time, on top of each other. The next time you need a shirt, you grab it off the top of a pile. The concept of a stack is the same, and the key bit is this: the last thing on the stack is the first thing off.

Another good example of where stacks are useful in everyday life is in browsing the Web. Your back button maintains its own stack of every page you've visited in that window - as you click the back button, you take items off that stack, one at a time, until you're back at the first Web page you opened.

How do they work with OpenWarp?

Every player gets their very own personal history stack. Nobody else can see items on your stack, and you can't see anyone else's - it's just for you. When you log in to a server running OpenWarp, your stack is empty.

Using the stack is a matter of first pushing places onto the stack, so they're stored - in reverse chronological order - for later. Then, when you want to revisit them, you can pop those places back off the stack. Every pop takes the topmost location off your stack and moves you there, removing it from your stack when you're done. (If you don't want to remove that place from your stack, that's OK - just peek instead of pop.)

At any time, you can print your stack to your chat window. This lets you know what places you have on your stack right now, and the last one printed is the first one you'll go to.

What commands do I use?

To push the place you're standing onto your stack, in effect leaving a checkpoint where you are, use /warp stack push. You can also push warps on the stack, if you have them defined. Just add the name of the warp: /warp stack push {NAME}.

To go back to the topmost place on your stack (popping it), run /warp stack pop. To peek instead of pop, leaving the last place on the stack, use /warp stack peek instead.

And of course, showing your current stack is as easy as typing /warp stack print.

For more detail, see the command reference.