Intro
- Download the editor
- Rename the downloaded file to
godot
and add Godot to your path - Open a terminal
- Test if you can use Godot via CLI and run
godot --version
- Run
npx -y @godot-js/godot-ts init
(new project will be crated at your current terminal path) - Follow the prompts
- Run
cd <your-project>
- Run
npm i
- Run
npm run dev
- this will enable typescript watch mode and opens the editor - Run the menu command inside the editor
Project > Tools > JavaScript > Generate TypeScript Declaration File
and overwrite filegodot.d.ts
Features
- By running
npm run dev
you compile your.ts
files into.mjs
automatically - Use the generated
.mjs
files inside your editor - To open the
.ts
origin file for a.mjs
file you need to enable External Editor - If you want to start the game without editor run
npm run start
- For more information check out
godot-ts
Open scripts from the editor
Inside the editor you are normally able to open a script inside the build in text editor.
But we use a compiled .mjs
file for our scripts.
.ts
files can't be open in the editor.
So we need to open the .ts
files inside an external editor:
- Goto
Editor/Editor Settings/Text Editor/External
- Check the
Use External Editor
- Add your path your desired editor to
Exec Path
- Check this for more information - Paste
{project} --line {line} {file}
(JetBrains products) toExec Flags
- If you click on a
.mjs
script it should read thebanner
on top of the file like//generatedPath=<absolute-path>.ts
and opens this file