-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automap rule file should ignore object layers. #3262
Comments
I think this would be better solved by making it possible to mark layers as comments (e.g. comment_LayerName) rather than by ignoring entire layer types. Also, Object Layers are valid output layers xP And it's possible one day they may become valid input layers. It might be nice if any invalidly named layers were just ignored instead of raising errors. But if that's likely to confuse people, then an explicit comment marker would be good. I use region_somethingInvalid as successful comment layers, seems to work for object layers too. So, for now, perhaps you can use regions_comment? Pretty sure this is an oversight, and a proper way to add comment layers would still be nice. |
What if we just added layer name prefix "//" for commenting out a layer? Would also be nice for temporarily disabling a layer. |
/* Toggle // by eishiya, last updated 4 Feb 2022
Adds an action to the Layers menu that adds or removes // to/from
selected Layers' names, useful for disabling layers in Automapping.
Group Layer names are left untouched, since Automapping ignores them.
*/
var toggleCommentLayer = tiled.registerAction("ToggleCommentLayer", function(action) {
// Should the state of each layer be toggled individually,
// or based on the state of the bottom-most layer?
let toggleIndividually = false;
let map = tiled.activeAsset;
if(!map || !map.isTileMap) {
return;
}
let lastSeenCommented = null;
map.macro("Toggle //", function() {
let selectedLayers = map.selectedLayers;
for(let li = 0; li < selectedLayers.length; ++li) {
let curLayer = selectedLayers[li];
if(curLayer.isGroupLayer) //ignore group layers
continue;
if(curLayer.name.indexOf("//") == 0) { //commented
if(lastSeenCommented === null) lastSeenCommented = true;
if(toggleIndividually || lastSeenCommented === true)
curLayer.name = curLayer.name.substring(2).trim();
} else { //uncommented
if(lastSeenCommented === null) lastSeenCommented = false;
if(toggleIndividually || lastSeenCommented === false)
curLayer.name = "//" + curLayer.name;
}
}
});
});
toggleCommentLayer.text = "Toggle //";
tiled.extendMenu("Layer", [
{ action: "ToggleCommentLayer", before: "LayerProperties" },
{separator: true}
]); You can customize the toggling behaviour by changing whether |
@eishiya Amazing! I guess we'll see that in https://github.com/eishiya/tiled-scripts soon. :-) |
I wasn't planning to put it there, otherwise I'd have just posted a link xP But I guess I should add this to my Automapping Helper script. |
Wow, what a fine solution, and so prompt too! Y'all are incredible! |
I want to add comments to my automapping rule file using text in an object layer, but currently can't figure out any way to do so.
When I add an object layer in the rule file, running the rule file will complain that the name of the object layer is not one of the allowed input*, output*, or region* possibilities.
(If I change its name to something like "region", it will complain that input* output*, and region* must be tile layers, but that's what I expected.)
I think it would be a reasonable default behavior for Tiled to ignore non-tile layers without errors during automapping.
I'd also be happy for any advice on a workaround for me to add comments to my rule files!!
Thanks a bunch! 😃
The text was updated successfully, but these errors were encountered: