export variables to txt file?

stiven202

Villager
Member
Joined
Apr 29, 2013
Messages
18
Reaction score
0
First Language
English
Primarily Uses
is there any way to export variables to a txt file?

 

example:

 

In part of my game, player will enter his name and ID. I want to keep those variables and then export them to a text file and can view them.

 

List example:

 

TXT FILE:

 

Name: Esteban

ID: 523,134->this ID, previously entered by each player

Name: Alejandra

ID: 564,146

Name: Fernando

ID: 564,466

Name: Lily

ID: 564,884

 

thanks.

 

 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.

Why export them?  Why not just have the player send you his save file, then you can load that into your own game and look at everything.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Try this script:

http://forums.rpgmakerweb.com/index.php?/topic/45024-txt-files-builderopener/

in the part where you set up the text,

use something like this:

Code:
@DOC1 = $game_actors[1].name + "\n" + $game_actors[1].id.to_s + "\n" + $game_actors[2].name + "\n" + $game_actors[2].id.to_s + "\n" + $game_actors[3].name + "\n" + $game_actors[3].id.to_s + "\n" + $game_actors[4].name + "\n" + $game_actors[4].id.to_s + "\n"
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
I highly doubt that will work, because $game_actors is not yet initialized when the module runs. It will throw an error immediately on game startup.

I wonder too, why do you want to do this?

You could try this snippet:

# Use the following script call in eventing:## save_txt_data("filename",actor_id,variable_id)## "filename" = The name of the text file you will save into.# If there is no such file in the game's directory, it will be# created automatically. If there is one already with the same# name, it will append the new text at the end of the txt file.## actor_id = The ID of the actor. The selected actor's name will be saved# in the txt file.## variable_id = The ID of the variable to save. The value of the variable will# be saved in the txt file.## Examples: ## save_txt_data("Player Data",12,78) - # Saves the name of actor 12 and the value of variable 78 into a file named# "Player Data.txt".## save_txt_data("InfoDump",8,9) - # Saves the name of actor 8 and the value of variable 9 into a file named# "InfoDump.txt".## Run a name input processing command and a number input command before you use# this script call, and enter the re-named actor's ID and the variable's ID used# in the number input. This way, the entered data will always be saved in the# text file, ready to be used for whatever purposes.## Made by: Sixthclass Game_Interpreter def save_txt_data(filename,aid,vid) File.open("#{filename}.txt", "a+") do |f| num = 0 f.each_line do |line| if line =~ /-- Player: (\d+) --/i num = $1.to_i end end num += 1 f.write("\n -- Player: #{num} -- \n") f.write("Name ------------------- #{$game_actors[aid].name} \n") f.write("ID --------------------- #{$game_variables[vid]} \n") end end end
Use the provided script call, combine it with eventing, and you can easily do what you want with it.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Yes, if you write that in an event script box, it won't throw an error.


I meant in your script, if you enter what you wrote above in the module settings of your script, than it will throw an error.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top