- 6
- Posts
- 6
- Years
- Sevilla
- Seen Jan 27, 2025
RPG MAKER XP - v16.2 - Not tested in other versions.
More than once I've wanted to go to an specific moment of the game while I was developing it to see how the new things I was adding affected the ones I already had.
Or to check a bug someone reported me. So I made this little script:
NOTE: I'm Spanish so some things may be in Spanish. Sorry in advance.
So my script save global variables, game switches and local switches in .txt files. One for variables, one for switches and a third one for self switches.
Each specific moment you would want to save will have 3 .txt files, as follows:
-LISTA_VIL_V_0 (for variables - V)
-LISTA_VIL_I_0 (for game switches - I)
-LISTA_VIL_L_0 (for self switches - L)
*Translation: game switches=interruptores // Lista= list // Self switch=interruptor local
The number represents the moment you want to export/save. I recommend writing them down somewhere.
I have 5 saved
So in the root of Essentials you must create a folder called "VIL". There's where the script will be saving the data.
The script has 4 functions:
-Listar (To list): check if you already have a file with the number you want to save. This is optional, you could overwrite it and it would be ok, but you would lose the data you had there previously.
-Exportar (to export): to save all the variables and game/self switches in a .txt
-Importar (to import): to change all the variables and game/self switches values as the .txt says
-Manual Interruptores locales (Manual Self switches): I couldn't find a method that allowed me to save self switches automatically, so I had to introduced them one by one. I'll explain this later.
This is the script. I also leave the link if you want to download it
In order to use it, you only need to change two things:
-In "Exportar_VIL", "num_variables":
In "tipo==0" change 650 and put the number of variables your game has.
In "tipo==1" change 153 and put the number of game_switches your hame has.
In "tipo==2" change 25 and put the number of game self switches your game has.
(I recommend, in your game, have a certain margin with the variables and game switches. Ex: I use until variable 67 but I could use until variable 75. I don't use them but maybe I would. That way I wouldn't need to come to the script and change +1 the num_variables every time I add a new one).
- In MII_Loc you have to add the self switches you want to import/export. I leave here the template (it's also in the script). It's very easy to fill:
In the first template, "resultado" will be =0; in the second =1, ...
INSIDE THE GAME
Export an specifict moment (to save it), I advice to do it this way:
I used an auxiliary variable (636 my case) so I could check if the file I want to save my data exists or not. I saved that value (for example: 15) in v[636] and I asked function "Listar(pbGet(636),0) if the number 15 and furthermore, the file LISTA_VIL_V_15 was able or not. If it already exist you could rewrite it, it's an option. I only asked for one file instead of LISTA_VIL_V_15, LISTA_VIL_I_15 and LISTA_VIL_L_15 because if there's one of them, I asume there must be all 3 of them. But maybe it was deleted by accident, how knows. I don't see it necessary but you can ask for the three of them. Do as you wish.
Later I call the function "Exportar_VIL(pbGet(636),0)" ,"Exportar_VIL(pbGet(636),1)" and "Exportar_VIL(pbGet(636),2)" so I export in the selected number all the data I want to save and the 3 .txt will appear in your folder.
Import (to load an specific moment):
In my case, I have this inside "New Game" if DEBUG is ON. But you could place it anywhere. Only be careful that the player cannot have access to it.
If I want to import moment "3", I'll say variable (636) is 3, and call functions "Importar_VIL(pbGet(636),0)", "Importar_VIL(pbGet(636),1)" and "Importar_VIL(pbGet(636),2)".
CAREFUL: Don't know why but if you don't give v[636] the value you want before each call, there will be an error. No idea why, but it happens. Thankfully, you just have to say that variable is 3 (or any number you want to import) before each call. If you do this below then you will get an error
What it's lleft is very easey and depends on you. I have this in "New Game" so I won't have any pkm, so I add one pkm to my team and teleport myself to where I should be in that moment.
Careful when you can "Importar_VIL because you will be changing values and it can affect the map you are in.
So that's everything for now. Paste the script above main.
If there's any doubt, just write me and I will solver it.
Although I appreciate it, I won't get mad if you don't credit me. Just do it or not, your choice.
PS: Last advice. If I were you, I would delete the VIL folder before publishing my game. Otherwise maybe the players would find a way to use all that data. You never know.
More than once I've wanted to go to an specific moment of the game while I was developing it to see how the new things I was adding affected the ones I already had.
Or to check a bug someone reported me. So I made this little script:
NOTE: I'm Spanish so some things may be in Spanish. Sorry in advance.
So my script save global variables, game switches and local switches in .txt files. One for variables, one for switches and a third one for self switches.
Each specific moment you would want to save will have 3 .txt files, as follows:
-LISTA_VIL_V_0 (for variables - V)
-LISTA_VIL_I_0 (for game switches - I)
-LISTA_VIL_L_0 (for self switches - L)
*Translation: game switches=interruptores // Lista= list // Self switch=interruptor local
The number represents the moment you want to export/save. I recommend writing them down somewhere.
I have 5 saved
So in the root of Essentials you must create a folder called "VIL". There's where the script will be saving the data.
The script has 4 functions:
-Listar (To list): check if you already have a file with the number you want to save. This is optional, you could overwrite it and it would be ok, but you would lose the data you had there previously.
-Exportar (to export): to save all the variables and game/self switches in a .txt
-Importar (to import): to change all the variables and game/self switches values as the .txt says
-Manual Interruptores locales (Manual Self switches): I couldn't find a method that allowed me to save self switches automatically, so I had to introduced them one by one. I'll explain this later.
This is the script. I also leave the link if you want to download it
Spoiler: CODE
Code:
################################################################################
# IMPORTAR/EXPORTAR VIL #
# Creador: Pableroski #
# No necesita dar créditos. Se agradecería pero no obligo a nadie #
# No necesita ninguna variable. #
# En Importar_VIL, modificar num_variables según la cantidad que se tenga. #
# Ej: Si tengo 152 variables, cuando tipo==0, num_variables=152. Si tengo 34 #
# interruptores (no locales), cuando tipo==1, num_variables=34. Si tengo 5 #
# interruptores locales, cuando tipo==2, num_variables=5 #
# La función MII_Loc necesita que la vayamos completando con nuestros #
# interruptores locales. Dejo una plantilla. La primera tendrá "numero=0", #
# la segunda "numero=1"... Abajo está explicado qué poner en cada sitio. #
################################################################################
#Comprobamos si el archivo existe o no
def Listar(numero,tipo)
numero=numero.to_s
iteracion=0
array=[]
maximo=50 #Si superas los 50 .txt, aumentar.
if tipo==0
array_comprobante=['LISTA_VIL_V_' + numero + '.txt']
end
if tipo==1
array_comprobante=['LISTA_VIL_I_' + numero + '.txt']
end
if tipo==2
array_comprobante=['LISTA_VIL_L_' + numero + '.txt']
end
resultado=true #No existe
array= Dir.entries("\VIL")
while (iteracion<maximo && array[iteracion]!=nil)
if array[iteracion]==array_comprobante[0]
resultado=false #Existe
end
iteracion+=1
end
return resultado
end
#Guardamos variables en archivo seleccionado
def Exportar_VIL(numero,tipo)
clase=[]
if tipo==0
num_variables=650 #Num variables que tenemos
clase=['V_']
end
if tipo==1
num_variables=153 #Num interruptores generales
clase=['I_']
end
if tipo==2
num_variables=25 #Num interruptores locales
clase=['L_']
end
numero=numero.to_s
iteracion=1 #Las variables que se pueden comprobar empiezan en 1
File.open('VIL\LISTA_VIL_'+clase[0] + numero +'.txt',"w") do|line| #Abre archivo, recorre con var line
while iteracion <=num_variables #Itera variables mientras escribe.
if tipo==0
line.puts $game_variables[iteracion]
end
if tipo==1
line.puts $game_switches[iteracion]
end
if tipo==2
line.puts $game_self_switches[[MII_Loc(iteracion,1),MII_Loc(iteracion,2),MII_Loc(iteracion,3)]]
end
iteracion +=1
end
end
end
#Copiamos en juego conjunto de variables seleccionadas
def Importar_VIL(numero,tipo)
mapa=0
id=0
interruptor=0
clase=[]
if tipo==0
num_variables=650 #Num variables || #Num interruptores (según 'tipo')
clase=['V_']
end
if tipo==1
num_variables=153 #Num variables || #Num interruptores (según 'tipo')
clase=['I_']
end
if tipo==2
num_variables=25 #Num variables || #Num interruptores (según 'tipo')
clase=['L_']
end
numero=numero.to_s
iteracion=1 #Las variables que se pueden comprobar empiezan en 1
array=[]
copia=0
archivo=File.open('VIL\LISTA_VIL_' + clase[0] + numero + '.txt')
array=archivo.readlines
while iteracion<=num_variables
if tipo==0
copia=array[iteracion-1] #El array cuenta la pos 0
copia=copia.to_i
if iteracion!=12 #Quitar el \n a las variables con texto
$game_variables[iteracion]=copia
else
$game_variables[iteracion]='Rafael'
end
end
##################################################
if tipo==1
if array[iteracion-1]== "false\n"
$game_switches[iteracion]=false
end
if array[iteracion-1]== "true\n"
$game_switches[iteracion]=true
end
end
##################################################
if tipo==2
if array[iteracion-1]== "false\n"
$game_self_switches[[MII_Loc(iteracion,1),MII_Loc(iteracion,2),MII_Loc(iteracion,3)]]=false
end
if array[iteracion-1]== "true\n"
$game_self_switches[[MII_Loc(iteracion,1),MII_Loc(iteracion,2),MII_Loc(iteracion,3)]]=true
end
end
##################################################
iteracion+=1
end
archivo.close
end
################################################################################
def MII_Loc(numero,tipo)
resultado=0
numero-=1
#Plantilla
#Aquí podéis poner el nombre del mapa
if numero==0 #Cada plantilla tiene su número. Empezar en 0, siguiente 1...
if tipo==1
resultado= #Id del mapa
end
if tipo==2
resultado= #Id del evento
end
if tipo==3
resultado="" #Interruptor local a modificar
end #MAYÚSCULA y entre ""
end
#Fin plantilla
end
In order to use it, you only need to change two things:
-In "Exportar_VIL", "num_variables":
In "tipo==0" change 650 and put the number of variables your game has.
In "tipo==1" change 153 and put the number of game_switches your hame has.
In "tipo==2" change 25 and put the number of game self switches your game has.
(I recommend, in your game, have a certain margin with the variables and game switches. Ex: I use until variable 67 but I could use until variable 75. I don't use them but maybe I would. That way I wouldn't need to come to the script and change +1 the num_variables every time I add a new one).
- In MII_Loc you have to add the self switches you want to import/export. I leave here the template (it's also in the script). It's very easy to fill:
In the first template, "resultado" will be =0; in the second =1, ...
INSIDE THE GAME
Export an specifict moment (to save it), I advice to do it this way:
I used an auxiliary variable (636 my case) so I could check if the file I want to save my data exists or not. I saved that value (for example: 15) in v[636] and I asked function "Listar(pbGet(636),0) if the number 15 and furthermore, the file LISTA_VIL_V_15 was able or not. If it already exist you could rewrite it, it's an option. I only asked for one file instead of LISTA_VIL_V_15, LISTA_VIL_I_15 and LISTA_VIL_L_15 because if there's one of them, I asume there must be all 3 of them. But maybe it was deleted by accident, how knows. I don't see it necessary but you can ask for the three of them. Do as you wish.
Later I call the function "Exportar_VIL(pbGet(636),0)" ,"Exportar_VIL(pbGet(636),1)" and "Exportar_VIL(pbGet(636),2)" so I export in the selected number all the data I want to save and the 3 .txt will appear in your folder.
Import (to load an specific moment):
In my case, I have this inside "New Game" if DEBUG is ON. But you could place it anywhere. Only be careful that the player cannot have access to it.
If I want to import moment "3", I'll say variable (636) is 3, and call functions "Importar_VIL(pbGet(636),0)", "Importar_VIL(pbGet(636),1)" and "Importar_VIL(pbGet(636),2)".
CAREFUL: Don't know why but if you don't give v[636] the value you want before each call, there will be an error. No idea why, but it happens. Thankfully, you just have to say that variable is 3 (or any number you want to import) before each call. If you do this below then you will get an error
What it's lleft is very easey and depends on you. I have this in "New Game" so I won't have any pkm, so I add one pkm to my team and teleport myself to where I should be in that moment.
Careful when you can "Importar_VIL because you will be changing values and it can affect the map you are in.
So that's everything for now. Paste the script above main.
If there's any doubt, just write me and I will solver it.
Although I appreciate it, I won't get mad if you don't credit me. Just do it or not, your choice.
PS: Last advice. If I were you, I would delete the VIL folder before publishing my game. Otherwise maybe the players would find a way to use all that data. You never know.