RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.
http://rptools.net
GNU Affero General Public License v3.0
787 stars 259 forks source link

Bind getBar, setBar isBarVisible and setBarVisible to javascript #4899

Closed fishface60 closed 2 weeks ago

fishface60 commented 2 weeks ago

Identify the Bug or Feature request

resolves #4898

Description of the Change

Add token.getBar, token.setBar, token.isBarVisible and token.setBarVisible functions to the JavaScript macro context.

See https://richardmaw.gitlab.io/maptool-bar-test/ for example campaign properties and add-on demonstrating the change.

Possible Drawbacks

This may stabilise an API with problems.

Documentation Notes

token.isBarVisible() Function

• Introduced in version 1.15.1

Returns true if the named bar is visible, false if it is not.

Usage

let visibility = token.isBarVisible(barName);

See isBarVisible() for MTScript equivalent.

token.setBarVisible() Function

Note: Using this function on tokens you do not own is only possible in a Trusted Macro

• Introduced in version 1.15.1

Changes bar visibility.

Usage

token.setBarVisible(barName, state);

See setBarVisible() for MTScript equivalent.

token.getBar() Function

• Introduced in version 1.15.1

Returns the current value of the named bar, or 0 if it is not visible.

Usage

let value = token.getBar(barName);

See getBar() for MTScript equivalent.

token.setBar() Function

Note: Using this function on tokens you do not own is only possible in a Trusted Macro

• Introduced in version 1.15.1

Set the value of the named bar, enabling it if it was hidden.

Usage

token.setBar(barName, value);

See setBar() for MTScript equivalent.

Release Notes


This change is Reviewable