jon jon - 5 months ago 13
Java Question

increase nominal value of a text insid variable? [solved]

Hi guys how i can increase this text valur inside my variable ?

EX:
// file name inside the folder

fileNAME = '1';

//later in the script i need to do

// a variable have a number and need to set this number to the fileNAME

newNumber++;

and

//need to set to newNumber valur

fileNAME = 'newNumber';

Here what am not shure how to do this :)

Tanks you guys

here the full script

// Listing item menu
// Listi= test premiere list
Itemlist = 1; // test itemid 1 in DB
Listi=1; // List loop (while) Listi/ max item show in screen
Pid = 100; // Picture id (100-1 eatch loop)
Xitem = 0; // X coor for the item + picturesize+ marge
Yitem = 0; // Y coor for the item + picturesize+ marge
InpicX = 46; // Initial X of menue item list
InpicY = 186; // Initial Y of menue item list
MargeX = 7; // Marge bettwenn 2 picture X
MargeY = 6; // Marge bettwenn 2 picture Y
ISIZEX = 82; // X size of picture
ISIZEY = 82; // X size of picture
fileNAME = '1';// identifie le nom fichier 1,2,3,4,5,6 .....
PIDNAME = 0 // identifie le nom de limage a id de limage
// Test if have item
while(Listi<=36){
if (($gameParty.hasItem($dataItems[Itemlist])==true || $dataItems[Itemlist].itypeId !== 2) || $dataItems[Itemlist].itypeId !== 3){
$gameScreen.showPicture(Pid, fileNAME, 0, InpicX+Xitem, InpicY+Yitem, 100, 100, 255, 0);
$gameScreen.setPictureCallCommon(Pid, 21, 1);
// cré une variable PIDNAME [X] selon le pid ex: si clic sur image 200 , variable volatile PIDNAME= LE NOM DE FICHIER
PIDNAME[Pid] = $gameScreen._pictures[Pid]._name;
if (Listi==12 || Listi==24 || Listi==36) {
Xitem=0; Yitem+=ISIZEY+MargeY; Itemlist++; Listi++; Pid++;
}else{Xitem+=ISIZEX+MargeX; Itemlist++; Listi++; Pid++;}
}else {Itemlist++;}}

Answer

Convert your file name to an int.

currentFileNumber=parseInt(fileNAME);

Then increment the number.

currentFileNumber++;

Finally, convert the file number to a string and use it for your purpose.

fileNAME=currentFileNumber.toString();

Or More easily

Keep a variable to track your current file number.

fileNumber=1;

Increment it whenever you want to.

fileNumber++;

Then convert that to string to get the string representation.

fileName=fileNumber.toString();