@mapeditor/tiled-api
TypeScript icon, indicating that this package has built-in type declarations

1.10.1 • Public • Published

tiled-api

This package includes TypeScript definitions for the Tiled scripting API which (depending on your editor support) also allow you to write simple JavaScript scripts with automatic code completion.

Online documentation

See: https://www.mapeditor.org/docs/scripting

Writing a Tiled plugin with code completion in VS Code

Create a new project:

mkdir example-tiled-ts-plugin
cd example-tiled-ts-plugin
npm init

Install the Tiled definitions:

npm install @mapeditor/tiled-api --save-dev

Write your plugin and enjoy code-completion:

/// <reference types="@mapeditor/tiled-api" />

const action = tiled.registerAction("CustomAction", function(action) {
    tiled.log(action.text + " was " + (action.checked ? "checked" : "unchecked"))
})

action.text = "My Custom Action"
action.checkable = true
action.shortcut = "Ctrl+K"

tiled.extendMenu("Edit", [
    { action: "CustomAction", before: "SelectAll" },
    { separator: true }
]);

Of course, when writing TypeScript code instead of JavaScript you also get compilation errors instead of only syntax highlighting.

Readme

Keywords

none

Package Sidebar

Install

npm i @mapeditor/tiled-api

Weekly Downloads

617

Version

1.10.1

License

MIT

Unpacked Size

127 kB

Total Files

6

Last publish

Collaborators

  • thorbjorn
  • ablu