Storing a database entry as a String

Im using " $gameParty.gainItem($dataWeapons[$gameVariables.value(20)], 1, true); " to add a weapon based of a random number.


What I'm wanting to achieve is to display the added weapon in a 'show text' so the player can see what they have received. 


I can add a String to a variable using, " $gameVariables.setValue(19, 'String Here'); " and then display that string with " \v[19]. "


But I'm struggling to find the right syntax to be able to add the weapon database entry to the String


I have tried  " $gameVariables.setValue(19, '$dataWeapons[$gameVariables.value(20)]') " - Which just displays what is in bold as text.


I have also tried " $gameVariables.setValue(19, $dataWeapons[$gameVariables.value(20)]) " - Which just displays the word 'object'


Any help steering in my the right direction will be greatly appreciated 
 $gameVariables.setValue(19,String($dataWeapons[$gameVariables.value(20)].name)) 
You got really close ^^


the problem is that you are trying either to pass an Object as a String or using   '$dataWeapons[$gameVariables.value(20)]'  but in this cans eveything inside these ' ' is considered a string itself and not a pointer to the Object.


What you need to do is to find out where in   $dataWeapons[$gameVariables.value(20)] the name of the item is stored, to do that simply run the game and type it in the console, then press on the arrow next to it to show all the properties of the object and find what you need.


In this specific case the name of the property is "name" so you have to call


$gameVariables.setValue(19, $dataWeapons[$gameVariables.value(20)].name) 😛
Thank you both very much 🙂

Original thread: https://forums.rpgmakerweb.com/threads/storing-a-database-entry-as-a-string.64695/