MZ Trying to show the icon in the message

Im makiing a random reward and the code works in that regard but i cannot get the item to show its icon as well.
const items = [152, 153, 154, 155, 156, 157]; const index = Math.randomInt(items.length); const reward = $dataItems[items[index]]; $gameMessage.add("Your party gained " + reward.name + "!"); $gameParty.gainItem(reward, 1); $gameMessage.newPage();

I have tried adding "\I[reward.iconIndex]" but it doesnt work. Any help would be appreciated.
Escape codes accept the kind of value the instructions say to provide - a name, integer, etc. They won't evaluate JavaScript inserted into their brackets.
You could use template literals and 2 slashes instead of 1 in order for the escape code to be considered valid.
But the important part is mostly the double slashes.
$gameMessage.add(`Your party gained \\i[${reward.iconIndex}]${reward.name}`);
It needs to be a double-backslash because JavaScript uses backslashes for its string escape notation:
You could use template literals and 2 slashes instead of 1 in order for the escape code to be considered valid.
But the important part is mostly the double slashes.
$gameMessage.add(`Your party gained \\i[${reward.iconIndex}]${reward.name}`);
I had this kind of code in another part of my plugin to call a skill name and icon. I tried it first and it wasnt working, so i tried what i posted. I found out it was the "i" I used was upper case instead of lowercase was blocking it from working. Thanks for this! Now i feel dumb lol.
I found out it was the "i" I used was upper case instead of lowercase was blocking it from working.
Just so you know: all the core text codes, including \i[n], are case-insensitive, i.e. they work in upper- or lower-case. A plugin might change that, but I imagine it was a different problem.
See i thought the worked upper or lower too, thats why i thought something else must be the issue. Though similar message build worked in another plugin I have for skill name and icon when learning from items.

The code i posted is inside an mv plugin using fossil to work. I'm not sure if that's what was going on or not, but I literally had that same line in my message just with the "i" as a capital and it wasn't working. I confirmed it a little bit ago when I had the same problem using \\n[1] in the message text, when the n was capitalized it would show up as N[1] in the message, when lower case n, it called the name.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-show-the-icon-in-the-message.162523/