Character View Helper Functions

Helper Functions in Character View modules

This document provides detailed information on helper methods within the SceneGrinder VTT Svelte integration module, aimed at enhancing interaction with character data and UI components. Users who want to create their own gaming systems or extend existing systems will need to know how to use these functions withing Character View build outs.


The helper methods facilitate a range of functionalities, from attribute manipulation and UI interactions to dynamic list handling within a Svelte application. Below, you'll find the specifications for using these methods effectively.

Helper Methods


Initiates a check action for a specified attribute path, useful for attribute validation or checks within the game logic.


  • attrPath: String. The dot notation path to the attribute.



edit(e, attrPath, asMod)

Opens a popup for editing an attribute's value, supporting both direct attributes and modifiers.


  • e: Event. The trigger event, typically a click event.
  • attrPath: String. The dot notation path to the attribute.
  • asMod: Boolean. Indicates if the edit is for a modifier.


edit(event, 'character.attributes.intelligence', true);

addItem(e, attrPath)

Facilitates the addition of items to a list or collection attribute via the UI.


  • e: Event. The trigger event.
  • attrPath: String. The path to the list or collection attribute.


addItem(event, '');

deleteItem(e, attrPath, rowId)

Enables the removal of items from a list or collection attribute through the UI.


  • e: Event. The trigger event.
  • attrPath: String. The path to the list or collection attribute.
  • rowId: String/Number. The identifier of the item to remove.


deleteItem(event, '', 'sword123');


Generates a dynamic array of objects representing items within a list or collection attribute, each with utility methods for further interaction. This method is versatile, handling both arrays of properties and collections of properties, enabling iteration and manipulation of individual items or attributes within these structures.


  • path: String. The path to the list or collection attribute.

Usage Contexts:

  • Array of Properties: When dealing with direct arrays, list allows iteration over array items, providing access to individual properties and utility methods for each.
  • Collections of Properties: For collections (objects with key-value pairs), list facilitates access to each collection item, treating them as discrete entities for manipulation or interaction.


const skillList = list('character.skills');
skillList.forEach(skill => console.log(skill.get('name')));


Tracks and restores the scroll position of a specified DOM element, useful for persisting UI scroll states across re-renders.


  • node: HTMLElement. The element to monitor.



Utility Functions within list

Within the context of list, additional utility functions are provided for detailed interactions:

get(attrPath, defaultIfBlank)

Fetches the value of an attribute, offering a default if the value is absent.

edit(e, asMod)

Triggers an edit UI for the attribute or list item.


Initiates the addition of an item to the collection.


Facilitates the removal of an item from the collection.


These helper methods are designed to streamline interactions within the SceneGrinder VTT environment, providing Svelte authors with the tools needed for effective character data management and UI dynamics.

Back To SceneGrinder Documentation Back To Whatever You Were Reading Before