Macro Maker

by SqueakyReaper
A library to assist with adding macros during runtime. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://SqueakyReaper.MacroMaker##version=2

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

byond://SqueakyReaper.MacroMaker##version=2

565 downloads
Version 2
Date added: May 1 2011
Last updated: May 9 2011
2 fans
Macros can easily be defined in the .dmf file, but some times people prefer a more hands on, code-y approach. My library assists with that.

Inspired by Handy Stuff, a list of helpful libs by Forum_Account, I aimed to create my own library to handle macros. While his method is very effective, as are some of the others I've come across, I like to understand what is going on with the code. And what better way to learn and understand than to teach, yes?

This has been updated as of May 9th. Please re-read the documentation below, or the comments in the code.

Adding a Macro

The full list of modifiers is this:

client.addMacro(kKey, runProc, repeat=0, release=0, shift=0, alt=0)

Here are some samples for using it:

client.addMacro("NORTH", "jump")

This will make your mob run "jump" with no arguments when the "NORTH" (your up key) is first pressed.

client.addMacro("A", "fall+4", release=1)

This will make your mob run "fall" with a 4 argument when you release the A key. The 'release' is set to 1, which is why it's on release of the key.

You only have to put the modifier that you're going to use on 1. For example:

client.addMacro("B", "say+I released the b key while holding shift!", release=1, shift=1)

The result is evident. "repeat" is whether or not to do it while holding down the button, release is when you let go of the key, shift is while pressing shift and alt is while pressing alt.

Removing a Macro

client.removeMacro("NORTH", release=1)

This would get rid of the above macro. It clears whatever you have set there.

Misc. Notes

If you set this;

client.arrows = 0

In your code, it will turn off BYOND's standard movement code.

All things called by these macros must be verbs. Macros can't run procs, only verbs. I suggest keeping "control_freak" on (it's on by default in my library), as well as making any macro that's sensitive have this line of code in it:

set hidden = 1

This will hide it from your verb panels.

More information can be found in this post. If you have any questions, put it in the comments section and I'll do my best to assist you.

Comments

KetchupKid: (Jun 18 2011, 11:49 am)
Great job, this gave me an easy way to allow macro customization while preventing people from editing the skin with control_freak.
SqueakyReaper: (May 9 2011, 4:33 pm)
Updated the macromaker. It now supports releasing the key, holding it down, pressing while shift and pressing while alt. Not sure why I didn't put that in before...
SqueakyReaper: (May 7 2011, 2:07 pm)
I've been trying to link it to a blog post, actually. The URL is here:

http://www.byond.com/members/ SqueakyReaper?command=view_post&post=112760

Finally found the "documentation" field, so I dropped the link in there.
Stephen001: (May 7 2011, 1:25 pm)
I would love to see you develop this library further and provide some separate documentation to the current code documentation. A blog post about why people would want to use the system would also be great.

Keep it up, and thanks!