biud436 / vscode-rgss-script-compiler

🏰 RGSS Script Compiler is the extension of Text Editor called Visual Studio Code. if you are using this extension, you can modify script files and create the bundle file called Scripts.rvdata2 in Visual Studio Code without internal Script Editor directly.
https://marketplace.visualstudio.com/items?itemName=biud436.rgss-script-compiler
MIT License
13 stars 3 forks source link

Test Mode (with console and debug scene) Game Play #16

Closed SnowSzn closed 1 year ago

SnowSzn commented 1 year ago

Hi there!

Could you considerate implementing support for the native RPG Maker VX Ace console?

In RPG Maker VX Ace editor, when testing the project, game.exe process is created and this one allocates its own console (if user desires to by activating an option in the editor) and modifies the Ruby standard output and standard error. It also activates the $TEST flag (this flag is used to call the in-game debug scene to modify variables and switches).

In the public version of the extension, the game only runs in normal mode (without $TEST flag activated) and using the VSCode extension's output channel as the standard output.

It would be amazing if you could allow the user to decide whether to use the VSCode or let the game allocates its console, because in my case it seems there are problems when it comes to show the debug messages to the VSCode output, probably the contents are not flushed to VSCode therefore messages are not displayed the moment they are written to the active output.

RPG Maker VX Ace games support two command-line arguments to do this:

You can test this by simply setting the working directory to the game's folder and running start '.\Game.exe' "console test" in shell. If done correctly you will be able to press F9 key to call the in-game debug scene when playing the game.

Since (property) GamePlayService._args: any[] is available it could be used to determine whether a console should be allocated or not. I modified this method in "TestGamePlay.js" to allow the process allocate a console for testing and it works nice.

makeCommand() {
     this._args = ["console", "test"];
}

As far as I know, this always works for RPG Maker VX Ace projects, but for RPG Maker XP it is different since it does not support console allocation so console argument will always be ignored. I tried running start '.\Game.exe' "test" with a RPG Maker XP project and it seems that test command does not work neither. I used Process Explorer by Microsoft to analyze the game.exe strings and found a "debug" string.

I tried executing game.exe with the "debug" argument like start '.\Game.exe' "debug" but still nothing happens, so it seems this feature was added for RPG Maker VX Ace and won't work for RGP Maker XP.

To implement this method, the generated file: rgss-compiler.json could be used to add a new key->value and determine whether to use VSCode console or let the game allocate its own console, something like: "VXAceConsole": true You can also use the rgssVersion key ("rgssVersion":"RGSS3") to determine whether allocating a console window is supported based on the editor used (RPG Maker XP/RPG Maker VX Ace) or not.

For the test argument, I think it won't need an option on the JSON because test play should always run with that option enabled. But if desirable, you could create two separate commands Run Game (Normal Mode) and Run Game (Test Mode) and alternate the use of test argument between these two commands or just add another key->value pair in rgss-compiler.json like: "testMode": true.

biud436 commented 1 year ago

it is possible to implement that you said.

I tried executing game.exe with the "debug" argument like start '.\Game.exe' "debug" but still nothing happens, so it seems this feature was added for RPG Maker VX Ace and won't work for RGP Maker XP.

To use the console window in the RPG Maker XP, You must use third party script for Console Window that includes the function AllocConsole.

For instance, https://github.com/biud436/RGSS3/blob/master/XP/RS_ConsoleForRMXP.rb

SirenSingsCurse commented 1 year ago

I am an RPG Maker XP user. Thank you for your wonderful plugin! It was very helpful!

By doing the following, I was able to start in debug mode of RPG Maker XP.

makeCommand() {
     this._args = ["debug"];
}

Thank you for your consideration.

biud436 commented 1 year ago

@SirenSingsCurse thank you. I will try