Skip to content

Script Doc

Warning

This section is not for the novice, you can damage your data by incorrect usage.

This just a stub of information as a skeleton framework for Doc'ing. It is currently a WIP at this time.

Script Doc API

Script Doc API (new window)

Methods and Variables

Javascript D20PRO specific methods and variables

In the script library editor, you can use the following additional bindings to access content from inside D20PRO's engine as native javascript:

console -- root class with subcommands -- controls the console view for the instance. this can be used to force zoom levels, token selection, token visibility, toggle fog of war and so on.

map -- root class with subcommands -- provides access to all things related to the current map. Be careful with this as the target map can change while the decision window is open.

mapView -- root class with subcommands -- provides access to the map view controller. offers a lot of the same functionality as the console, but with specific focus on the maps.

role -- string value -- returns the currently assigned role for the script executer (usually the GM). Options are "GM" or "Player".

gamelog -- root class with subcommands -- provides access to the game log for building entries and posting new logs.

feature -- root class with subcommands -- provides access to the parent feature/spell which called the script.

caster -- root class with subcommands -- provides access to the casters creature template data.

casterInPlay -- root class with subcommands -- provides access to the casters creature data as it related to the specific token on the map. "InPlay" data adds to the creature template data with things like location, tethers, statuses and more.

classBinder -- root class with subcommands -- this one provides access to the creature class library and lets you pull base data from class/creature templates for comparison to caster/target data.

light -- root class with subcommands -- provides access to the lighting mechanics allowing for programmatic creation of lights and control over existing lights.

target -- root class with subcommands -- provides access to the target's creature class template data.

targets -- array of target -- provides access to a list of all targets in the current selection. Can be iterated over to provide specific access to array elements identicial to the above "target" type.

time -- root class with subcommands -- provides access to the games time controls for round, minute, hour, day, month, etc.

gameLogToken -- root class with subcommands -- helper class used to build new game log tokens which are valid when published from scripts.

as a GM you have access to the following additional commands

channels -- root class with subcommands -- usage of this class is required to publish game log entries/tokens built with the above game log classes. Channels can also be used to force a programmatic "broadcast" of the game state.

gameNative -- root class with subcommands -- access the underlying game state. Exposed for power users but not suggested as you can easily break your campaign with this one.

maps -- array of maps -- this provides easy access to the stack of open maps. Use this to help manage things like teleportation between maps or auto-map switching.

when an effect is in play (already cast) the following become available

effect -- root class with subcommands -- provides access to the current effect node and it's children. This allows direct manipulation of effect value nodes and other settings programmatically.

mult -- root class with subcommands -- provides access to the active effects multiply/repeat settings and the node associated with those settings.

classLevel -- utility -- returns the current classLevel of a cast effect. This does not include the casting class details, just the level that it was cast at.


Other

// abilityID is typically a number between 0 and ... for example for D&D ability ID is
// STR = 0, DEX = 1, CON = 2, INT = 3, WIS = 4, CHA = 5. Rules determine this order and naming.

// number is an integer or byte value for the following signatures

// returns an array of Skills for the given target.
retv = target.getSkills().getSkills();

// returns the current skill penalty value for the given target.
retv = target.getSkillPenalty().getPenalty();

// sets the skill penalty for the current creature (good for armor and such).
target.getSkillPenalty().setPenalty(number);

// boolean check to see if a given creature has a skill penalty.
retv = target.getSkillPenalty().hasPenalty();

// checks to determine if the skill penalty is applied to the current ability ID.
retv = target.getSkillPenalty().applicable(abilityID);

// Main call to get skill by "name" and access the calculated skill bonus for the current target creature.
retv = target.getSkills().getSkill("name").getCurrentBonus(target);

// call to access the current number of ranks for the named skill.
retv = target.getSkills().getSkill("name").getRanks();

// call to set the ranks for the named skill.
target.getSkills().getSkill("name").setRanks(number);

// call to access the current rank modifier (using rules) for the named skill.
retv = target.getSkills().getSkill("name").getRankMod();

// call to set the current rank modifier (using rules) for the named skill.
target.getSkills().getSkill("name").setRankMod(number);

// call to access the current number of misc bonus (ranks) for the named skill.
retv = target.getSkills().getSkill("name").getMisc();

// call to set the misc value for the named skill.
target.getSkills().getSkill("name").setMisc(number);

// call to access the current modifier for the misc bonus for the named skill.
retv = target.getSkills().getSkill("name").getMiscMod();

// call to set the misc mod value for the named skill.
target.getSkills().getSkill("name").setMiscMod(number);

// call to get the total calculated ranks, including all feature mods and external factors.
retv = target.getSkills().getSkill("name").getTotalRank();

// call to get the total calculated misc, including all feature mods and external factors.
retv = target.getSkills().getSkill("name").getTotalMisc();

// call to fetch the skill name... but you kind of already have it, most likely.
retv = target.getSkills().getSkill("name").getName();

// call to rename a skill
target.getSkills().getSkill("name").setName("skill name");

// call to get the skill group affiliation
retv = target.getSkills().getSkill("name").getGroup();

// call to SET the skill group name
target.getSkills().getSkill("name").setGroup("group name");

// call to get the ability associated with the skill
retv = target.getSkills().getSkill("name").getAbility();

// call to SET the ability association of a skill.
target.getSkills().getSkill("name").setAbility(abilityID);