How to access variable's value from a save file

Hi everybody!

My game is divided in chapters. The current chapter number is save in a variable.
When I'll load a save game, I would show the name of chapter, based in this variable value in the save file. But I didn't succeed in to draw this value. 🙁

I tried add this as a information in makeSavefileInfo method:


info.variable   = $gameVariables.value(10);


And so write it in save file window on loadscreen:


var info = DataManager.loadSavefileInfo(1);
this.drawText(String(info.variable), 0, 0, this.contents.width, 'center');


I searched for plugins with this feature. but didn't find too.
This works fine for me. I have done the exact same practice for adding act information onto save files, and have no problems displaying it.


Did you try doing:


console.log(info.variable);


to ensure the value actually loads correctly, and isn't empty when drawing? 


It works fine for me, so there's something irregular happening with your setup. I don't have the full code of where you implement these changes, so can't really pin-point.
Ya, more some attempts and now works. For some reason, my save folder had a "config" file. Worked after erase it. Strange...
Anyway, thanks for the confirmation, Sarkilas!
I was looking at forum ... looking for something to help me.
I understand the programming and logic.
However can not apply to the RPG Maker.
But thanks to his doubts, helped me with mine.


I was looking for a way to play a variable set to a variable of the script.


Even that was not its intention, thanks  😀

Original thread: https://forums.rpgmakerweb.com/threads/how-to-access-variables-value-from-a-save-file.55981/