
Stop me before I go too far; I might be replicating existing functionality. Then again, as I'm new to R20 and maybe don't know all the ways people typically use it, tell me if there is more that could be done. :-)
I wanted a script that could let me modify parameters for an ability on an ad hoc basis (see below for why I wanted this). So, the implementation of this would look like:
{an ability} ==> [has replaceable parts ("hooks")]
{the script} ==> [has functions that process values for those hooks]
Straightforward. In practice, it would look like this... take an original ability like:
OriginalAbility: !some_script --arg1:The Value --arg2:Another Value --arg3:So much value
If that ability also accepted a "target" argument that would parse a list of token IDs separated either by space or by comma, you might at times need options like:
!some_script --arg1:The Value --arg2:Another Value --arg3:So much value --target: @{target|Target 1|token_id}
!some_script --arg1:The Value --arg2:Another Value --arg3:So much value --target: @{target|Target 1|token_id} @{target|Target 2|token_id}
!some_script --arg1:The Value --arg2:Another Value --arg3:So much value --target: @{target|Target 1|token_id} @{target|Target 2|token_id} @{target|Target 3|token_id}
...
Ugh. So, instead, drop a hook into that part of the Ability. In this case, I'll use "__target__" (what you use is up to you):
!some_script --arg1:The Value --arg2:Another Value --arg3:So much value --target: __target__
!insertargs --load:OriginalAbility --__target__:[...]
gettargets(#)
targetsel()
!insertargs --load:OriginalAbility --__target__:gettargets(?{Targets|1})
Code and Syntax
API Call: Call it using either "!insertarg " or "!insertargs ".
Arguments: Structure your arguments as " --key:val" pairs.
key: your next hook
val: how to replace that hook
Special Arguments: The first argument tells the script how to operate. key: "chat" or other val: name of Ability to operate on
Version 0.2 Updates:
-- the available functions are now independent objects. A library-style object is used to test user input against the available functions (keys), passing in the remaining arguments. Add a function, add a key to the library.
-- multiple arguments can now be passed to the available functions by use of " :: " (space colon colon space) as the delimiter
-- the gettargets() and targetsel() functions now accept a custom delimiter. For gettargets(), it is the second arg. For targetsel() it is the first. If it is not provided, a space is used. To get an empty delimiter, use the argument delimiter but don't supply a value.