Can you use var in a text as pointer to another var?

Aryam777

Villager
Member
Joined
Mar 8, 2017
Messages
17
Reaction score
15
First Language
Polish
Primarily Uses
RMMV
What I mean is if you can do something like this:
ex. \v[ v[7] ]

While Yanfly's extended messages allows to display item icons and text, it only works when you input a specific number (like \ii[7]), however I would like a message to display a previously selected item.

I already know the item's ID and Name (using a script) can be stored in variables and those can be used to display the variable values in the text... And while for ex. v[7] can store selected item's ID and v[8] selected item's NAME... I still can't figure out how to place items icon in there. Hence the question wether you can do something that would work like \ii[v[7]] OR perhaps is it possible to store an icon in a variable?

Is it possible to use a text code (or some kind of formula) within a text code? Scripts are fine. - it would be very useful. :)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,947
First Language
English
Primarily Uses
RMMV
You could overwrite the function that processes escape characters to be able to handle that syntax and get the value of a variable to figure out which variable to show the value of, yes.
 

Aryam777

Villager
Member
Joined
Mar 8, 2017
Messages
17
Reaction score
15
First Language
Polish
Primarily Uses
RMMV
SOLVED IT! :D

Actually I dug in the default jscript and in the plugin's script and those things are usually handled by the "replace" and "parseInt" String function. And there is no smart way to take over the "parseInt" except to already feed it pre-prepped data. And THAT gave me an idea to use the $gameMessage functions to prepare the String passed onto the game script.

So the solution is:
$gameMessage.add("Item \\ii[" + $gameVariables.value(*pointer variable ID*) + "] can't be used here.")

By displaying the message through scripts and feeding the game interpreter an alredy prepared string with the value of a variable inserted!
I tried that in tandem with Yanfly's Extended Message plugins and it works! You just have to add the message configure functions before that, you know the $gameMessage [icon, index], background and positionType. :) Instead of $gameVariables you can just input some other game data and use it as a formula after placing it in ( ).

The text code used here is from the plugin but you can use anything instead of \\ii, like \\v or \\p etc.

You just have to remember to use two "\". Since your messages go through java script interpretation before baing passed to the game interpreter and "\\" means to pass down a "\". :)

Oh and sadly text codes stored inside $gameVariables don't work, so you can't store "\n[2] is down" in a variable. but you can store it in a script variable to use it later within this script.

Man this is so awesome and simple I'm stumped baffled I didn't find that anywhere...
I scoured the internet and everyone says the same thing... To write yourself a plugin... Or write own functons to text interpretation. But this solution is much more neat and simple!
I don't want to sound cheeky but you might want to sticky that solution example somwhere. ;P Kind of obvious in the hind sight. xD

Thank you Trihan for nudging me in the right direction. :)
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,947
First Language
English
Primarily Uses
RMMV
I did wonder if that would work. Handy to see it does, good find!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Done with another simple battleback :LZYcheeze:
Anyone else find it amusing that people watch videos of tragedy and then try to take the "moral high ground" by having sympathy for the victims? Dude, you watched the tragedy for the same reason everyone else. People being injured is an instinctive human curiosity.
Say, does anyone know any other indie game development forums? Progress on my uni survey has been a little slow, so I wanna look into posting it around a bit more.

Forum statistics

Threads
104,306
Messages
1,005,425
Members
135,829
Latest member
LordPenguin666
Top