astrochili / vscode-defold

A toolkit for Visual Studio Code to develop games with Defold
https://marketplace.visualstudio.com/items?itemName=astronachos.defold
MIT License
167 stars 10 forks source link

Can't run the build from Defold Editor #28

Closed Deirel closed 1 year ago

Deirel commented 1 year ago

I have added the "debugger" script to the main collection, as stated in the instructions. Running a debug session from VS Code works great. However, when I try to run the build from the Defold Editor by pressing Ctrl+B, the following logs appear in the console:

INFO:DLIB: Log server started on port 53783
INFO:ENGINE: Target listening with name: Dev - fe80::cf32:7ec3:e1b:d02a - Windows
INFO:ENGINE: Engine service started on port 53784
INFO:GRAPHICS: Initialised graphics device 'opengl'
INFO:ENGINE: Defold Engine 1.5.0 (00352cc)
INFO:DLIB: Initialized Remotery (ws://127.0.0.1:17815/rmt)
INFO:ENGINE: Loading data from: build/default
INFO:LIVEUPDATE: Could not find base .arci/.arcd. Liveupdate disabled
INFO:ENGINE: Initialised sound device 'default'
ERROR:SCRIPT: debugger/debugger.script:11: module 'debugger.debugger' not found:
    no file 'debugger.debugger'
stack traceback:
  [C]:-1: in function require
  debugger/debugger.script:11: in main chunk

WARNING:RESOURCE: Unable to create resource: /debugger/debugger.scriptc: FORMAT_ERROR
WARNING:RESOURCE: Unable to create resource: /_generated_da3d727d.goc: FORMAT_ERROR
ERROR:GAMEOBJECT: Could not instantiate game object from prototype /_generated_da3d727d.goc.
WARNING:RESOURCE: Unable to create resource: /main/main.collectionc: FORMAT_ERROR

Defold is fairly new to me, so perhaps I'm missing something obvious?

Deirel commented 1 year ago

After conducting some research, I discovered that if I run the following code:

local debugger = require('debugger.debugger')
debugger.start()

instead of:

require('debugger.debugger').start()

then the error disappears and the build starts successfully.

Not really sure why is it so, but FYI.

astrochili commented 1 year ago

Very strange, because it's pretty much the same thing.

astrochili commented 1 year ago

Maybe the problem is in the Defold analyser of required modules. Yes, it analyzes the require() uses before building the game.

Anyway, it's more correct to assign to a local variable first. There is no need for such minification here. Besides, it was like that earlier in the guide.

So I will change it to the variant that works for you. Thanks!

astrochili commented 1 year ago

Confirmed, it's a bug in Defold — https://github.com/defold/defold/issues/7963.