How to print Debug text to the console

Post » Sat May 28, 2011 8:11 am

As the title says, I would like to be able to print some variables and references to the console similar to C++, e.g.:

myActorRef: 00ff105 has effect = 1


for debuging reasons. I know there is a way to do it, but I can't find it anywhere :banghead: Anyone has a clue?

Edit: Found PrintToConsole, but it's only for float variables. Actually I can't make it work, I must be using wrong syntax. Anyone knows if I can print a short, an int or a reference somehow???
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Sat May 28, 2011 11:38 pm

I just put the following in the scrip I'm debugging:

printc "??? is: %.3f"

replace the ??? with the variable's ID (text name)

The .3 part is to print the value out to 3 decimal places.
User avatar
Danny Warner
 
Posts: 3400
Joined: Fri Jun 01, 2007 3:26 am

Post » Sat May 28, 2011 3:52 pm

As the title says, I would like to be able to print some variables and references to the console similar to C++, e.g.:

myActorRef: 00ff105 has effect = 1


for debuging reasons. I know there is a way to do it, but I can't find it anywhere :banghead: Anyone has a clue?

Edit: Found PrintToConsole, but it's only for float variables. Actually I can't make it work, I must be using wrong syntax. Anyone knows if I can print a short, an int or a reference somehow???



Shorts or floats - just specify digits for the %f formatter
PrintToConsole "Enemy, Total %.0f", iEnemyCount

The Name of something:
PrintToConsole "Enemy, %n", rTarget

The FormID:
PrintToConsole "Enemy, %i", rTarget

To save all this in a text file - you have to type this every time you restart the game:
scof "myfile.txt"
User avatar
Mark
 
Posts: 3341
Joined: Wed May 23, 2007 11:59 am

Post » Sat May 28, 2011 9:52 pm

Thanks a lot to both of you, you just saved me from hours of headaches :)
User avatar
rheanna bruining
 
Posts: 3415
Joined: Fri Dec 22, 2006 11:00 am

Post » Sat May 28, 2011 8:18 pm

When it comes to debug text, it can be very useful to use http://fose.silverlock.org/fose_command_doc.html#DebugPrint instead of http://fose.silverlock.org/fose_command_doc.html#PrintToConsole. The two functions work in pretty much exactly the same way, except http://fose.silverlock.org/fose_command_doc.html#DebugPrint will only print messages to the console if "debug mode" has been turned on for that plugin file via http://fose.silverlock.org/fose_command_doc.html#SetDebugMode. This lets you leave debugging lines in your code without worrying about creating console spam.

There's a good reference in the FOSE documentation for the various format specifiers that you can use to print dynamic data to the console - http://fose.silverlock.org/fose_command_doc.html#FormatSpecifiers
Other available format specifiers, which also work with http://geck.gamesas.com/index.php/ShowMessage, are listed on the GECK Wiki - http://geck.gamesas.com/index.php/ShowMessage#Formatting_notation

Cipscis
User avatar
oliver klosoff
 
Posts: 3436
Joined: Sun Nov 25, 2007 1:02 am

Post » Sat May 28, 2011 2:46 pm

There is a nice trick that exploits DebugPrint, SetDebugMode and http://fose.silverlock.org/fose_command_doc.html#GetSourceModIndex. You can toggle debugging on/off by running the lines

set myModDebugMode to (1 != myModDebugMode)SetDebugMode myModDebugMode (GetSourceModIndex SomeItemAddedByMyMod)

where myModDebugMode is a short. These can be run from an options menu, by adding an item to the pc or whatever.
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Sat May 28, 2011 5:18 pm

If I remember correctly, the "modIndex" parameter of http://fose.silverlock.org/fose_command_doc.html#SetDebugMode is only required in the console, where http://fose.silverlock.org/fose_command_doc.html#GetSourceModIndex doesn't work. When called in a script, http://fose.silverlock.org/fose_command_doc.html#SetDebugMode should apply to the source mod by default.

Cipscis
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm


Return to Fallout 3