Help using JavaScript for a hangman game

Hi!! I'm currently creating a small demo of a game for my senior project for college, and one of the puzzles I want to make is a hangman puzzle that has 10 errors.

I have tried doing it with regular else/if conditionals, but I find the process to be way too taxing on my computer (which is pretty old) and causes the game to freeze up after the first few turns.

The other thing, is that I want to add the letters to the empty lines once they're guessed right, and while I can do the assets, I don't really know how to make a variable for them to switch.

Thankfully, I have an uncle that knows javascript programming that is willing to help me out, but when we tried a simple dummy code, the javascript just loops without ending and doesn't excecute inside the game, rather opening an emerging window.

I'm wondering if rpgmaker needs a certain code that has it so it runs inside the game instead of replacing/creating a new window? I'd be really thankful for any help!

Event SC:
Captura de pantalla 2024-07-28 153840.png
You're going to have to post your event page if you want help identifying the problem.
creating one require 2-4 pages and choice to input a letter
and a variable for wrong letters and a variable array.

if you do it right, it should be pretty much easy by eventing it.
this is the test event we made for now (text is in spanish, sorry)
You're going to have to post your event page if you want help identifying the problem.
Captura de pantalla 2024-07-28 153840.png
ShadowDragon has the right idea. This is a problem of declaring arrays of letters, finding specified elements, and splicing them out.
creating one require 2-4 pages and choice to input a letter
and a variable for wrong letters and a variable array.

if you do it right, it should be pretty much easy by eventing it.
That's exactly what I'm asking, I don't know which choice input would be best/how to make it stop looping ^^;;
You might want to do some basic tutorials to see what event commands do. "Exit Event Processing" stops the current event from being processed, so it never turns self-switch A on. And since it's an autorun event, it will just start again on the next frame.
You might want to do some basic tutorials to see what event commands do. "Exit Event Processing" stops the current event from being processed, so it never turns self-switch A on. And since it's an autorun event, it will just start again on the next frame.
We're trying to make it so it starts as soon as the game is launched, but I'm still not quite sure if it'd better to do 'parallel'

I have done all the tutorials that come with the program, but this part still is confusing to me. Also, does that mean I should instead put self-switch on before 'exit event processing' ?
if you want to very basic non advanced way

create 1 parallel event or an common event with a loop/breakloop

set 1 event on a map (1 letter for each) of the word
1 switch (can be ABCDEF.....YXZ switch or selfswitch A and B
so you require scriptcalls to call this.mapId() and the eventID and letter
if the input letter is correct, else variable wrong +1 and push that letter
into the wrong array (this array can also be rechecked if it already has
it or does not.

but if you want it more advanced, than a plugin might be useful, but same
thing applies, but easier to use and call so you can use the name window
if you know the word.

the choices are more simple to use

- call letter
- say out the word

but it should be pretty much eventing to get it all, and maybe with HUDMaker
plugin or picture call for on screen is it easy doable 🙂 (up to 30 pictures max)
or long words or sentence up to 99.
Also, does that mean I should instead put self-switch on before 'exit event processing' ?
Do not use 'exit event processing' at all. There's no reason to. The processing will end when it reaches the last command anyway. It's meant to be used inside conditionals to end an event early.

Similarly "Break Loop" is redundant, since it's not inside any loop.
Just a couple of things.

Not all Java Script can be put into the Script Event Command and have it just work in MZ. The concepts generally work, but there are some differences.

If your only experience is doing the built in tutorial, I fear this might be a bit complex for you.

I would do this with the TextPicture and ButtonPicture default plugins that come with MZ. So you can display the letters of the alphabet, remove them once they are selected, and show them in the correct spot in the puzzle.

Did you want just one puzzle, which is fairly easy, or did you want multiple puzzles, which isn't terribly hard, but just a bit more work?

I would offer to make a demo of such a game, but that would be doing your school project for you so that doesn't seem good.

If you use TextPicture and ButtonPicture to display the letters that can be chosen, you don't need a parallel event to keep running. And you can use the Common Events that are called by clicking on a letter to erase the letter, check if the selection is wrong, and draw the letter in the appropriate place in the puzzle or draw the next part of the hangman figure.

While I might use arrays, you can pretty much do this with just Variables and Conditional Branches.
Just a couple of things.

Not all Java Script can be put into the Script Event Command and have it just work in MZ. The concepts generally work, but there are some differences.

If your only experience is doing the built in tutorial, I fear this might be a bit complex for you.

I would do this with the TextPicture and ButtonPicture default plugins that come with MZ. So you can display the letters of the alphabet, remove them once they are selected, and show them in the correct spot in the puzzle.

Did you want just one puzzle, which is fairly easy, or did you want multiple puzzles, which isn't terribly hard, but just a bit more work?

I would offer to make a demo of such a game, but that would be doing your school project for you so that doesn't seem good.

If you use TextPicture and ButtonPicture to display the letters that can be chosen, you don't need a parallel event to keep running. And you can use the Common Events that are called by clicking on a letter to erase the letter, check if the selection is wrong, and draw the letter in the appropriate place in the puzzle or draw the next part of the hangman figure.

While I might use arrays, you can pretty much do this with just Variables and Conditional Branches.
For now I only need this one puzzle.

The project is more of an art project that uses rpgmaker as an engine to tell a story (of which I'll only show a prologue segment with one puzzle as a proof of concept), but I'd still like to write the coding myself if possible, especially if I decide on continuing the project after graduating. (Hence why I got permission from my advisors to get help from my uncle)

The puzzle only has 7 correct letters. The hangman will be built if 10 incorrect answers are placed. still I'd like to have all options displayed since, while making the options, it's quite tedious to make the player flip through only 4 rows of letters at a time.
I did see from an older thread that someone suggested changing a character's name, instead. But I don't know if that'd be compatible with changing the hangman's image
Have you explored using TextPicture and ButtonPicture like I mentioned. Here is an example of a UI screen that is 100% Evented using those two plugins.

Puzzle Options Menu.png
Have you explored using TextPicture and ButtonPicture like I mentioned. Here is an example of a UI screen that is 100% Evented using those two plugins.

View attachment 312965
I _have_ used the TextPicture feature, but mostly to replace text with icons on the dialogue options, nothing as complex as this
Well, if someone else can't give you a very simple to follow solution, I will write out a description of how I would event this. It might require you to do a little research for anything you aren't familiar with, but at least it would be a solution.

In the meantime, I might have some tutorials on my YouTube page that might help with some aspects. If you have time and are interested in checking them out.
if someone else can't give you a very simple to follow solution
The solution isn't going to be simple because the OP has no programming knowledge on top of being a beginner at RPG Maker. The scripting way to do this is with manipulating strings and/or arrays which isn't that hard by itself, but making the user interface for this would be a lot more work.

The OP has nothing built already except an input prompt loop, which effectively means the forum is going to have to write the entire thing from scratch for the OP if they want to make a "simple to follow" guide. ShadowDragon posted a general outline of how you could do it, but it requires intermediate scripting and engine knowledge.

Is this a two player game or one? I.e. is one player inputting the answer word or is it picked from a pool of possible words by the computer?
Also, what time frame are you talking about? Meaning what is your deadline for having something?
Well, if someone else can't give you a very simple to follow solution, I will write out a description of how I would event this. It might require you to do a little research for anything you aren't familiar with, but at least it would be a solution.

In the meantime, I might have some tutorials on my YouTube page that might help with some aspects. If you have time and are interested in checking them out.
I tried my hand at doing a test event with the advice from Shadow Drgon, so I'll post it here once I'm home so I can hopefully get some more advice.


As for the YT tutorials, I'd appreciate it immensely.
The solution isn't going to be simple because the OP has no programming knowledge on top of being a beginner at RPG Maker. The scripting way to do this is with manipulating strings and/or arrays which isn't that hard by itself, but making the user interface for this would be a lot more work.

The OP has nothing built already except an input prompt loop, which effectively means the forum is going to have to write the entire thing from scratch for the OP if they want to make a "simple to follow" guide. ShadowDragon posted a general outline of how you could do it, but it requires intermediate scripting and engine knowledge.

Is this a two player game or one? I.e. is one player inputting the answer word or is it picked from a pool of possible words by the computer?
It is a one player game,but the hangman only has one solution and is only a single puzzle that gives a reward to advance the story. I.e the puzzles found in Ib or Ao Oni
Also, what time frame are you talking about? Meaning what is your deadline for having something?
I have until late november, so around 4 months

Original thread: https://forums.rpgmakerweb.com/threads/help-using-javascript-for-a-hangman-game.170695/