The easy extensibility allows any programmer to create things such as buttons, springs, pushable blocks, and much more. I'd like to take some time to demonstrate how easy it is to create those three things.
First and foremost, I defined a /mob/mechanism type to act as a parent to all such interactable objects. This means I have to do:
And voila, I can bump into them!
Now, I also defined a /mob/player subtype, for the actual players. I wanted to make sure players could bump into boxes and make them move. The movement itself is not all that smooth, in my opinion, and that could be improved. However, the basic 'push and move' is not difficult either:
var/mob/m = a
It's probably not that smooth because I'm forcing it to use pixel_move, instead of something else. I'm still re-learning how to use the library myself.
That's all that goes into pushing objects!
Springs themselves are a bit more interesting, because they have to operate in two parts (at least, the way I set them up, they do). The actual spring is a 32x32 block which is stepped on, and there's a non-dense block right above it which does the actual 'spring' animation. Here's a larger chunk of code for springs:
//these can't be dense, otherwise the player will bump into them
//these need to have a pheight of at least 1, though.
//boost is just how much of a velocity boost you get by stepping on one
var/boost = 15
//if this return isn't here, you see the spring bouncing on itself, so to speak
//this handles making the top spring flick it's animation
spawn for(var/atom/o in top(5))
//I initially wanted to make it reverse your vel_y, but I found that wasn't always a good solution
if(m.vel_y && m.vel_y < 0)
m.vel_y = -m.vel_y
//so it has a default value to change your vel_y to, too
m.vel_y = boost
I hope the comments help. I'm still working on the whole 'being descriptive' part.
The last thing I wanted to discuss was buttons. Firstly, I defined a separate type for this, linkable, along with a few useful members:
Next, I wanted to make sure I didn't have to do a lot of work to make two objects linkable. It means the map has to be played with a bit more, but that's alright with me. I simply overrode New():
for(var/mob/mechanism/linkable/o in world)
if(o!=src && o.linked == linked)
o.linked = src
linked = o
Now, you'll notice it looks for two identical linked vars. This means they can be initially set to anything, and they will adjust themselves upon being created.
A recent change to the library was modifying how stepped_on works, and adding stepping and stepped_off. This helped my implementing of buttons by a lot, as you can see here:
It just activates and deactivates whatever it may be linked to at the time. Really, it's that easy. All you need to do is define another subtype of /mob/mechanism/linkable, set it's activate() and deactivate() procs, and all is well!
Hopefully this helps others see just how easy this library is to work with, and perhaps encourage some new developers to try it out!