Hello,
I made this script that simple creates a entityType string custom property on the selected images:
// Register a new action called "TemplateAction"
let TemplateAction4 = tiled.registerAction("TemplateAction4", function(action)
{
let tilemap = tiled.activeAsset;
// Ensure there's a valid tilemap
if (!tilemap) {
tiled.alert("No active tilemap found.");
return;
}
// Loop through all selected objects and print their IDs
let selectedObjects = tilemap.selectedObjects; // Get selected objects
if (selectedObjects.length === 0) {
tiled.alert("No objects are selected.");
}
else
{
selectedObjects.forEach(obj =>
{
// Check if the "imagePath" property exists by trying to get its value
let entityType = obj.property("entityType");
if (entityType === undefined)
{
// Create imagePath property if it doesn't exist
obj.setProperty("entityType", "enemy" );
}
else
{
tiled.alert("entityType already exists");
}
});
}
});
TemplateAction4.text = "add entityType attr"; // Display name in the menu
tiled.extendMenu("Edit", [
{ action: "TemplateAction4", before: "MapProperties" }
]);
It works fine. I just want to be able to see a tool tip when I hover over showing a message like: “valid entity types are enemy, npc, prop, collider and decoration”
I check the api the toolTip seems to be a function for Qt. I don’t know much about Tiled scripting but I think that what I am doing is an Action type script, but the toolTip is for Qt widgets right? So is it possible to dispaly a tool tip on my custom property?
Also, can I put the actions on a shelf to be more accessible?
I don’t like having to go to the edit menu each time.
thanks