Giter Site home page Giter Site logo

justarandomgeek / vscode-factoriomod-debug Goto Github PK

View Code? Open in Web Editor NEW
97.0 8.0 21.0 3.67 MB

Factorio Mod Tool Kit

License: Other

Lua 38.96% TypeScript 59.90% HTML 0.66% JavaScript 0.13% Shell 0.04% Batchfile 0.04% PowerShell 0.11% CSS 0.17%
dap-server debugger factorio factorio-tool json-schema lsp-server vscode-extension

vscode-factoriomod-debug's Introduction

vscode-factoriomod-debug's People

Contributors

aweinand avatar bilka2 avatar chrisdias avatar deltius5kb avatar dependabot[bot] avatar dkhex avatar isidorn avatar jansharp avatar justarandomgeek avatar laar avatar muppet9010 avatar nexela avatar penguinencounter avatar quezler avatar sparr avatar supersandro2000 avatar weinand avatar ypetremann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-factoriomod-debug's Issues

QUESTION: How to setup a development environment?

How to setup a comfortable development environment?

So far I haven't used the debug mode yet, because I don't really have an idea how to use it.
Current setup: I have

  • a Factorio folder with bin and mods folders for each mod I develop. In each mods folder I have the mod to test and all dependent mods. (I know, managing the mod-list.json would also be possible, but not implemented because it works as it is)
  • 'Factorio'
    • 'bin/...'
    • 'mods-Test1'
      • 'Test1Mod.zip' (The mod to test)
      • 'DependencyMod' (one or more mods which I need for a test)
      • 'mod-list.json' etc
    • 'mods-Test2'
  • a Development folder with all mods I develop
    • 'Test1Mod' (with the workspace file and some .git, .vscode folders)
      • 'src' (the content of the mod, as in zip file)
    • 'Test2Mod'

To test (without debug) I call a batch file which copies the zipped src folder to the mod directory and than I call the factorio.exe with parameter

  • factorio.exe --mod-directory PATH

With this setup I have a test environment for each mod.

BUT now I want to debug finally (as I am actually used to for C#)

  • I installed 'Factorio Mod Debug' and configured the launch.json
  • I open my workspace file for the mod to test
  • I Press F5 to start debug. so far so good, factorio starts (using the mods folder)

Now the problems begin:

  • How do I get the currently executed source code to make breakpoints?
  • or How to I start factorio with the current code (w/o copying it each time)?
  • How do I pass parameters to use a different mods folder? (--mod-directory PATH)
  • Or how would you set it up to test/debug all mods properly?

for you ideas and tips I would be very grateful

0.18.26 is not doing anything, 0.18.25 is working as intended

"Install Another Version" via vscode's context menu and select 0.18.25: Everything is working:

  • The section "source control: factorio mod packages" is filled with content (my mod) and for the mod the icons appear.
  • Pressing F5 launches factorio with the correct parameters.

With the latest (0.18.26) version:

  • The section "source control: factorio mod packages" is empty (showing a loading circle when hovering over it, but stays empty).
  • Pressing F5 does nothing (the UI overlay with the 6 buttons appears but disappears seconds after).

Don't know how to track down the issue or help with finding the causs... If you need anything that could help let me know

Recommends LuaRandomGenerator when math.randomseed() is used in data stage

18.073 Loading mod steelaxe-subscience 1.1.1 (data.lua)
math.randomseed() has no effect in Factorio. Use LuaRandomGenerator for custom seeded streams
@__steelaxe-subscience__/science.lua:47

I really like the warning in general, but for the data and settings stage recommending LuaRandomGenerator isn't ideal since it's not available there.

BUG: changelog BOM cause "Line not in valid block"

As the title says, if the changelog file is in UTF-8 with BOM, then it will cause an "Line not in valid block" error.
Should ignore about BOM or cause an error like "unwanted BOM"
As far as I know factorio don't mind about this BOM so I'm pretty sure it can be ignored

Prevent "Prototype Caching is enabled" warning?

I'm debugging with a large number of prototypes at the moment, so often have the prototype caching enabled to speed the launch.

Everytime I debug in vscode I get the "Prototype Caching is enabled" warning and click "Continue anyway"... it never seems to fail.

What please would be the symptoms of "conflicts with the final portion of debugger initialisation"?

Is there a way to prevent the warning?
If not, could we please have a "remember my choice" option or launch.json option to prevent the warning?
FactorioDebuggerProtoWarning

Error when setting train schedule to invalid rail target locks up debugger

If i set a train schedule record of type rail to a non existent entity the debugger just stops. It doesn't freeze, but nothing progresses and no error is shown. The base game run without debugger shows an invalid rail entity error.

Concept code that breaks when in a mod, just needs a train somewhere and NO track at {0,0}:

local train = GET A LUATRAIN REFERENCE
train.schedule = {
    current = 1,
    records = {
        {
            rail = game.surfaces[1].find_entity("straight-rail", {0,0})
        }
    }
}

version name in mod directory

When I create a modpackage the top directory has the modversion at the end of the name. This is actually no longer necessary and makes developing and debugging the mod more difficult. Is there a setting to change this?

Feature request: Make the default for git_publish_branch also accept "main"

Since GitHub has made "main" the default branch name for new repos, it would make sense to accept it as a default branch to publish from. Obviously that would break things for current users though, so perhaps git_publish_branch could also accept an array of strings, with ["main", "master"] being the default value.

VS Code Version Error

What version of VS Code should I be using to install the extension? When I try to install it I get an error message that it is not compatible with the current version of VS Code (1.41.1).

Multiline string settings are now supported in the settings editor

Ref microsoft/vscode#79571

Hi! Just a note that you can now add the "editPresentation": "multilineText" key-value pair to any string setting that can take multiple lines. In the settings editor, the setting will then display a textarea rather than a single-line inputbox. The feature is currently available in the Insiders edition of VS Code, and will be released to Stable in around two weeks.

FEATURE: Add pre debug script

I have a mod where some data generally follow what is really in the mod, for example path and size of images (so if I double the image resolution it can scale it down). for that I use a script that generate a lua file with a list of all properties factorio can't access by itself.

Your tool permit to add some scripts, for prepublish, publish, datestamp, prepackage ... could you add predebug to run just before (re)starting.

Result of using serpent.line in __DebugAdapter.print is "<error>"

Hey, I am trying to print a simple table (e.g. {x = 235, y = 430}) concatenated into the printed string with serpent.line with __DebugAdapter.print. This results in: __DebugAdapter.print("Spawned ruin: Size " .. ruin.size .. " Center " .. serpent.line(ruin.center)) -> Spawned ruin: Size small Center <error>

Separating the serpent.line from the rest of the string results in this: __DebugAdapter.print(serpent.line(ruin.center)) -> <error>

Printing without serpent.line results in this: __DebugAdapter.print(ruin.center) -> { {<...>}, }, I have "Factorio > Debug > Expandable Print" turned off.

Printing with the built-in "print" with serpent.line results in this: print(serpent.line(ruin.center)) -> {x = -215, y = 55}

Based on this experimentation, it looks like __DebugAdapter.print is the problem here. I am using version 1.1.4.

workspace.md

The Lua.workspace.library type is expecting an array, not an object.

"Lua.workspace.library": {

/* Adjust these to match your Factorio install path */
"C:/path/to/factorio/data/": true, /* for __base__ and __core__ */
"C:/path/to/factorio/data/core/lualib": true, /* some basic libs can be required directly*/

},

Should be:

"Lua.workspace.library": [

/* Adjust these to match your Factorio install path */
"C:/path/to/factorio/data/", /* for __base__ and __core__ */
"C:/path/to/factorio/data/core/lualib", /* some basic libs can be required directly*/

],

Packages uncommited changes

Packaging files not in version control is a significant pitfall, because the typical development workflow using version control is that only the committed changes are released, but currently what is committed (and tagged) can be completely different from what gets packaged and released.

The possible solutions are:

  1. Checking out the current working tree in a temp directory and packaging from there
  2. Using git-archive like so, for example: git archive --format=zip -o test.zip master src (although this would require renaming the archived directory, so is probably not worth it)
  3. Checking whether the current working tree is clean and refusing to package otherwise (probably the simplest solution; the author can just use git-stash --all if needed)

When filename case mismatch, exception don't shows

A lot of times I have an exception, debug adapter successfully stops where the exception occured, it display the call stack, it point to line in the file where the error occured, I can inspect variables but when there is a filename case mismatch on the file where the exception occured, the error don't shows in the editor (and so I know there an error but I don't know why) ...

control.lua:

require("ErroringFile")

erroringFile.lua:

error("some error")

BUG: incorect error path in vscode

If I do :

require("__mymod__.overwrite.__othermod__.path.to.my.script")

or

require("overwrite.__othermod__.path.to.my.script")

I see in the call stack

MOD/mymod__/overwrite/__othermod_nil/path/to/my/script.lua

where it should be

MOD/mymod_0.18.0/overwrite/__othermod__/path/to/my/script.lua

This bug occur in the vscode part.

[Request] Add name of the mod to tags when you commit a new version

Hello,

I'm using your addon to develop the 5Dim mods in my case there are several mods to develop, it's not just one.
My request is that in the automatic commit when uploaded to the portal (I'm using the publish mod button directly) this commit is uploaded with a tag that includes the version (for example 1.0.1) but being several mods as it is my case it's difficult to see exactly which mod has been updated.

Is there a way to add this field to the commit tags?
It would be something like 2 tags (for example [5dim battlefield], [1.0.1]) one with the name and another with the version or a single tag that includes both (for example [5dim battlefield 1.0.1]).
Maybe this can be done already and I don't know how to do it?

Greetings and thanks!

undocumented __debugline "short" parameter

[...] the metamethod __debugline, which can be [...] a function which takes the table as an argument and returns a string.

The function also gets a second parameter (short) is this intentionally undocumented?

Support command line arguments

I would like to be able to add command line arguments to the debugger opening of Factorio. I tried adding these to the factorioPath debugger configuration variable, however, that just causes an error on running.

My old Factorio shortcut:
C:\FactorioModding\bin\x64\factorio.exe --window-size=1280x720

My attempted factorioPath variable line:
"factorioPath": "C:/FactorioModding/bin/x64/factorio.exe --window-size=1280x720"

I have confirmed that without the window-size argument the debugger can launch Factorio and operate successfully.

Failed to get upload token from Mod Portal: Error: NOT FOUND

If I try to "Upload to Portal" vscode kindly asks for a user and password.

In the terminal I get the following:

> Executing task: factorio: player-count-based-research-speed.upload <

Logging in to Mod Portal as 'Yenz'
Failed to get upload token from Mod Portal: Error: NOT FOUND
Terminal will be reused by tasks, press any key to close it.

After looking into the code I assume it's just that the mod doesn't exist yet ๐Ÿ˜†

Debug breakpoint inspection of inventory LuaItemStack crashed game

I inspected an item stack in an inventory during a breakpoint and the VS code debugger/Factorio crashed.

What I saw onscreen:
state inspection

Factorio log:
factorio-current.log

I called a function from the defines.events.on_robot_mined_entity event when a train wagon was deconstructed by a robot. I had a breakpoint in this function. The code went and got the fuel inventory of another entity on the map .get_fuel_inventory() and passed this to another function. Inside this inner function I hovered over the passed in fuel inventory, its contents list and then the item stack as seen in the screenshot. This is when it crashed.
Without the breakpoint the code runs inside the game fine.

debugadapter error when remote call itself errors

I'm not sure if the title is perfectly accurate, but a remote call that crosses the mod border that's given invalid aruments such as functions causes this:

__debugadapter__/debugadapter.lua:187: attempt to index local 'lastframe' (a nil value)

however looking at the source it seems very context specific so here are 2 example mods to fully reproduce it:
DemoMods.zip

QUESTION: How to specify startup parameter?

in launch.json I have specified
'"args": "--mod-directory "E:\Program Files\Factorio\1.1\mods-debug""'
but it seems not to work.

But may be this question is only one of many other. The main question is
"How to setup an development environment." But for this I will create an extra issue.

BUG: Typo in adjustMods handling

#11
If an adjustMods entry is already in mod-list.json then it duplicate the entry, if there wasn't it did nothing.
Now for each adjustMods entry, it create an entry only if it didn't exist, otherwise it will modify the existing entry

Frozen on "loading mods" when using 0.18.00 as mod version number

The behaviour is pretty similar to #21, F5 to launch game which then gets stuck on "Loading mods". I'm adding the output for completeness:

using auto-detected config.ini: C:\Users\Erik\Documents\GitHub\Factorio\config\config.ini
using modsPath C:/Users/Erik/Documents/Factorio/mod-dev (launch)
package install debugadapter {"using":"1.1.4","from":"existing","previous":false}
debugadapter enabled in mod-list.json
using dataPath C:/Users/Erik/Documents/GitHub/Factorio/data
loaded ChangeMapSettings 4.1.0 from workspace file:///c%3A/Users/Erik/Documents/Factorio/mod-dev/ChangeMapSettings
loaded base from data file:///c%3A/Users/Erik/Documents/GitHub/Factorio/data/base
loaded debugadapter 1.1.4 from mod zip file:///c%3A/Users/Erik/Documents/Factorio/mod-dev/debugadapter_1.1.4.zip

For me, the cause seems to be a mod with "version": "0.18.00", in the info.json. Changing the version to 0.18.0 allows the game load as expected. Note that launching the game without the debugger works as expected even with mod version 0.18.00.

Headless support

I need to debug scenario on server and don't want to restart my factorio client every time.

Can not set breakpoints (unable to translate path)

I have loaded the mods directory in VSCode

loaded Kux-CoreLib 2.1.0 from mod zip file:///e%3A/Program%20Files/Factorio/1.1/mods/Kux-CoreLib_2.1.0.zip
loaded base from data file:///e%3A/Program%20Files/Factorio/1.1/data/base
loaded debugadapter 1.1.11 from mod zip file:///e%3A/Program%20Files/Factorio/1.1/mods/debugadapter_1.1.11.zip
0.925 Loading mod settings debugadapter 1.1.11 (settings.lua)
unable to translate path file:///e%3A/Program%20Files/Factorio/1.1/mods/Kux-BlueprintExtensions/data.lua
0.941 Loading mod core 0.0.0 (data.lua)
72.663 Checksum for script Kux-CoreLib/control.lua: 25276010273
unable to translate path file:///e%3A/Program%20Files/Factorio/1.1/mods/Kux-BlueprintExtensions/control.lua

for all files I set a breakpoint I get the error " unable to translate path ..."
If I copy the path to browser, it will show the file. So what is wrong?

How to edit the default factorioPath?

I've been debugging loads of different mods lately - love your work thank you!

I can't figure out the VS Code way of updating the default factorioPath - I've managed to edit the package.json for now, but I suspect it may be overwritten on your next update?

Disclaimer: VS Code just doesn't agree with me, so I know little about it.

Small imperfection in .cfg syntax highlighting

First of all thank you for this amazing tool! Allow me a bit of nit-picking, as I have nothing else to complain about ;)

I got the following line in the .cfg file of one of my mods with works perfectly well, the syntax highlighting is not ideal however:

control=(__CONTROL____1____)

Hope it's not that big of a deal to fix it.

1.1.8 install doesn't provide all globals

Generated API TypeDefs missing ComparatorString details

The API game.get_filtered_entity_prototypes filter can take a comparison value, but the generated TypeDefs don't provide a definition of its values.

API Call: https://lua-api.factorio.com/latest/LuaGameScript.html#LuaGameScript.get_filtered_entity_prototypes

The filter type of: https://lua-api.factorio.com/latest/Concepts.html#EntityPrototypeFilter
takes a comparison field for some of its types: https://lua-api.factorio.com/latest/Concepts.html#ComparatorString

The generated TypeDef looks to have this as a class, but no fields on it. So the latest Sumneko 3.4.1 won't ever accept a value for it.

Example code where I tried to force the type inline:
local turrets = game.get_filtered_entity_prototypes({{filter = "turret"}, {mode = "and", filter = "build-base-evolution-requirement", comparison = "โ‰ค" --[[@as ComparatorString]], value = evolution}})
Gives error still:
Cannot assign stringtoComparatorString.

globals like data are not defined

VSCode is saying all my globals are Undefined. data, game, script, defines. None of them are being recognized. What did I do wrong?

Extra info: I can't generate new versions of the mod correctly

Hello,

I've been trying to get the addon set up right for a while, but I think there's something I'm doing wrong.
When I increase the version of a mod it only makes the change inside the info.json, but it doesn't modify the folder name, this is correct?
When I generate a package from a mod it is generated inside the folder of that mod, shouldn't it be generated in the Mods folder directly? Is there a way to set this up?

Thanks you for your time and for this great vscode addon!

un-applied code changes break breakpoint release (Continue)

When in a breakpoint and you change the code in VS code and hit Continue the breakpoint finishes, but Factorio stays frozen?
I'm sure I used to write code while in a breakpoint before as it was good to inspect stuff in the current scope.
I know that the debugger lines wouldn't match up with what I had code wise if I'd changed it, but that's fine.

So in the past I could do this:

  • Hit break point
  • Look at state
  • Make code changes
  • Hit continue
  • the game continued

Now when I do this the game doesn't continue, it just stays frozen, bug the debugger says its not stopped.

After continuing the game I would then save my code, apply it to the mods folder and reload the save to have it applied.
It used to be if I stepped through with code changes the debugger would be out of sync with the code I now had on screen (same AS full VS in c++/c#)
I think it started 2 VS Code updates ago.

Why is the debugadapter mod being disabled when I start debugging?

I'm attempting to use the plug-in on MacOS against the Steam version of factorio 1.1.21, so I'm unclear if this is a Mac issue, a Steam issue, or a me issue. The problem is the debugadapter mod keeps being disabled when I go to launch factorio with the F5 Start Debugging option inside VSCode. This makes the game quickly fail during loading with the error:

2.733 Error Util.cpp:83: "--instrument-mod debugadapter" specified but named mod is not enabled

I have tried to manually enable the mod in the game before quitting and trying the debugger, but I've observed the debugadapter enabled setting inside mod-list.json keeps getting reset to false. If I manually edit the json to enable it, by the time Steam gives me the confirmation prompt on if I want to launch factorio with command line arguments, the value has been reset to false - so something is disabling it.

If I manually change the value back to enabled:true before accepting the Steam confirmation dialog, the game loads fine with the mod enabled, so I suspect the extension is trying to enable the mod and failing somehow - instead disabling it. Whether that's an extension bug on Mac or a misconfiguration on my end, I'm unsure.

Here's my launch config:

{
    "type": "factoriomod",
    "request": "launch",
     "name": "Factorio Mod Debug",
     "factorioPath": "/Games/Steam/steamapps/common/Factorio/factorio.app/Contents/MacOS/factorio",
     "modsPath": "/Users/<me>/Library/Application Support/factorio/mods/",
     "configPath": "/Users/<me>/Library/Application Support/factorio/config/config.ini"
},

I get the same behavior even if I omit the modsPath and configPath values.

Undefined fields on game.forces and game.surfaces

I'm assuming it's because they are CustomTables and not tremendously well-defined, but all of game.forces.player, game.forces.neutral, game.forces.enemy and game.surfaces.nauvis should be defined. Unfortunately, every reference to them is getting reported as an "undefined field" in my codebase!

Add search option to profiler view

Sometimes other mods (that I do want to enable for testing with) take up the full width of the profiler view, such that I cannot see my own mod anymore. It would be very helpful to have a searching functionality in the profiler view such that I can search for my own mod.
Or alternatively/additionally, just an option to zoom in without clicking.

globals still undefined after 1.1.21

Hello, sorry to bug you again!
My temporary fix for this issue is to add the globals to the lua diagnostics list...
"Lua.diagnostics.globals": [ "mods", "table_size", "log", "localised_print", "serpent", "__DebugAdapter", "__Profiler", "data", <-- "script", <-- "defines", <-- "game", <-- "remote", <-- "global" <-- ],

But I'm still getting yellow squigglies below fields like "created_entity" in this example:

function(event) if event.created_entity.supports_backer_name() then event.created_entity.backer_name = "" end

Could you tell me how to manage my library settings manually to fix this? Thank you!

Generates some classes wrong from game runtime-api.json it seems

Looks like the generated runtime-api.lua from the runtime-api.json is going wrong in a few cases. An example I hit with current versions of Factorio and Debug extension is:

on_chunk_generated.area is listed as being: BoundingBox<int,MapPosition<int,double>>
meaning EmmyLua rejects on_chunk_generated.area.left_top

I assume this was mean to cover that a BoundingBox's northwest position can be accessed by either .left_top or [1].

Also similar issue with the MapPosition within it not listing .x as valid, but expecting [1].

Factorio Game: 1.1.58
Factorio Mod Debug: v1.1.13
I've re-run Generate TypeDefs and reloaded VS Code after this.

How do I setup these vs-addon and factorio to work with my mod?

I can't get to the point when any output or breakpoints are sent to VS Code...
Sadly there is no video tutorial how this can be done for the very first time

  • "Adjust the paths and launch settings as required." Can you give an example please?
    Is this correct?
    {
    "type": "factoriomod",
    "request": "launch",
    "name": "Factorio Mod Debug",
    "modsPath": "D:/G/Factorio/Factorio_0.18.18/mods",
    "configPath": "D:/G/Factorio/Factorio_0.18.18/config/config.ini",
    "factorioPath": "D:/G/Factorio/Factorio_0.18.18"
    }

  • I run factorio with this cmd
    D:\G\Factorio\Factorio_0.18.18\bin\x64\factorio.exe --instrument-mod debugadapter
    Is that enough?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.