Bulk Editing Guide

Overview

Screentop lets you quickly edit multiple entities at once using just a bit of JavaScript. In the edit modal you should see an input that contains something like like this:

function editVariant(variant, index) {
  return {

  };
}

As you modify this function, the JSON representation of the entities will update automatically.

Try it out by editing some variants with this example:

function editVariant(variant, index) {
  return {
    name: `Example ${index}`,
    fillColor: "red"
  };
}

This will update the selected variant Names to "Example 1", "Example 2", ... and Fill Colors to red.

You can review the updated values in the JSON input and Save to confirm these changes.

Common usage patterns

Setting a different asset for each variant

function editVariant(variant, index) {
  return {
    asset: "Asset 1",
    // Outputs 1, 2, ...
    assetIndex: index,
  };
}

Setting the same back asset for each variant of a tile component

function editVariant(variant, index) {
  return {
    backAsset: "Asset 1",
    backAssetIndex: 1,
  };
}

Setting a different variant for each object

function editObject(object, index) {
  return {
    // Outputs "Variant 1", "Variant 2", ...
    variant: `Variant ${index}`,
  };
}

Moving all objects a certain distance

function editObject(object, index) {
  return {
    x: object.x + 32,
    y: object.y + 32,
  };
}

Positioning point anchors in a grid

const COLUMNS = 5;
const ROWS = 5;
const CELL_WIDTH = 32;
const CELL_HEIGHT = 32;

function editAnchor(anchor, index) {
  const row = (index - 1) % COLUMNS;
  const column = Math.floor((index - 1) / COLUMNS);
  return {
    // Outputs -64, -64, -64, ...
    x: column * CELL_WIDTH - (COLUMNS - 1) * CELL_WIDTH / 2,
    // Outputs -64, -32, -0, ...
    y: row * CELL_HEIGHT - (ROWS - 1) * CELL_HEIGHT / 2,
  };
}