Hello, I have this script that is working, except that instead of flat attributes it creates ints.
// Register a new action called "TemplateAction"
let LayerParallaxAction = tiled.registerAction("LayerParallaxAction", function(action)
{
let tilemap = tiled.activeAsset;
// Ensure there's a valid tilemap
if (!tilemap) {
tiled.alert("No active tilemap found.");
return;
}
let selectedLayers = tilemap.selectedLayers; // Get selected objects
if (selectedLayers.length === 0) {
tiled.alert("No objects are selected.");
}
else
{
selectedLayers.forEach(obj =>
{
// Create imagePath property if it doesn't exist
let parallaxFactorX = parseFloat(10.0);
obj.setProperty("parallaxFactorX", parallaxFactorX);
let parallaxFactorY = parseFloat(2.0);
obj.setProperty("parallaxFactorY", parallaxFactorY);
});
}
});
LayerParallaxAction.text = "add parallax attrs to layer"; // Display name in the menu
tiled.extendMenu("Edit", [
{ action: "LayerParallaxAction", before: "MapProperties" }
]);
I am not very familiar to js so it’s probably something basic.
Thx