The extension can be used in combination with the Defold Buddy extension, which adds additional sugar and features. But don’t forget to clean up the API annotations to avoid duplication.
@astrochili I love this extension! thank you so much!
Just a question. When using VSC I do the following to test the game:
(1) press CMD-SHIFT-B and then
(2) select “Launch (without Debugger)”.
Is it possible to avoid the two steps and just have a single shortcut that does (1) and (2)? I am sorry for the maybe noob question…
Thank you so much!
EDIT: I have just noted that with (1) and (2) the project is not built but just the last build (made from the Defold editor) is launched. On the other hand if I try “Build to launch” then the build process is really slow. How may do in VSC something like CMD+B in the Defold Editor (that build and run in a second the game)?
You have to add debugger script to the main collection.
[Defold] Using F5 to run in debug mode.
You have nothing to do.
In the both option, you just need to press F5 button.
But I prefer to use option 2. Because the hot reload worked well.
For me, it seems hot reload doesn’t work when I run from vscode. It seems when run game from defold editor, there is a connection between running game & editor → editor can trigger hot reload.
There are several ways to launch the game with Defold Kit.
Run and Debug (F5 by default)
This is the easiest way to run from VS Code. @uosdev mentioned the need to add a script, but it’s not really necessary. You only need a script in the project if you want to debug with breakpoints, otherwise the game will run without debugging (just like when you run a task). But it requires to install the local lua debugger extension and add the launch configuration during setup Defold Kit.
If you want to run without the local lua debugger (but there are not many reasons for this), you can add a shortcut to run the command. It’s possible to do from the command pallete (Ctrl/Cmd + Shift + P) or from the VS Code settings menu.
Regarding “create and run a game in a second”. Build in VS Code uses the bob builder with the “--variant debug build” arguments and it takes a bit longer than building in the Defold Editor.
Defold Editor uses bob too, but it uses some caching and change tracking approaches. This is a mystery to me and so I don’t know how to speed up the build process yet. Perhaps the Defold team could help with this and give some hints where to start.
If you need for a quick startup without debugging in VS Code and you don’t mind having an open Defold editor, you can just run the build in Defold. There is a Buddy extension to call the Build menu command in Defold Editor from VS Code, have a look at it.
I don’t mind having the Defold editor open in background (indeed I still need to use it for all the “graphical” editing of particles, collections, …). So the Buddy VSC extension to launch the game from VSC via the Defold editor should be perfect for me.
But may this extension conflict somehow with the Defold Kit? I am sorry, I know this is a very embarrassing question… I am lost with all these installation procedures…
But may this extension conflict somehow with the Defold Kit?
Haven’t tried it very closely, but it looks like the only overlapping functionality is syncing the API annotations. You can simply not use annotations syncing in Defold Kit. Or, on the contrary, do not use it in Buddy.
Otherwise you will have duplicate annotations. Buddy saves them to the project folder, Defold Kit to the extension storage folder.
I agree that it’s probably confusing. It’s good when there is a choice, but then which one to choose? Currently there are “Defold IDE” (old), “Defold Build Tools” (old?), “Defold Kit”, “Defold Buddy” with overlapping features between them. It would be great to have a single or a couple of “go to” extension when working with Defold in VSCode. However there is no easy way to combine the extensions since they are community extensions with each person having their own approach, goals, ideas and because it’s easier and more enjoying to work on your own stuff. I like the idea behind “Defold Build Tools” extension to have all building and running functionality in a single extension. I am also experimenting with debugging when game is started by Defold editor (not via Bob) and it makes sense to have that functionality outside of Buddy so that ppl who don’t use it still have access to debugging and stuff.
In example, that’s what I don’t like the most about Nunjucks templating language in VSCode is that there are a ton of extensions that do the same thing and I don’t know which one is the best.
It just seemed to me that your post raised a question about what all this is for, so I thought I’d respond in detail.
What’s up with the existing extensions?
I think that the significance of the intersection of features and the issue of choice is overstated.
I would not be wrong to say that Defold IDE has been unsupported for more than two years and is not up to date, since the only function it provides is refactoring hash constants.
Defold Build Tools has not been updated since 2021. It was created based on the guide, but originally as part of ts-defold. For lua users it can resolve dependencies, bundle and run with bob, but without debugger for lua, only TS.
With Buddy right now the only overlap is annotations, which there is no problem to disable. I’ve also added to the Defold Kit settings the ability to select your annotations.
Why did I create my own annotations generator?
Simply because I don’t know anything about C# or Java and I think it’s better to do these things in Lua so that everyone can fix things. I think it’s reasonable, it just works by this way.
Why did I create the extension?
Here are some criteria I follow:
Want to debug code in VS Code and to this day have the only working solution based on using lldebugger, bob and the algorithm described in the defold.sh script from the guide.
I want to run the game without running the Editor, if possible. I like to work with the engine as a framework and use the Editor more as a scene or gui editor.
I want to bundle and deploy the game to a connected mobile device without using the Editor.
If any of the existing extensions would have implemented this in the last two years, that would have been great. But that hasn’t happened, when personally that’s exactly what I need. So I implemented it in the expectation that someone else has the same approach and wishes.
Why didn’t I just add the functionality to Buddy?
I saw the original approach of communicating with the editor, not with bob, by design. But wanted to retain the ability to work without starting the Editor (described above why).
Responsibility for the guide, 100 stars keeps it from hiding, and I’m ready to continue maintaining.
I don’t have a heart for anything that mixes development and political views.
But this is my personal position, which may be close to a minority. And that’s not a problem, because the main fuel for me was the need for only the features I implemented. The only thing I’m missing now is smarter caching for the bob. But this is impossible to implement without a corresponding bob API that accepts a list of changed files to build.
Any file generators, refactoring, communicating with the editor over http - it’s just not my thing, there’s room for it and Buddy will do it well. If you implement debug via mobdebug that would be great, maybe I can use it too without running the Editor, why not.
Many thanks for your work to @astrochili@mikatuo . Now I am able to launch the game from VSC using Buddy and Defold: Project > Run.
However I see the console output in the Defold editor and not in VSC. But maybe this is unavoidable since Buddy is just launching the game in the Defold editor. And I’m getting a bit too picky…
Defold Build Tools has not been updated since 2021. It was created based on the guide, but originally as part of ts-defold.
Update: In the case of Defold Build Tools I was wrong. Just missed the point all this time and kept thinking that the extension funcionality is for ts-defold only. Just recently realised that launching with bob works with a regular project too, but without debugger for lua.
Thank you very much for this extension This is gonna save me a lot of time in the future
Quick question about annotations as its my first time using them. Ive got a module where i setup all the annotations but when i call a method within that module it does not show all the params etc but it does for the ‘new’ function within the module. I’ve attached 2 images of what I mean. Thanks in advance
Hello. As far as I can see, you have annotated the transitions class with the new method, which returns an new instance of transitions. But the start_transition method is a part of the instance table, not to the transitions class. So if you returns the transitions class then it’s okay that it doesn’t have methods of a table not related to the class.
But what exactly do you want to do, a module that creates instances of a class or something else?
Sorry for my very late response, I just never had the time to look more into the problem but on my xmas break I took some time to look at this again. I found the issue when I place line 6 above line 2 it works perfectly fine