Using out-of-engine custom code in RPG Maker

Hello everyone! New here and would like some advice.

(Not sure if this is the correct forum category to post in for this but this looked like the best place)

I'm wondering if it is possible to use a custom script (using a different language, in this case Haxe) to generate JavaScript code that does not directly interact with the existing RPG Maker code. This is probably unconventional and probably unnecessary, I could just get help on writing my own plugins, but I am very stubborn when it comes to learning new APIs and my brain can't cope with monolithic API References.

Basically, I'm looking at potentially writing some custom code (not via the plugin system) and just using a very simple plugin system to invoke the scripts when needed.

The reason to do this is because I wish to integrate custom game mechanics from another project into my RPG Maker game, without using the PIXI.js backend the RPG Maker engine uses.

I can definitely see this being possible, but would there be "ramifications" for this kind of custom behaviour, or is this perfectly fine and I don't have to worry about legalities?

(Also, after looking at how existing plugins integrate into the engine, it is very daunting to me, despite my C++/C# background.)

Also thinking of using C# to "extend" the editor if this is also allowed, as I'm not the biggest fan of the event UI, and working out custom movement scripts for multiple events is hard to manage. When I say "extend" here, I'm really just mean creating a separate application that modifies event data from maps made in RPG Maker instead of using RPG Maker itself for event management.
yes and no.

you can look into LunaTech_plugins that uses haxe code in their plugin,
but it also still require JS from the core to read things correctly.

you can also use css in JS or HTML. I dont know for PY though, but it
might be possible to read them if you code a JS to read them and for
what functions in the core to make them work.

there is also a game that uses JS and HTML windows around the game.
so C# and C++ might work too if done correctly.
I can definitely see this being possible, but would there be "ramifications" for this kind of custom behaviour, or is this perfectly fine and I don't have to worry about legalities?
You can incorporate whatever you like into your game, I'm not sure why there would be any legal concern. The RPG Maker EULA is right there for you to read...it says stuff like you can't use RPG Maker assets in another game creation engine, but that's not what you're talking about.

(Also, after looking at how existing plugins integrate into the engine, it is very daunting to me, despite my C++/C# background.)
Which part? I would consider it extremely simplistic - if you want an existing function to work differently, you simply copy it into your plugin file and change/add whatever you want. Whatever you write in a plugin is what happens instead of in the base code.

If you can describe what you find so intimidating, perhaps someone can offer an explanation that will make it easier for you to use regular plugins; your post, no offense, reads oddly.

You're talking about splicing code in an entirely different language into your game, and it seems that if you're competent enough to implement that, it should be pretty easy for you to read existing code and see how it works. My prior experience is entirely in C/++ and reading everything makes sense, aside from a few bits of JavaScript-specific syntax that I had to Google.

Also thinking of using C# to "extend" the editor if this is also allowed
Why not? It's a file, you manipulate it however you like. Note that, again, in the EULA, there's some provision about a certain percentage of the game being made inside of the RPG Maker editor in order to function under the RPG Maker license. Sounds like you should just read carefully through the EULA for most of your questions here.

(But, again, if you find it just casually doable to write an entire program that would replace the event editor, how can it be difficult for you to read plugin code?! 🤣)
Although it's not my nature to discourage OP, I think the effort is not worth it this time. Back then, when RPG Maker MV came out, I was also confused by those big files, but after a while, I understood how writing plugins work, and I think the system works well.

Basically, I'm looking at potentially writing some custom code (not via the plugin system) and just using a very simple plugin system to invoke the scripts when needed.
But why not via the Plugin system? This system is already really simple, I think you cannot go more simpler than that.

The reason to do this is because I wish to integrate custom game mechanics from another project into my RPG Maker game, without using the PIXI.js backend the RPG Maker engine uses.
So what exactly do you want to do? Do you want to add some code into RPG Maker's code or more like copy some of RPG Maker's code into your game?

Also thinking of using C# to "extend" the editor if this is also allowed, as I'm not the biggest fan of the event UI, and working out custom movement scripts for multiple events is hard to manage. When I say "extend" here, I'm really just mean creating a separate application that modifies event data from maps made in RPG Maker instead of using RPG Maker itself for event management.
Here's an attempt to make an alternative editor. While it does not focus on eventing, it proves that it's possible to program an editor:
I don't think it is mentioned enough here.. but literally all JS has to offer as a fully functional programming language is available for use with RPG Maker, it only appears limited because what is relevant to the API has been exposed. Get pro at JS and you can probably do the same wild things you can do as with other languages you're pro at.
Sorry guys! Looks like the OP from the other thread (Tristan9510) is a spambot that copied an alread existing thread.
I've moved all your posts to the original thread, hopefully @tienery sees them this way.
Lot's of replies and where to start...

you can look into LunaTech_plugins that uses haxe code in their plugin,
but it also still require JS from the core to read things correctly.
Had a quick look at that code and looks interesting, I'll have to try that out at some point.

If you can describe what you find so intimidating, perhaps someone can offer an explanation that will make it easier for you to use regular plugins; your post, no offense, reads oddly.
No offense taken. It's not the content of the code that's the problem, I just have a love/hate relationship with anything to do with the Web and it continuously frustrates me every time I try using web code. This is my own personal problem, of course. However, I'm getting older and not younger, my brain is not as docile as it once was.

I learned programming 16 years ago and loved learning new things. Now, not so much. I prefer to stick to what I know and my brain gives me a kick anytime I try to force myself to learn something new unless it's exceedingly simple, like a dear imgui.

Also, my brain is slower than it was. With working a full-time job, the time investment required to learn a new API with a language I barely use is just not an ideal situation. That's why I decided to use RPG Maker in the first place to make my first game, because I really want to make one but need a few shortcuts, as I don't have the time to work on my game as much as I would like to on my busy schedule.

Still want the game to be good, though, of course. Just not sure how to approach some of the more custom features of the game.

So what exactly do you want to do? Do you want to add some code into RPG Maker's code or more like copy some of RPG Maker's code into your game?
My plan was to use Kha, a Haxe library, to generate WebGL code in JavaScript, which would be invoked via plugin commands that execute the WebGL render code rather than RPG Maker's engine code, but still keep data shared among the two codebases.

This probably sounds incredibly stupid and a waste of time, and may be worth just using PIXI.js instead as that's what RPG Maker uses, but even then it may still be a little silly to try to use PIXI.js directly and not just use the plugin system.

Since writing this post, I have had a look at tutorials for the plugin system. Coming from a C# background, my brain works on the notion that you just "write your code", link it up to the editor/engine, and bingo, it just works. Basically a DLL file within which contains a likely `interface` with which the main engine/editor detects and runs the plugin from that.

Obviously, based on what I've seen, that is practically what RPG Maker does, but I have noticed there is a slight caveat in that it is not so obvious when things are initialised, updated, and rendered. From what I can tell, there is the requirement to use function overriding, which is error-prone and can lead to unexpected behaviour. Plugins can easily collide in this type of environment.

From past experience, I would prefer an approach where you have a common interface which you create (inherit in the case of C#), and tell the foreign code system to use the class created from that interface.

So, for example, you might have an
Code:
init
for initialising your plugin,
Code:
render
for your render code, and
Code:
update
for real-time updates. You create your class and then call
C#:
Plugin.RegisterClass(typeof(MyClass));
or something like that.

(But, again, if you find it just casually doable to write an entire program that would replace the event editor, how can it be difficult for you to read plugin code?! 🤣)
To reiterate on what I said above, but also JavaScript is just an awful language. There is no type checking, so you get all sorts of weird behaviour. There is no concept of integers, so if the floating point sums offset by 0.000000001 which it can sometimes do, you get back numbers you don't want, breaking your code and you're left wondering how it happened.

This behaviour has probably been fixed for ages and I'm just not aware of it (as you can tell, I don't use JavaScript much), but I do remember it being a thing when I was first taught it.

So, yes, I understand JavaScript quite well and understand the code, but it's not reading the code that's the problem. It's the language I have a problem with, that's why I was considering using Haxe instead as I at least have a compiler telling me if something is wrong.
I gotcha.

I just have a love/hate relationship with anything to do with the Web and it continuously frustrates me every time I try using web code.
I mean, aside from that being kind of the intended use when JavaScript was made, it's really not "Web code" in RPG Maker. As I'm sure you know if you've looked through it, the engine's code reads almost identically to something you'd see written in C/++ (I haven't tooled around with C# to know if it's drastically syntactically different).

Maybe if you're getting into stuff with graphics rendering, and the code is doing it in the way the Web browser interface requires, but then that would be Web code regardless of the language you use.

Plugins can easily collide in this type of environment.
I would say "sometimes" rather than "easily." Because of the way the functions are aliased, as you progress down the plugin list each one will take any reproduced function from a prior plugin and then add its own bits to it. So you really only run into conflicts if multiple plugins try to overwrite the same function without aliasing.

JavaScript is just an awful language. There is no type checking, so you get all sorts of weird behaviour. There is no concept of integers, so if the floating point sums offset by 0.000000001 which it can sometimes do, you get back numbers you don't want, breaking your code and you're left wondering how it happened.
I also don't love the lack of strict typing, or how loose the error handling can be. But I've never seen the behavior you describe.

That being said, if the approach you describe is what you want to do in your game project...there's no legal reason you can't.
There is no concept of integers, so if the floating point sums offset by 0.000000001 which it can sometimes do, you get back numbers you don't want, breaking your code and you're left wondering how it happened.
If you use some other language that then compiles to javascript anyway (which is how I understood your approach) you wouldn't be protected from that anyways, right?

I also have to second @ATT_Turan : At least to me something like that has never happened.
If you use some other language that then compiles to javascript anyway (which is how I understood your approach) you wouldn't be protected from that anyways, right?

I also have to second @ATT_Turan : At least to me something like that has never happened.
asm.js, for example, mimics the integer type by doing something like this:

JavaScript:
return (x+y)|0

So bitwise OR actually maintains the integer value result, in order to get effective debugging when compiling using ECMAScript or the likes. I suspect the same will be the case for other compilers. This then means debugging results will be almost identical between the programming language and the target language.

It may be that browser's just better support integral numbers and forces the built-in interpreter to keep integers as integers. But in the past, as all number values in JavaScript are floating-point and not integers, the various web browsers that existed meant that JavaScript numbers would have different results, often meaning that your JS code might work perfectly fine in Chrome but not in Safari or IE.

But that's normally in a Web environment. This is mostly a non-issue with an RPG Maker game as most games will want to take advantage of floating-point values anyway, as they are more efficient for GPUs these days and almost always you don't need to use integers except where you need them, like array access.

Sorry to go off on a technical tangent, I get carried away easy.

Having looked at this tutorial, I can see how easy it is to work with plugins. Plus the huge reference list for plugins. So, although I'm not a fan of JS (mainly because of a lack of compiler or type checking), it may just be worth trying to work on something like this for the future.

I'll probably have a look at replacing the title screen as a starting point, see how I get on, and post questions if need be in separate posts.
Technically, what RM uses is just NWJS (someone said you could even migrate to Electron but IDK how). So if that is possible within NWJS, then it should be possible. I don't know anything about Haxe, so I can't help you there.

But, technical aside, it left me with a question. What are you going to take from RPG Maker?
- You are going to use custom code not interacting with existing RPG Maker code.
- You are going to use a custom editor.

This is basically you are making your own game engine.
But, technical aside, it left me with a question. What are you going to take from RPG Maker?
- You are going to use custom code not interacting with existing RPG Maker code.
- You are going to use a custom editor.
RPG Maker will still be used for the most part. Obviously there will be a lot of custom code put in as well as I would like my game to be unique, not a rip of RPG Maker resources just slapped together into trashware. This is a serious project, after all.

So, the tools and plugins will be used to replace mostly interface elements. Custom UI, custom battle system and an additional feature in the form of meditation sessions.

Most of this will be event based. I will have a custom editor I will build to manage custom data easier as using the in-built plugin parameters is not very intuitive.

I've been thinking about this extensively today but still wondering how to implement some of these.

Original thread: https://forums.rpgmakerweb.com/threads/using-out-of-engine-custom-code-in-rpg-maker.149725/