Autojoining

by Foomer
[Share] [Zip]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Foomer.Autojoining##version=2

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

byond://Foomer.Autojoining##version=2

354 downloads
Version 2
Date added: Aug 5 2009
Last updated: Aug 27 2009
6 fans
A library that makes it easy to create autojoining turfs or objects using 13, 16 or 47 states. [More]
The purpose of this library is to make it easy to autojoin tiles using 13, 16 and 47-state autojoining. Most everything is already setup for you when you include the library, all you really need to do is decide which turf types are going to be joined and in what way.

NOTE: This library is intended for STATIC objects, such as terrain or decorations, NOT for things that will be moving around, like blobs.

Each atom gets a new variable called 'autojoin', which can be set to either 13, 16 or 47 depending on the kind of joining that you want for that object.

turf/cave_walls
    icon = 'cave_walls.dmi'
    icon_state = "13"
    autojoin = 13

Aside from that, all that's left is to determine what each object wants to join to. Do they join with the edge of the map? Do they join to other objects of their own type? Do they join to objects with a specific attribute? You can decide what each object joins to by overriding the atom.JoinMatch(direction) function, like this:

turf/river
    icon_state = "river.dmi"
    icon_state = "16"
    autojoin = 16

    JoinMatch(direction)
        var/step = get_step(src, direction)

        // Return 1 if you want to join with the edge.
        if(!step)
            return 1

        // Do you want to join with turfs of same type?
        if(step.type == src.type)
            return 1

        // Join with other turfs using the 'water' attribute.
        if(findtext(step.attributes, "water"))
            return 1

        // Don't join with anything.
        return 0

You can also view Autojoining.dm to see how the default JoinMatch function is arranged.

Once you've decided which objects will be autojoining and which other objects they'll be joining to, then you're all set and the library will take care of the rest.

Advertisement

Comments

MDC: (Mar 28 2013, 12:22 pm)
Download link is broken Q_Q
FIREking: (Jan 3 2012, 2:41 pm)
Thanks for this, Foomer.
Ganing: (Sep 15 2011, 8:50 pm)
Very interesting!
Foomer: (Aug 26 2009, 10:31 pm)
Okay, here's an example. Suppose you have the map setup using 13-state tiles. The player only sees a wall of rock, and cannot tell that there is actually a secret passage leading to a cave on the other side. This necessitates 2x2 sections, which are joined automatically.

http://files.byondhome.com/Foomer/libraries/ 13state_example.png

In that screen shot, what the player sees is on left, and what's actually there is on the right. If the tiles were not used in 2x2 sections, then the player would be able to discern from the icon states that there's an open area on the other side of the wall.
Foomer: (Aug 26 2009, 10:25 pm)
That's in the nature of how 13-state autojoining works. It needs to be done in 2x2 clumps that never join by the corners. This is mostly designed for use in games that have opacity and you don't want players to be able to see what's on the other side of the autojoining wall.