Created
June 5, 2023 23:43
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
]); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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