Using External Applications to Process RPG Maker Output
In this article, I discuss how you can use external applications to handle output generated from RPG Maker.
It is well-known that RPG Maker does not support many things natively, such as the ability to make network requests. It is possible to write libraries that will allow us to implement this functionality, but personally I don’t see much point in re-inventing the wheel when it is well-developed everywhere outside of RPG Maker.
Interprocess Communication
According to Wikipedia:
In computing, inter-process communication (IPC) is a set of methods for the exchange of data among multiple threads in one or more processes.
So basically imagine you have an application that spawns or forks a child process. Your main application can redirect the child process’ standard input, standard output, and standard error streams to allow for communication between the parent and the child processes directly.
That is just one example of how you can implement IPC, and at this point it is about as much as I know about the topic.
Writing the External Application
So let’s look at what our application should do
- It should launch an instance of Game.exe
- It should redirect stdin and stdout
- It should poll the game’s stdout for any data
Remember that we are simply handling output from RPG Maker, so we are not worried about sending data to the game.
I picked C# to write my application launcher. There is no particular reason why I picked it; I just happen to be familiar with it and it will likely run on others’ Windows machines without installing anything. Sample code will be provided at the end of this article.
You could just as well use Java, Python, C++, or anything that supports forking processes, which should be just about anything.
Our Application in Action
To show that it works, I create a sample project where an event simply writes some text to the console.
A typical event that will run when you trigger it.
When I run the game using my custom console and trigger the event, this is what I see:
Resources
I’ve included a copy of the demo I set up. It includes a compiled executable. I’ve also included the C# source code.
Instead of running Game as you normally would for an RM game, run the RMConsole. Then talk to the NPC and look at the console.
Moving Forward
Notice that my custom application reads the output from RPG Maker and then writes it to its own console. Rather than writing it to console, you could pretty much do anything with it, such as making an HTTP request and send it off to a web server. Once you’ve connected the game to your own application, the possibilities are limitless.
Right now, we have managed to get data out of RPG Maker. However, to really close the loop, we need to be able to send data into RPG Maker, which I haven’t figured out at the time or writing. Maybe you can figure out how to do it!
Spread the Word
If you liked the post and feel that others could benefit from it, consider tweeting it or sharing it on whichever social media channels that you use. You can also follow @HimeWorks on Twitter or like my Facebook page to get the latest updates or suggest topics that you would like to read about.