Debug/command console via command prompt

  • I've been fiddling around with writing/appending to txt files via nwjs but want to take it a step further. I'm curious if what I want to do is possible and I'd rather use a cmd interface over a plain text-file if possible.

    I know I can open up command prompt up via nwjs' run shell in construct 2 and can also utilize write/append in text files to write log messages.

    Is there a proper way to format write/append text to said .bat file so it outputs correctly formatted log messages to the opened command prompt window? I'm trying to figure out how to properly add stuff like "echo" and "title" but cmd seems to ignore newline.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm not sure I understand your problem. So you are trying to create a BAT file from C2 and then execute it?

    This code works fine for me:

  • Thanks for showing that to me. I get how to properly format it now but I want to keep the cmd window open...like if I want to append additional messages while the window is still open (and therefore preferably keep it to one window), is that possible to do? Or would I have to append and do open shell again, which might open a second command prompt window?

    What I'm saying is that I want to append messages to the command prompt window (and have them show up in real time in the prompt window) while it is open and 'live' but I'm not sure if I can do that, based on my guesses of writing permissions. I could be wrong though.

  • I don't think it's possible to control the cmd window after it has been open from C2. You can do what you want with a "smart" batch file or vbs script.

    For example, this bat file displays the content of log.txt on the screen every second:

    title HEY
    

    Echo off [/p] :loop [/p] if exist log.txt type log.txt [/p] if exist log.txt del log.txt > nul [/p] timeout 1 > nul [/p] goto loop [/p]

    You can write a new log message into the log.txt while the bat-file is running and it will appear in the cmd window. (if the file doesn't exist, write to it. if it exists, append to it)

    I don't quite understand why do you need this. If this is just to display logs, why not use console log (F12)?

  • I'm using nwjs and I'm not quite sure how I can access the console log compared to if I ran my project in chrome, firefox, etc. This actually works for me quite well, thanks.

    It's mostly because I'm working on a robust in-game debug mode/command console (like you see in Minecraft, Fallout/Skyrim, etc, that sort of thing as well along with general debug-utils) to sort of replace Construct 2's debugger partially, so end-developers who use my A-RPG Gamekit can debug their own projects to a large extent/usability than having to open up C2's own native debugger.

  • Just press F12 in NWJS window to open console.

    There is also an action "show dev tools", so you can open it from an event.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)