What's new

PSM_SHOW_POPUP, translating RPG Maker MV, and you


crap

Jungle Girl
Joined
Oct 6, 2013
Messages
41
Reputation score
58
You may recognize the plugin call PSM_SHOW_POPUP if you've tried to translate (machine or otherwise) certain RPG Maker MV games. If you don't, here's the lowdown:

This call is for a plugin named FTKR_PopupSpriteMessage.js. The PSM_SHOW_POPUP call with its associated arguments (the main one: text, and position, etc) are used to show text anywhere on the screen. There is also PSM_SHOW_POPUP_B which is the same thing but has more options: color, size, font changes, and importantly: offsetWait. That last argument is an integer, and it is processed as follows:
  1. if it is greater than 0, process the text one character at a time with a delay between each character (delay determined by the "count" argument)
  2. if it is exactly 0, process the text one character at a time with no delay (used for per-character color, size, etc changes) (this is what PSM_SHOW_POPUP defaults to)
  3. if it is less than 0, process all the text at once.
Processing characters one at a time is fine and all, but it leads to a lot of spam if you're using a hooker -> MTL to translate. So to fix that, we just need to set offsetWait to less than 0, like -1. Here is the easiest place to do it, from FTKR_PopupSpriteMessage.js (from about line 530 in the file I have):
JavaScript:
    Game_Interpreter.prototype.setupPopupMessage = function(args) {
        var status = FTKR.PSM.popupStatus[Number(args[1])];
        var option = this.setupPopupMessageOptions(args, 6);
        $gameParty.setPopupMessage(
          setArgNum(args[0]), setArgNum(args[2]), setArgNum(args[3]), setArgNum(args[4]),
          status.offsetWait, args[5], status.color, 0, status.italic,
          status.fontSize, status.outlineColor, status.popupHeight, status.fontFace,
          status.opacity, !!option.align
        );
    };
and in case you're curious, here's how I changed it to always equal -1:
JavaScript:
    Game_Interpreter.prototype.setupPopupMessage = function(args) {
        var status = FTKR.PSM.popupStatus[Number(args[1])];
        var option = this.setupPopupMessageOptions(args, 6);
        $gameParty.setPopupMessage(
          setArgNum(args[0]), setArgNum(args[2]), setArgNum(args[3]), setArgNum(args[4]),
          /* status.offsetWait,*/ -1, args[5], status.color, 0, status.italic,
          status.fontSize, status.outlineColor, status.popupHeight, status.fontFace,
          status.opacity, !!option.align
        );
    };
Neat.

Next is the text argument. You may have noticed if you're translating one of these games and you try to add spaces to the text in a PSM_SHOW_POPUP call in e.g. CommonEvents, you'll end up with errors or non-functional popups. This is because normal space characters tell the plugin to move to the next argument; all the things after the space(s) get parsed as arguments (or ignored). If you want to include a space that doesn't break the game, you need to get creative and use something like or, as noted in the instructional comments of FTKR_PopupSpriteMessage.js:
文字列(text)
:ポップアップする内容を指定します。
半角スペースは使用できません。
半角スペースを入れたい場合は \_ (アンダーバー)と入力してください。
MTL:
*string* *text* *
: A pop-up message will be displayed.
Half-width space is unavailable.
If you wish to enter a half-width space, please enter \_.
Ok, great, you know how to use spaces in your translation now, but it's still awkward to hit \_ - especially while translating. Also, the comment is wrong - you actually need to enter \\_ or the game may not load at all. How can we get around this issue? With Specifically an .AHK script that looks something like this:
f12::
ToggleKeys := !ToggleKeys
Return

#If ToggleKeys
Space::
SendInput \\_
#if
Once you have AHK installed, copy paste that into an .AHK file, compile it and run it! While the script is running, press f12 to toggle the key swap on/off; while it's toggled on, press spacebar and you'll get \\_ instead, so you can translate games that use this plugin more easily. Note that if f12 doesn't work for you as a toggle shortcut you can change it: . If you want to , the big three are: ! for alt; ^ for control; + for shift. For example, if you wanted control+p to be your toggle, you'd put ^p:: in place of the f12:: - just remember to compile and run again if you change it.

Attached are the .AHK script and FTKR_PopupSpriteMessage.js with the modification shown. Paste the .js file into your games ~/www/js/plugins/ folder and replace the one in there. The .AHK script should run from any folder once you have AHK installed and the script compiled. For the .js file, you may want to just update the one you have as there are multiple versions, some of which probably fixed bugs or something.

note: I have heard of truly awful anti-cheat software that will flag any AutoHotkey script as a hack. To be safer, exit the script entirely (right click icon in taskbar) before you start something with anti-cheat.
 

Attachments

Last edited:

Strange

Demon Girl Pro
Joined
Jul 24, 2014
Messages
1,256
Reputation score
486
There's a bunch of these, but a specific example is worth explaining. Adding to the above:

Translator++ users would typically search for them using a regex (/PSM_.+/ in the example) then delete them by batch replace (shift+ctrl+F, replace by nil).
You'd need to be careful the number of matches in your search is consistent with the the number of lines replaced.
Some are more complicated and you'd want either a middle step, or a line-by-line verification, editing manually the abusive replacements.

The worst cases are when these commands are before text needing to be translated, like in that example... Trial, error and patience are keys :(
I don't remember that command specifically, but there are good hints/lessons to learn right here!

Alternatives can include copying the script/code to notepad++ and working from there. But autohotkey is good advice when working on RPGMV directly.
 
Last edited:

hpfas

New member
Joined
Oct 28, 2021
Messages
2
Reputation score
2
You may recognize the plugin call PSM_SHOW_POPUP if you've tried to translate (machine or otherwise) certain RPG Maker MV games. If you don't, here's the lowdown:

This call is for a plugin named FTKR_PopupSpriteMessage.js. The PSM_SHOW_POPUP call with its associated arguments (the main one: text, and position, etc) are used to show text anywhere on the screen. There is also PSM_SHOW_POPUP_B which is the same thing but has more options: color, size, font changes, and importantly: offsetWait. That last argument is an integer, and it is processed as follows:
  1. if it is greater than 0, process the text one character at a time with a delay between each character (delay determined by the "count" argument)
  2. if it is exactly 0, process the text one character at a time with no delay (used for per-character color, size, etc changes) (this is what PSM_SHOW_POPUP defaults to)
  3. if it is less than 0, process all the text at once.
Processing characters one at a time is fine and all, but it leads to a lot of spam if you're using a hooker -> MTL to translate. So to fix that, we just need to set offsetWait to less than 0, like -1. Here is the easiest place to do it, from FTKR_PopupSpriteMessage.js (from about line 530 in the file I have):
JavaScript:
    Game_Interpreter.prototype.setupPopupMessage = function(args) {
        var status = FTKR.PSM.popupStatus[Number(args[1])];
        var option = this.setupPopupMessageOptions(args, 6);
        $gameParty.setPopupMessage(
          setArgNum(args[0]), setArgNum(args[2]), setArgNum(args[3]), setArgNum(args[4]),
          status.offsetWait, args[5], status.color, 0, status.italic,
          status.fontSize, status.outlineColor, status.popupHeight, status.fontFace,
          status.opacity, !!option.align
        );
    };
and in case you're curious, here's how I changed it to always equal -1:
JavaScript:
    Game_Interpreter.prototype.setupPopupMessage = function(args) {
        var status = FTKR.PSM.popupStatus[Number(args[1])];
        var option = this.setupPopupMessageOptions(args, 6);
        $gameParty.setPopupMessage(
          setArgNum(args[0]), setArgNum(args[2]), setArgNum(args[3]), setArgNum(args[4]),
          /* status.offsetWait,*/ -1, args[5], status.color, 0, status.italic,
          status.fontSize, status.outlineColor, status.popupHeight, status.fontFace,
          status.opacity, !!option.align
        );
    };
Neat.

Next is the text argument. You may have noticed if you're translating one of these games and you try to add spaces to the text in a PSM_SHOW_POPUP call in e.g. CommonEvents, you'll end up with errors or non-functional popups. This is because normal space characters tell the plugin to move to the next argument; all the things after the space(s) get parsed as arguments (or ignored). If you want to include a space that doesn't break the game, you need to get creative and use something like or, as noted in the instructional comments of FTKR_PopupSpriteMessage.js:
文字列(text)
:ポップアップする内容を指定します。
半角スペースは使用できません。
半角スペースを入れたい場合は \_ (アンダーバー)と入力してください。
MTL:
*string* *text* *
: A pop-up message will be displayed.
Half-width space is unavailable.
If you wish to enter a half-width space, please enter \_.
Ok, great, you know how to use spaces in your translation now, but it's still awkward to hit \_ - especially while translating. Also, the comment is wrong - you actually need to enter \\_ or the game may not load at all. How can we get around this issue? With Specifically an .AHK script that looks something like this:
f12::
ToggleKeys := !ToggleKeys
Return

#If ToggleKeys
Space::
SendInput \\_
#if
Once you have AHK installed, copy paste that into an .AHK file, compile it and run it! While the script is running, press f12 to toggle the key swap on/off; while it's toggled on, press spacebar and you'll get \\_ instead, so you can translate games that use this plugin more easily. Note that if f12 doesn't work for you as a toggle shortcut you can change it: . If you want to , the big three are: ! for alt; ^ for control; + for shift. For example, if you wanted control+p to be your toggle, you'd put ^p:: in place of the f12:: - just remember to compile and run again if you change it.

Attached are the .AHK script and FTKR_PopupSpriteMessage.js with the modification shown. Paste the .js file into your games ~/www/js/plugins/ folder and replace the one in there. The .AHK script should run from any folder once you have AHK installed and the script compiled. For the .js file, you may want to just update the one you have as there are multiple versions, some of which probably fixed bugs or something.

note: I have heard of truly awful anti-cheat software that will flag any AutoHotkey script as a hack. To be safer, exit the script entirely (right click icon in taskbar) before you start something with anti-cheat.
Thank you so much for the tips! I`ve been messing around and trying to translate something as a learning project and stumbled upon this plugin call. After injecting the translation for an initial test I could tell the plugin was using spaces as an argument separator. Searching online for the plugin call led me directly to your post, and I`m glad it did, since the instructional comments were wrong and I most certainly wouldn`t figure that out!

Correction: the game I was translating actually used just "\_" for space. Maybe different version of the plugin?. In any case, a simple replace fixes it.

With this, my test project is a happy success!
Thanks a bunch!
 
Last edited:

hpfas

New member
Joined
Oct 28, 2021
Messages
2
Reputation score
2
Aside from what was stated above, I'd like now to add some more observations I made about the plugin behaviour:
  • According to the instructions, the commonly used call is something like PSM_SHOW_POPUP <ID> <StatusID> <X> <Y> etc..., in which the Status ID is the parameter number that corresponds to a specific text format (fontface, fontsize, color, popupheight, offsetwait, etc). This Status ID can be easily configured inside the editor's plugin manager.
  • There is, however, a discrepancy between the number indicated in the plugin manager structure list and the actual ID it should be used. The range of ID's seem to start at 0, while the list starts at 1. In other words, if you tweak the settings of the 5th item in the list (in editor), the changes will reflect the Status ID 4.
  • If the list in the plugin manager contains, say, 15 items (Status ID from 0-14), if you try to set one of the PSM_SHOW_POPUP calls a Status ID of 14 an error will occur. Even though the StatusID 14 has all parameters clearly defined (even checking the plugins.js file), when trying to display the message, the game will crash claiming an OffsetWait paramater was not defined.
I think it's useful to keep these in mind for adjusting the translated content size and position on screen, as it was necessary for my case.
 
Top