Action Control

by Polatrite
A 100% reliable library to better control player actions requiring delays, or just about any other delay action you might need to do.
ID:131125
 
/* Action Control by Polatrite -- 1.3
   http://developer.byond.com/hub/Polatrite/ActionControl

   The scoop:
   This is the one-stop library to control actions. An action, in this context, is any
   proceedure that needs to control time-delayed proceedures with a variable. An example
   would be the game Proelium by SilkWizard. Actions are used in that game when firing
   a rocket, recharging mana, spawning a wolf, and many other tasks. When a player is
   performing an action, they can't do any other "actions" at the same time. This is
   an excellent addition to any game featuring real-time attacking proceedures and things
   of that nature, as you can make sure a player with a fast connection isn't getting 10
   hits a second, where a player with a slow connection may only get 2.

   How it works:
   The library creates an atom/movable/action, which is essentially an object stored
   on whatever player executes the action. As long as an action is stored on a player,
   they are considered to be "performing an action." The library also stores important
   variables on the action itself. The action will typically have an icon and a name.
   The time remaining on executing an action is saved as the action_atom.suffix. This
   time is in seconds remaining.

   How to apply it in your own code:
   You can use this in your own code, by checking if(player.action_atom), and if it
   returns 1 (true) then you know a player is performing an action. You are expected
   to edit all necessary code to include the action functions and checks. Refer to
   the demo section for more information on syntax and implementation.

   Why should I use this?
   This library provides a bulletproof action control system. If you implement the
   checks properly, it will work properly. Where some spawn and sleeping systems
   typically have trouble with reliability (every once in a while they may fail),
   this library does not. Plus, it gives a valid count-down of time remaining,
   and gives options for icon and icon_state, so you can overlay or display the
   action in the statpanel with no advanced code. Just a simple stat(action_atom).

   Where do I go if I have problems?
   You can contact me, Polatrite, via the BYOND pager. Preferribly, however, send
   an e-mail to [email protected].

   Do I have to donate a book of credits to use this library?
   While a mention of my name and a reference to this library would be nice, it's
   not required. Include me in your credits at your discretion.

   What are the usage limitations on this library?
   Use it. Modify it. Post it on the hub. The only thing you're not allowed to do
   is charge money for it. (Or any modifications of it.) This is a free library.

   Will you improve this with later versions?
   Yes. More documentation will be added, any bugs will be fixed, and possibly
   feature requests to be implemented. Private feature requests are availible
   for purchase to preferred users, upon request. */


Version 1.0 (10)
* Created and added the library to listings
Version 1.1 (11)
* Internal edits
Version 1.2 (12)
* Better documentation
Version 1.3 (13)
* Added a saving option