How-to setup and configure an environment to do tracing into lua and modding scripts

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

waadaa85
Posts: 46
Joined: Tue, 8. Feb 22, 01:14
x4

How-to setup and configure an environment to do tracing into lua and modding scripts

Post by waadaa85 »

Hi,
Sorry for the WoT, I'm beginning in X4 Modding and, like many people, I found the learning curve over it a bit steep :-). Even after a 20-yrs+ career as computer engineer. I've done my share of coding in C/C++ and now learning lua.

So, following a discussion with ChemO'Dun over reddit (https://www.reddit.com/r/X4Foundations/ ... ns_plans/ regarding the station editor and an opportunity to improve its plans' management with a mod. I started digging in through the wealth of docs, threads, github repos, wiki and all that span over a decade now (if I includes XR modding stuff).

In order to better understand the inner working of X4 game engine before modding anything, I try to do a trace through a specific module (Station-configuration.lua) to see which functions are called/used when a new plan is brought in the editor from the "load plan" button.

I set a dev environment on my windows 10 rig, with VSCode and ChemODun's tools for debugging and codeComplete. all .cat files (both core and extensions) have been unpacked and good to go.

I launched X4 with the prescribed starting parameters:

Code: Select all

x4.exe -debug all -logfile x4debug.log -scriptlogfiles x4scripts.log -prefersinglefiles 
In VSCode X4Debug extension, I created the launch.json and configured it. I also created a creative game startup to do the tracing. Several problems occurs:
  • 1-The X4.exe doesn't attach to the VSCode debug console for some reason, nothing goes through it...
    2-x4debug.log fills with lots of things but not the specific lua code I want to trace on (i probably need to insert some print lines within the lua code, as (according to kuertee's readme on UI support API) lua debug libraries will not work properly. I'm assuming the same for the trace libraries)
    3- I tried different .bat files to redirect/filter the logs but nothing is actually written in the scriptlogfiles' files (except for the x4debug.log) I probably missed something somewhere for the scriptlogfiles to work while executing
Any help is welcome to point me in the right direction.

Regards,
WaaDaa

"Station Administration would like to remind you to keep children away from the airlocks"
waadaa85
Posts: 46
Joined: Tue, 8. Feb 22, 01:14
x4

Re: How-to setup and configure an environment to do tracing into lua and modding scripts

Post by waadaa85 »

Quick notes:
  • protect UI mode is OFF in extensions settings
    SirNukes' Mod support API (1.95 latest) and python server is installed and running (v.1.4.3)
    SirNukes' Mods emmydbg and debug-info extensions are ON.
    kuertee's UI Extension and HUD is ON
WaaDaa

"Station Administration would like to remind you to keep children away from the airlocks"
User avatar
ChemODun
Posts: 591
Joined: Mon, 12. Feb 07, 21:58
x4

Re: How-to setup and configure an environment to do tracing into lua and modding scripts

Post by ChemODun »

Hi.

Some points:
  • At first - welcome :-)
  • At second - I'm on a final stage with trade editor for stations, as addendum to config exchanger, so, please take it in account :-)
  • My X4 Debugging extension for vs code is only for scrips. I.e. aiscripts and md ... And there is a pseudo debugger, i.e. it is only parses error messages in a current extension scripts. So, it is not for Lua.
  • For Lua debugging please use - [TUTORIAL] X4 UI Dev with debugging (VSCode and EmmyLua))
Multiply entropy by absolute zero

Freedom in space
waadaa85
Posts: 46
Joined: Tue, 8. Feb 22, 01:14
x4

Re: How-to setup and configure an environment to do tracing into lua and modding scripts

Post by waadaa85 »

Thanks for the nfo ChemODun.

I'm working on the Construction Plan merging mod I told you earlier. I've modified the station editor's config menu to add a checkbox and currently wiring the inner stuff.

I'll check the tutorial you provided right away :-)

cheers and Happy Holidays.
WaaDaa

"Station Administration would like to remind you to keep children away from the airlocks"
User avatar
ChemODun
Posts: 591
Joined: Mon, 12. Feb 07, 21:58
x4

Re: How-to setup and configure an environment to do tracing into lua and modding scripts

Post by ChemODun »

You are welcome and Happy Holidays too!
Multiply entropy by absolute zero

Freedom in space

Return to “X4: Foundations - Scripts and Modding”