Warps

by Forum_account
An easy way to create tiles that warp mobs to another location. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Forum_account.Warps##version=2

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Forum_account.Warps##version=2

364 downloads
Version 2
Date added: Feb 10 2012
Last updated: Feb 25 2012
6 fans
The library defines the /warp type which you can use to create warps. All you have to do is define a sub-type of /warp (ex: /warp/warp_01), open the map editor, and place the warp on two tiles. When you run the game, the player will be teleported from one tile to the other when they step on the warp.

The library is simple but can be used in more complex ways. It comes with five demos that show how to use it in different ways. The demos are:
  • conditional-warp-demo - Shows how to create a warp that only works if the mob using it meets certain criteria. Also shows how to create a warp with two destinations that picks a destination based on the mob using the warp.
  • one-way-demo - Shows how to create warps that only work in one direction.
  • simple-demo - Shows the basic usage of the library - creating pairs of turfs that teleport the player back and forth when stepped on.
  • transition-demo - Shows how to implement a simple fade in/out transition when a warp is used.
  • warp-function-demo - Shows how to customize multi-tile warps by overriding the warp_function proc.

Version History

Version 2 (posted 02-14-2012)
  • Added support for multi-tile warp areas. By default, the library will group all adjacent turfs in the same warp area and treat them as a single entrance/exit point. If you place the same warp area on both sides of a three tile wide doorway, the library will treat each group of three turfs as a single group and will know to move objects to the other group.
  • Added partition.dm which contains the warp.partition() proc. This proc is used to split the turfs in a warp into disjoint sets, which is needed for multi-tile warps.
  • Updated the default behavior of destination(). If the warp has a target type defined, it finds a turf in that area. If it contains two turfs, it returns the one the object isn't on. Otherwise, it calls warp_function().
  • Added the warp.warp_function() proc. By default, this proc partitions the turfs and defines the destination to be the first turf found in a different set.
  • Updated the simple-demo to include a multi-tile warp and icons for the warp areas.
  • Added the warp-function-demo which shows how to modify warps by overriding their warp_function proc.
  • Added the transition-demo which shows how to create transitions between screens.
  • Removed the advanced-demo and door-demo.
Version 1 (posted 02-11-2012)
  • Initial version.

Comments

LordAndrew: (Feb 16 2012, 9:45 am)
I tried that but it didn't work at first, but then I realized I already had a ..() going on for non-mobs, whoops. Thanks!
Forum_account: (Feb 14 2012, 2:57 pm)
You can override the warp's warp() proc to check the type of the object its warping:

warp
warp(mob/m)
if(istype(m))
..()
LordAndrew: (Feb 14 2012, 1:27 pm)
Hrm. I have a door on top of one of my warps and when I open it, when it closes again it ends up getting warped. Not sure how to stop that.
LordAndrew: (Feb 14 2012, 12:06 pm)
The town's just one tile. The red tile in the first and last screenshots is a locked warp turf that is basically used to be where the red exit perimeter in the town sends the player.

e: The code you posted does exactly what I was doing but with a lot less effort. Thank you!
Forum_account: (Feb 14 2012, 11:54 am)
Yep, you can easily handle that. I'm not sure what the red spot is on the first and last screenshots. Is the town shown as two tiles? Or is it just the blue tile?

warp
town_01
// place this around the perimeter of the town
exit
target = /warp/town_01/outside

// place this on the town on the overworld map
outside
target = /warp/town_01/inside

// place this inside the town where you want players to be moved to
inside
warp()

The /warp/town_01/inside type only exists to be a target. We override its warp() proc to make it not do anything when we step on it.

Placing three areas on the map is certainly easier than editing turf instances in the map editor =)