MV "$gameMessage.add" fade out after 3 sec?

Hi^^

i am trying to use a script in a plugin that shows what item was stolen from an opponent, with the help of the forum i could already build the needed message script.

But how can i let it fade out after 3 sec without any Game_input..?
Screenshot_1.png

--
thats my used script:

JavaScript:
$gameMessage.setBackground(1);$gameMessage.setPositionType(1);
var stolenWeaponId = targetBattleUnit[1]._equips[0].id;
var itemName =  $dataWeapons[stolenWeaponId].name;
var msgIconID = $dataWeapons[stolenWeaponId].iconIndex;
var eName = targetBattleUnit[1].name();
$gameMessage.add(eName + "'s \\i["+ msgIconID +"]"+ itemName +" stolen!");
The way this works currently, its required for the Gamer to click, to fade out the message..


I know how to fade out after few secs in a textbox, but couldnt make it work on a "$gameMessage.add" script..
And i dont have much skills on both of them (textboxes&"$gameMessage.add")
\| - means wait 1 second
\^ - don't wait for intput

so at the end of text type:
\|\|\|\^

$gameMessage.add(eName + "'s \\i["+ msgIconID +"]"+ itemName +" stolen!\|\|\|\^");

but how to fade out it, IDK, but with those text tags, text will wait 3 seconds and dissapear without waiting for player's input.
\| - means wait 1 second
\^ - don't wait for intput

so at the end of text type:
\|\|\|\^

$gameMessage.add(eName + "'s \\i["+ msgIconID +"]"+ itemName +" stolen!\|\|\|\^");

but how to fade out it, IDK, but with those text tags, text will wait 3 seconds and dissapear without waiting for player's input.
nope, that works in a textbox
(and yes with "fade out" i just mean disappear^)
i copy pasted your solution and thats what i got^^
Screenshot_2.png

(and gamer_input_click was still required)

somehow the "$gameMessage.add" works a bit different than the Textbox idk

And for several reasons i would like to avoid using a common event and 3_$gamevariables + the textbox.. if thats possible..
Ahh! because you must it either escape it with another slash:

\\|\\|\\|\\^

or

\x1b\|\x1b\|\x1b\|\x1b\^

I can't tell the difference where to use which one, but one of these should work ( I think the first one should do )

PS: If you are using in text lot of variables, then format() would be much easier to read code in future updates:

JavaScript:
$gameMessage.add("%1's \\i[%2] %3 was stolen!\\|\\|\\|\\^".format(eName, msgIconId, itemName));
Ahh! because you must it either escape it with another slash:

\\|\\|\\|\\^

or

\x1b\|\x1b\|\x1b\|\x1b\^

I can't tell the difference where to use which one, but one of these should work ( I think the first one should do )

PS: If you are using in text lot of variables, then format() would be much easier to read code in future updates:

JavaScript:
$gameMessage.add("%1's \\i[%2] %3 was stolen!\\|\\|\\|\\^".format(eName, msgIconId, itemName));
that worked^^ thank you very much^^
and about the code, i dont really know what i did here, i read other topics and somehow buided/puzzled that code by trial and error..but thx for the hint i will try it out aswell.

edit:
using text box code is still a riddle to me^^
however thx, i will report this as solved!
using text box code is still a riddle to me^^
Let me explain.

In JavaScript (and most other programming languages), the backslash (\) character is a special character used for "escape characters".

Escape characters are special characters that you can't simply include in a text for whatever reason. For example, in C there's an escape character that causes your PC to beep (\a).

There's also an escape character to delete the previous character (\b), so "Hello V\bWorld" produces Hello World (because the V has been deleted by \b). This character exists in JavaScript too. It's usually used in command line programs for animation purposes, like this:


spinning_wheel.c595af6f83ea.gif



The most important escape characters are the ones that allow you to add a quote mark to your text. For example, if you have the text "Hello Beautiful World" and you want Hello "Beautiful" World, you obviously can't use "Hello "Beautiful" World", because now your have two texts: "Hello " and " World" and an undeclared variable Beautiful in between.

So you use the escape character \" instead: "Hello \"Beautiful\" World" becomes Hello "Beautiful" World.

JavaScript also allows you to define text between single quotes (') instead, which lets you do this: 'Hello "Beautiful" World', but in return, you can't do that: 'Where's John's car?' for the same reason as before. In that case, you need to use another escape character: \' like this 'Where\'s John\'s car?'

And now you might ask yourself: "What if I want to add a backslash (\) in my text?"

There's an escape character for that too: \\


Now, when you write some text for a Text event command in the RPG Maker editor, the editor expects you to type text like: Hello, my name's "Alex", and I'm the Hero! but can't expect you to write either Hello, my name's \"Alex\", and I'm the Hero! or Hello, my name\'s "Alex", and I\'m the Hero! because the whole point of RPG Maker is that you don't need to know any of this.

However, RPG Maker MV/MZ use JavaScript and must abide by the rules of JavaScript, so it must escape those quotes properly.

In addition, RPG Maker defines its own set of escape characters (called "control characters"), such as \n[1] to display the name of Actor 1. However, \n also happens to be the escape character for a new line.

This means that RPG Maker also needs to escape backslashes, so \n[1] in RPG Maker becomes \\n[1] in JavaScript.

And that is why, if you want to write RPG Maker control characters within JavaScript, you need to double the backslashes, to make sure JavaScript doesn't interpret them as JavaScript escape characters. Therefore you need to write \\|\\|\\|\\^ instead of \|\|\|\^.


I hope this explanation helped you understand this concept a bit better.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/gamemessage-add-fade-out-after-3-sec.142319/