Jump to content

How to output variables to an external file automatically


Visualize

Recommended Posts

I've been attempting to figure out if Fallout: New Vegas will allow me to export variables automatically to an external file. Meaning, as I am playing the game I would like the game to periodically output variable values, such as the player's position or when a quest is completed, to a text file.

 

I'm aware of the console command SetConsoleOuputFile and have been able to save console command logs. However, I have not seen any console functions that allow me to automatically run a console command nor have I seen a G.E.C.K. scripting function which sends information to the console. There is the scripting function ShowWarning which should publish a string to an external file named warnings.txt but my scripts containing the function have not produced the warning file.

 

Has anyone ever tried to do this? And if so what are the specific functions you used to achieve this functionality?

Link to comment
Share on other sites

I'm assuming this is just for debuging purposes right?

 

If so then the nvse functions printc/dbprint can help. (printToConsole)

 

eg, this is a line I output to a console at the start of an OnActivate block during development.

; dbprintc "DOB rThis=(%i) iSlvM=%.0f rSlv=%n (%i) rMSC=%n (%i) rHI=%n (%i) " rThis iSlvM rSlv rSlv rMSC rMSC rHI rHI

 

Just for completeness...

For the times you want to pause the game and peek at some variables that you've not already placed into code.

 

The following console commands are useful

 

;set console output file

scof "myconsoleoutput.txt"

 

;show quest variables

sqv Questname

 

;Show selected object inventory

inv

 

;show vars on the selected object

sv

Link to comment
Share on other sites

Yep, the scof command is an alias of SetConsoleOuputFile that Visualise mentioned already.

Remember to open the console to type that to begin the console dump.

 

Offhand I can't remember which directory it creates the output file. The first time I used it I gave it a silly name and ran a filesearch search afterwards.

Link to comment
Share on other sites

Ah, I didn't have the nvse installed. Great, so dbprintc should print the statements to the console and scof will print it to a file. I'll have to test this tonight. To answer the directory question, the file usually ends up in the top directory of your New Vegas install, where FalloutNV.exe is located (at least that is where it has been showing up for me). I wonder if there is a limit on how much the console file can store.
Link to comment
Share on other sites

Sorry, I should have been clearer.

 

Try the printc command first. It has the same syntax as the dbprintc.

(dbprintc won't output anything unless debugging is enabled for the mod - using SetDebugMode.)

 

The docs show all the Format Specifiers you can use. (those %-thingies)

Link to comment
Share on other sites

Worked like charm. I attached my script to an NPC and was able to print to the console (using printc) while also saving the output to a file.

 

Now my next question is how do I run the script all the time? The current script I have doesn't begin until I get near the NPC I attached it to (I'm not familiar with how scripts run in general). Is there a way to attach the script to the player so it continuously runs?

Link to comment
Share on other sites

It sounds like it would be better as a quest script if you want it to run all the time.

Then it would be easy to adjust the frequency that it runs. (the default is once every 5 seconds)

You'd put the code in a gamemode block as you've probably done in your current script.

 

When a script is in an object or npc, then it will run *every* gameframe while the object is loaded and in the current cell.

 

Accessing variable values in other objects comes with its set of caveats.

Can you post a bit more detail about what your mod does and what you are trying to monitor?

Link to comment
Share on other sites

Sure, really it is a very simple script. I'm attempting to create a tracking script that monitors how the player traverses the world. Eventually I would like to also track when players complete quests and when they talk to NPCs. All this data can then be used to analyze how players progress through the game.

 

Right now I have the script below attached to a NPC, so when ever I am near the NPC the player's position is printed to the console every 300 gameframes. But of course, I would like to have this script run continuously throughout an entire play session. I haven't looked into building a new quest yet, but perhaps I can just give the player a starting quest automatically and attach this script.

 

scn PrintcTest

 

int num_frames

float posX

float posY

float posZ

 

begin GameMode

 

set num_frames to num_frames + 1

if num_frames == 300

set posX to Player.GetPos X

set posY to Player.GetPos Y

set posZ to Player.GetPos Z

printc "Player position, X: %.5f , Y: %.5f , Z: %.5f" posX posY posZ

set num_frames to 0

endif

 

end

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...