Skip to content

Instantly share code, notes, and snippets.

@dogboydog
Created June 5, 2023 23:43
Show Gist options
  • Save dogboydog/87e294ab14c17d6e2188713de9c36d15 to your computer and use it in GitHub Desktop.
Save dogboydog/87e294ab14c17d6e2188713de9c36d15 to your computer and use it in GitHub Desktop.
example tiled scripts related to the addition of custom properties to Tiled Projects https://github.com/mapeditor/tiled/pull/3667
var AddProjectProperties = {};
AddProjectProperties.action = tiled.registerAction("ProjectCustomProperties", function (action) {
tiled.project.setProperty('newString', 'hello world');
tiled.project.setFloatProperty('newRatio', 0.7);
tiled.project.setColorProperty('newColor', "#aabbaa");
});
AddProjectProperties.action.text = "Add Project Properties";
tiled.extendMenu("Edit", [
{ action: "ProjectCustomProperties", before: "SelectAll" },
{ separator: true }
]);
var ReadProperties = {};
ReadProperties.action= tiled.registerAction("ProjectReadProperties", function (action) {
tiled.project.property('myRatio')
for (const propName in tiled.project.properties()){
tiled.log(`Property ${propName} has value ${tiled.project.property(propName)}`)
}
tiled.log("Read properties")
});
ReadProperties.action.text = "Log all Project Properties";
tiled.extendMenu("View", [
{ action: "ProjectReadProperties" },
{ separator: true }
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment