Page 1 of 1

Debugging with VS Code

Posted: Fri May 11, 2018 11:33 pm
by sven
Recently, I've been playing with VS Code as an IDE for Stars in Shadow development. Some Korean game devs have written a very nice Lua debugger for it, and that means VS Code is now actually in many cases a better IDE for SiS than Visual Studio. It's also far easier to download and setup. If you're a modder, I'd suggest taking a look.

As of r37523 (which is currently "live" on Steam/GoG) you should be able to get setup as follows:

Install VS Code.
From your VS Code extensions tab, install the devCAT Lua Debugger.
From your VS Code extensions tab, Install sven2718's openhintvc extension.

Image

Go to File->Open Folder and open your "Lua state" dir.
In the VS Code debug pane, select launch-sis, and hit the green arrow.

Image

Now, if everything is working, the game should start in debug mode, and you should have access to both CTRL+click hotkeys and the ability to set breakpoints / view stack traces.

Re: Debugging with VS Code

Posted: Sat May 12, 2018 2:46 am
by siyoa
works so far :)

now, when I click "New Game" and ctrl-click on race description file RACES.lua opens, but ctrl-clicking anywhere else (race picture, home world) nothing happens :?:

Re: Debugging with VS Code

Posted: Sat May 12, 2018 3:07 am
by sven
siyoa wrote:works so far :)

now, when I click "New Game" and ctrl-click on race description file RACES.lua opens, but ctrl-clicking anywhere else (race picture, home world) nothing happens :?:


the ctrl-click feature is not implemented everywhere in the game -- basically, trying to use it on a given text block will give you a hint how old the underlying sources are (the ctrl-click feature is /relatively/ new).

Re: Debugging with VS Code

Posted: Sat May 12, 2018 4:43 am
by siyoa
ah, ok

I thought that that functionality is some kind of overlay, that brings the file up that contains the element

Re: Debugging with VS Code

Posted: Sun May 13, 2018 10:25 pm
by sven
Hmm. Apparently, most of the source files in SiS are encoded in Windows-1252, which VSCode will, by default, mis-label as UTF-8. This leads to text formatting glitches when VSCode re-saves any files that use extended characters, like '’' or '©'. There's a pretty simple fix though, which is to go to File->Settings and add the user settings overrides:

Code: Select all

    "files.encoding": "utf8bom",
    "files.autoGuessEncoding": true,

Re: Debugging with VS Code

Posted: Sun Jul 21, 2019 3:21 am
by akkamaddi
I've just installed this, but the control click does not seem to be opening anything in VS Code. Does this still work? I'm trying to track down where "Capricious" is applied to morale.

Re: Debugging with VS Code

Posted: Mon Jul 22, 2019 10:00 pm
by sven
akkamaddi wrote:I've just installed this, but the control click does not seem to be opening anything in VS Code. Does this still work?


It should still work. I just installed it on a new computer, tested things out, and ctrl-click does work for me. But note that to enable debugging, you need to launch SiS from the VS-code debugger tab, not via Steam. (That "launch" configuration sets up some command-line switches and other things that are necessary to make the whole live coding system work.)

Also note that ctrl-click doesn't work everywhere in the game. One good place to test it is from the initial Race descriptions in the start-game menu.

Re: Debugging with VS Code

Posted: Mon Jul 22, 2019 10:15 pm
by sven
akkamaddi wrote:I'm trying to track down where "Capricious" is applied to morale.


As best as I can tell, implementing "Capricious" remains a "TODO". :oops: