The Swiss Army library: sd_procs

A review for sd_procs created by Shadowdarke

For a lot of your games, you'll often find yourself needing the same code over and over. When Shadowdarke found he was running into the same needs in many projects, he created the sd_procs library. There's a lot of variety in here covering all kinds of common needs, so this one library you absolutely have to have in your arsenal.

Atom actions: The library defines two procs that are highly useful for when atoms move around: Bumped() and Trigger(). The Bumped() proc is like the flip side of Bump(). Whereas the Bump() proc belongs to the moving object, Bumped() belongs to the obstacle. If you have a special wall button that can be toggled by a player bumping into it or a projectile hitting it, you only have to set up a Bumped() proc for the button. The Trigger() proc is called whenever something steps onto a turf--very useful for traps and floor switches.

Base 64: There are other base 64 converters out there, but this one's pretty useful if you want to convert not only to and from regular text, but to and from hexadecimal numbers.

Color: The library defines a special datum called sd_color that can keep track of colors not only individually by red, green, and blue components (sorry, no alpha), but also by the color's HTML code and a solid icon of that color. Several procs for the datum can give you useful information as well, and you can get a color's brightness.

Direction procs: The procs in this part of the library are real workhorses you'll want somewhere for sure. The most useful bit is that you can find an approximate direction between two atoms, so if another atom is far to the north of you but just a little bit to the east, sd_get_approx_dir() will tell you the other atom is NORTH while get_dir() would only tell you NORTHEAST. Other functions include converting a direction to and from angular degrees, radians, or a radial value of 0 to 7.

HSL procs: This is for converting colors to and from RGB format to one that uses hues, but you might not find it the most useful part of the library. The hue range is 0 to 240, so converting from RGB to HSL and back you may see a subtle difference.

Math procs: Only a few math procs are included here, but they're good ones. You can convert numbers from decimal to any base from 2 to 36, and back. Also there's sd_get_dist() and sd_get_dist_squared(), which give real, accurate distances between two atoms--even on different Z levels.

Nybble color procs: You can use this to work with a smaller range of colors from 0 to 15, which you could use for instance to pack information about several colors into a single number. This is also useful in that if you change a color to nybble form and back to RGB, you'll know which color it's closest to.

Text procs: A handful of very useful text manipulation procs are in this section. sd_findlast() and sd_findLast() work like findtext() and findText(), but they start at the end and work backwards. sd_html_remove() filters out unwanted HTML. sd_replacetext() and sd_replaceText() can replace your search text with something else.

The library includes a test program and a list of sample sd_color datums that you can use, though neither of them are included in your projects.

A lot of useful stuff is packed in here--too much to go into every proc in depth. These procs can come in handy in just about any kind of game, and even in chat programs and MUDs. If you're a beginner, they'll save you all kinds of time and may even give you some ideas to do things you hadn't thought of before. For more advanced users, this is a nice one-click way to get a lot of basic functionality into any new project before writing even a single line of code.

Posted by Lummox JR on Friday, June 26, 2009 03:53PM - 2 comments / Members say: yea +3, nay -0

« Add to the action with s_damage · Second HUD: BYOND's newest feature demystified »

Login to post a comment.

#2 Foomer:  

Someone should come up with a set of libraries that every new developer should include with their projects.

Kind of like when you reinstall Windows, there are certain programs you might want to install right away, such as Adobe Reader or FLASH Player. Not that everyone uses them, but having them installed right off the bat saves you the trouble of having to download them later when you find you need to open a PDF or run FLASH.

Thursday, August 13, 2009 12:12AM

#1 Haywire:  

As useful as this is, and trust me it's very useful, I think developers these days have a tendancy to write their own personal 'procedure libraries', I've written multiple libraries for my personal use when writing programs/games, and really this is a great set of procedures.

Anyway, this is an awesome library, clearly a helpful one.

Saturday, June 27, 2009 02:59AM

 

 

Programming Help

Get Started - A quick overview of the tools available for learning to program in BYOND.

DM Guide - This is the first place you should look if you're new to BYOND's language DM. Some people call this the "blue book".

ZBT parts 1, 2, & 3 - Zilal's excellent tutorial series, teaching you the basics of how to get started writing games in BYOND.

Your First World and Step BYOND - Sample games that you can study to help you learn.

DM Reference - Handy for novice users and advanced programmers alike, this documents everything you need to know about the DM language.

Skin Reference - If you want to give your game a custom interface, this tells you what you can do with "skins" and how to work with them.

BYOND Resources - Demos and libraries you can download to help you with your creation.

Publishing Games

Publishing Games - A guide for putting your creations on the BYOND hub to share with others.

Recording Videos - If you want to find out how to make a video of your game and put it on YouTube or another site, this can get you started.

Keywords