Difference between revisions of "Scripting DebugLogging"
Jump to navigation
Jump to search
no edit summary
imported>Qazaaq (Created page with "Category:Scripting_Guides <source lang="papyrus"> Scriptname Papyrus:Log Hidden DebugOnly {Creates custom user logs for the purpose of debugging} Struct UserLog string...") |
imported>Qazaaq |
||
| Line 1: | Line 1: | ||
[[Category:Scripting_Guides]] | [[Category:Scripting_Guides]] | ||
This script will allow you to implement a user log on your scripts for the purpose of debugging. | |||
==Requirements== | |||
You will need to [[Enable Debug Logging]] in Fallout 4's [[Initialization File]] in order to allow the game to create logs in the file system. | |||
==Script== | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
| Line 66: | Line 73: | ||
EndFunction | EndFunction | ||
</source> | |||
==Usage== | |||
The Papyrus:Log script is a global library which is implemented by other scripts. An example of a Papyrus:Log implemented on a [[Quest]] would be as shown below. | |||
<source lang="papyrus"> | |||
ScriptName Papyrus:LogExample extends Quest | |||
{Attaches to a Quest form in the CreationKit} | |||
import Papyrus:Log | |||
; imports the Log script so the compiler knows about the UserLog struct type. | |||
UserLog Log | |||
Event OnInit() | |||
Log = new UserLog | |||
Log.Caller = self | |||
Log.FileName = "MyLogFileName" | |||
EndEvent | |||
Event OnQuestInit() | |||
; Event received when this quest has just started up - after aliases are filled, and at the same time as the quest startup stage is run. | |||
WriteLine(Log, "The OnQuestInit event has executed.") | |||
EndEvent | |||
Event OnStageSet(int auiStageID, int auiItemID) | |||
WriteLine(Log, "The OnStageSet event StageID equals "+auiStageID+" and auiItemID equals "+auiItemID) | |||
EndEvent | |||
Event OnReset() | |||
;Event received when this quest is started up (either the first time or subsequent times - this will fire in parallel with your startup stage!). | |||
WriteLine(Log, "The OnReset event has executed.") | |||
EndEvent | |||
Event OnQuestShutdown() | |||
; Event received when this quest has shut down (aliases are cleared at this time). | |||
WriteLine(Log, "The OnQuestShutdown event has executed.") | |||
EndEvent | |||
</source> | </source> | ||