How to load numbers from EXTERNAL TXT into a variable in rpgmv?

i want to get a number from an external text file and put it into a variable in the game.

for example,   I'll put a text file "1.txt" in my project folder and it contains only number '10' and no other content at all and load this in the game and save this 10 into variable[1]?

i have,'t got a clue to do this.

EXTERNAL TXT plugin only shows text messeges and

It was rather too complicated for me to fix and customize and I'd like to put a number into variable not messeges.

if you have answers and could make a simple plugin or suggestions pls share thank you so much!  ;_;
For what exactly do you need that number? Loading a file requires an asynchronous request, which might be too complicated for such a simple task. Wouldn't is be easier to use a plugin parameter for this?
I was wondering if RPGMV could read a certain number(like in txt file) from the NFC card through the android or PC reader and save it into variables and be used in the game you know.

so I could make a TCG game where player could play with certain NFC cards and apply it in the game to play you know?

route would be like: NCF card-> android / pc -> a text file or any other information file gets put into the project folder->read it from rpgmv and put it in a variable-> verify it and get an item/ character

doesn't necessarily have to be a txt file.

just wanted to load certain numbers from the NFC card.

Getting text file/ number from NFC card won't be a problem but

what I don't know is to load numbers from external text file and get it into variables in rpgmv..

wanted to know if this was possible to make as a plugin or script.
I don't know anything about how Android handles NFC cards, but assuming their contents can be accessed on the file system, you have 2 options to do this:

- Read the data at the beginning of the game (or any scene):

Code:
var data;var loadData = function(url) {    var request = new XMLHttpRequest();    request.open('GET', url);    request.onload = function() { data = Number(request.responseText); };    request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); };    request.send();};var alias_create = Scene_Boot.prototype.create;Scene_Boot.prototype.create = function() {    alias_create.call(this);    loadData();};var alias_isReady = Scene_Boot.prototype.isReady;Scene_Boot.prototype.isReady = function() {    return (data !== undefined) && alias_isReady.call(this);};// Afterwards, the data is available.
- Read the data during a scene, by using a callback:
Code:
var loadData = function(url, callback) {    var request = new XMLHttpRequest();    request.open('GET', url);    request.onload = function() { callback(Number(request.responseText)); };    request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); };    request.send();};// You don't know exactly, when the data will be available, so you should handle it completely inside the callback.
I don't know anything about how Android handles NFC cards, but assuming their contents can be accessed on the file system, you have 2 options to do this:

- Read the data at the beginning of the game (or any scene):

var data;var loadData = function(url) { var request = new XMLHttpRequest(); request.open('GET', url); request.onload = function() { data = Number(request.responseText); }; request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); }; request.send();};var alias_create = Scene_Boot.prototype.create;Scene_Boot.prototype.create = function() { alias_create.call(this); loadData();};var alias_isReady = Scene_Boot.prototype.isReady;Scene_Boot.prototype.isReady = function() { return (data !== undefined) && alias_isReady.call(this);};// Afterwards, the data is available.- Read the data during a scene, by using a callback:
Code:
var loadData = function(url, callback) {    var request = new XMLHttpRequest();    request.open('GET', url);    request.onload = function() { callback(Number(request.responseText)); };    request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); };    request.send();};// You don't know exactly, when the data will be available, so you should handle it completely inside the callback.
thnx for the specific information!! only.. what parts of this code do I fill in to test this?

like... for url.. what exactly do I write in it? and like variables numbers or any other parts do I change to appy this for me? 

could you maybe like an example?  after everything, I'd have to put this in a script call? sorry I asked too much.. I'm such an amateur at this... 🙁
Assuming you have a file named "1.txt" containing the number 10 in your project folder, you would write the first example like this:

Code:
var data;var loadData = function(url) {    var request = new XMLHttpRequest();    request.open('GET', url);    request.onload = function() { data = Number(request.responseText); };    request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); };    request.send();};var alias_create = Scene_Boot.prototype.create;Scene_Boot.prototype.create = function() {    alias_create.call(this);    loadData('1.txt');};var alias_isReady = Scene_Boot.prototype.isReady;Scene_Boot.prototype.isReady = function() {    return (data !== undefined) && alias_isReady.call(this);};var alias_start = Scene_Boot.prototype.start;Scene_Boot.prototype.start = function() {    alert(data);    // 10    alias_start.call(this);};
Assuming you have a file named "1.txt" containing the number 10 in your project folder, you would write the first example like this:

var data;var loadData = function(url) { var request = new XMLHttpRequest(); request.open('GET', url); request.onload = function() { data = Number(request.responseText); }; request.onerror = function() { throw new Error("There was an error loading the file '" + url + "'."); }; request.send();};var alias_create = Scene_Boot.prototype.create;Scene_Boot.prototype.create = function() { alias_create.call(this); loadData('1.txt');};var alias_isReady = Scene_Boot.prototype.isReady;Scene_Boot.prototype.isReady = function() { return (data !== undefined) && alias_isReady.call(this);};var alias_start = Scene_Boot.prototype.start;Scene_Boot.prototype.start = function() { alert(data); // 10 alias_start.call(this);};
wow thnx for this! just sent you a personal messege 🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-load-numbers-from-external-txt-into-a-variable-in-rpgmv.53727/