Skip to content

feat: Initial release of SwapTokenPositions script#2206

Merged
Alicekb merged 3 commits intoRoll20:masterfrom
steverobertsuk:sr/swap-token-positions-v1
Apr 30, 2026
Merged

feat: Initial release of SwapTokenPositions script#2206
Alicekb merged 3 commits intoRoll20:masterfrom
steverobertsuk:sr/swap-token-positions-v1

Conversation

@steverobertsuk
Copy link
Copy Markdown
Contributor

  • Added core functionality to swap positions of two selected tokens on Roll20.
  • Implemented customizable animation effects and persistent settings for GMs.
  • Created a user-friendly help command and macro installation feature.
  • Documented features and usage in README and CHANGELOG files.

- Added core functionality to swap positions of two selected tokens on Roll20.
- Implemented customizable animation effects and persistent settings for GMs.
- Created a user-friendly help command and macro installation feature.
- Documented features and usage in README and CHANGELOG files.

Signed-off-by: Steve Roberts <[email protected]>
* The main functionality is triggered by the `!swap-tokens` command in chat.
*/
// === Script version and last updated date ===
const SWAP_TOKEN_POSITIONS_VERSION = "1.0.0";
Copy link
Copy Markdown
Contributor

@shdwjk shdwjk Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all Roll20 Mod Scripts are concatenated together before being run on the sandbox, it's best practice to wrap your code in a closure. Usually something like:

on('ready',()=>{
   <... your code ...>
});

This prevents name collisions and general pollution of the global scope.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied a patch to wrap the code in a named scope to prevent collisions and general pollution of the global scope.

*
* @returns {void}
*/
on("ready", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just move this line up to above line 17, and that will solve the global scope issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept the on ready slim as I've wrapped the script in a named scope

…e script scope

Signed-off-by: Steve Roberts <[email protected]>

Co-authored-by: Copilot <[email protected]>
@steverobertsuk steverobertsuk requested a review from shdwjk April 24, 2026 13:53
@Alicekb Alicekb merged commit 2741a63 into Roll20:master Apr 30, 2026
1 check passed
@steverobertsuk steverobertsuk deleted the sr/swap-token-positions-v1 branch May 1, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants