This library aims to provide handy things. These handy things can either simplify BYOND's built-in features or introduce new features.
Version 6 is a rather minor update, just a bug fix and some comments added to the code, no huge changes in functionality.
• Fixed some bugs with the icon procs. They should now work properly for icons of any size. (Thanks MyNameIsSylar for pointing this problem and suggesting the fix!)
• Made a slight change to the return value of the icon procs, if an icon_state is specified then the icon returned contains a single, unnamed state. This lets you do things like: mob.icon = Icon.Rotate('icon.dmi', "mob", 20)
, Previously you'd have to also set the mob's icon_state to "mob".
• Added comments to the library code and demo. Most notably, each file has a comment at the top to explain its contents. Even if you don't care about how the code works, this info is good to know.
• Added support for client mouse procs in mouse.dm.
• Updated icon procs (Fade and Rotate) to work for icons of any size, not just 32x32.
• Changed the way that keyboard events are handled. Previously it used pre-defined macros in keyboard.dmf. Now it dynamically adds macros at runtime.
• keyboard.dmf is now only needed for the demo and was moved to the demo/ folder and renamed "demo.dmf".
The library contains two icon procs: Fade and Rotate.
hat = new /Overlay(src, 'hat.dmi')
hat.Layer(MOB_LAYER + 2)
The Rotate proc can take just an icon or an icon and icon_state as arguments. When passed only an icon it rotates all states in the icon. In this example it rotates all states so that as the mob's state changes the hat overlay has corresponding rotated states.
Create keyboard macros without editing the .dmf file!
// to handle the events
if(k == "a")
src << "You pressed A"
else if(k == "B" && M == RELEASE)
src << "You released B"
This calls the mob's macro proc (which is defined by the library) when the user presses the A key or releases the B key.
This library provides an easier way to deal with overlays and also provides some new functionality. For example:
coat = new /Overlay(src, 'icons.dmi', "blue coat")
// much later in the code
By storing a reference to the Overlay object we can change the overlays properties later on.
The Overlay object also has a Flick proc which can be used to animate individual overlays.
BYOND's mouse procs (Click, MouseEntered, MouseUp, etc.) give you a parameter string that looks like this: "icon-x=5;icon-y=7;left=1;screen-loc=9:5,9:7". The library also handles the parsing of these parameters.
Here is how you would create an object exactly where you clicked using the library and not using it:
// Without the library
Click(location, control, params)
var/list/params_list = params2list(params)
// With the library
e = ..()
new /obj/marker(e.location, e.icon_x, e.icon_y)
The library also defines two global objects called "Text" and "String" which contain many of the built-in string functions (copytext, findtext, etc.) and some new ones. The demo includes a Test_Text verb which shows how to use the text procs.