
Plugger
FILE LOCATION: My Personal Repo (until one-click submission)
META SCRIPT: This script is a meta-script, and part of the ZeroFrame Meta Toolbox. It can be used on its own, or in conjunction with ZeroFrame and the other meta-toolbox scripts, to modify other scripts' API commands.
ABSTRACT: Plugger gives you the ability to run small scriptlets (or scripts) and grant them zero-order capability (letting them shin-kick their way to the front of the line, no matter when they are installed). With ZeroFrame installed, you can schedule/prioritize the plugin evaluation in the loop, giving you even finer control. The plugins can offer anything from custom dice extraction from an inline roll to distance detection -- anything you might want a script to do in game.
Introduction
You can wrap other scripts you want to run in EVAL tags, and Plugger will evaluate the contents to run that command line. These could be standalone scripts or scripts registered to Plugger as a plug-in. If the scripts is registered as a plugin, you can retrieve whatever data you need to from the game or campaign and manipulate the command line in real time. Effectively, this gives you the ability to run code with the same shin-kicking, queue jumping trick that powers the meta-toolbox.
Although Plugger includes a library with a few built-in functions, the real strength of this sort of plug-ability is that 3rd-party scripters (or even you) can write scriptlets to allow this real-time return of game data to your command line. Need a PageID? Write a script and plug it in. Need the closest X number of tokens to a given token? Or all of the tokens within some given range? Write a script! (Or buy your local scripter a coffee and have them write it for you!)
Syntax Highlights
{& eval}scriptlet(--arg1|val --arg2|val){& /eval}
Using the EVAL Tags
EVAL tags are represented by {& eval} ... {& /eval}. The script command you want to execute would go between these tags. A full EVAL block would be structured using one of these formats:
{& eval} scriptname(arguments for script){& /eval}
{& eval} scriptname arguments for script{& /eval} {& eval} !scriptname arguments for script{& /eval}
The scriptname can represent one of the library of plugin scriptlets, or it could be another script in the game. Everything between the parentheses is passed to that script as arguments.
Use the first form when you want to access a plug-in designed to return information to the line. Plug-ins are built very similarly to normal scripts. In fact, a full-fledged script can be co-opted to return a value, if the developer wishes (more on building plugins later).
The last two forms are functionally the same as each other (the third line simply includes the leading exclamation point), but they differ from the first form in that they do not return anything to the command line. These forms are intended solely for launching other scripts (not plugins) that have nothing to do with returning a value to the command line. The EVAL tag will launch the other script and consume itself, leaving a zero-length footprint behind.
EXAMPLE: All tokens in range
Your character has an attack spell that affects anyone within some given range. Your scripter friend writes a script that returns the IDs of all tokens within that range, telling you that to use it, you would use a command syntax of:
!withinrange range source delimiter
So a typical call might be:
!withinrange 3 @{selected|token_id} ,
…returning a comma-separated list of tokens within 3 units of the given source token. Your scripter friend also tells you that they have built it as a plug-in for Plugger, so now you can use the same scriptlet in-line with another command to substitute in that comma-separated list:
!some-other-script --targets|{& eval}withinrange(3 @{selected|token_id} ,){& /eval} --damage|tons
By the time Plugger gets the message, the token id of the selected token will have been evaluated, and by the time the some-other-script API picks up the message, the EVAL tag will have been evaluated and will now the comma-separated list of tokens within the given 3 unit range.
Nest-able
EVAL tags are nest-able, and are processed from inside-out, allowing you to use one EVAL tag to return a piece of data that would be used as an argument in an enclosing EVAL tag:
{& eval}withinrange( {& eval} rangecalc(Bob the Slayer, Supernova) {& /eval} -M1234567890abcdef , {& /eval}
In that example, the the imagined (and custom built) rangecalc scriptlet figures out the range of the Supernova spell, and returns it to the outer EVAL block’s withinrange scriptlet.
Available Built-In Scriptlet Functions
At the time of writing this, there are two built-in functions, with more coming:
getDiceByVal() will retrieve dice from an inline roll that match a given set of value parameters (i.e., 2|5-6|>=10). Output options are a count of the dice, a total of the dice, or a list separated by a delimiter of your choice. More on the required syntax for this plugin in a later post.
getDiceByPos() will retrieve dice from an inline roll based on the position of the dice based on a set of position parameters (i.e., 2|5-6|>=10). Output options are a count of the dice, a total of the dice, or a list separated by a delimiter of your choice. More info on the required syntax in a later post.
Installing 3rd Party Scriptlets
If you or your local scripter has written a scriptlet to plug into Plugger (which is easy enough to do), you only need to install it as you would any other script. Provided the script author implemented the syntax to register that scriptlet with Plugger, it will be available to you as soon as your sandbox restarts.