Displaying output
When writing a mutator or mod it can be useful to display information in real-time, to allow detailed analysis of the operation.
Log
Possibly the most simple way to output information is to write directly to the log file. Since you cannot read the log in real-time, it is more useful for post-analysis.
Log("All checks OK");
Output:
ScriptLog: All Checks OK
If you are timing a section of code, you may want to add accurate timestamps to each string you output, which can be done automatically using StopWatch():
StopWatch(false); Log("Generating world"); // ... world generation code ... Log("Finished generating world"); StopWatch(true);
Output:
ScriptLog: 0.00 ms: Generating world
ScriptLog: 9.33 ms: Finished generating world
On-screen messages
Alternately it may be more convenient to display messages in real-time, which can be accomplished with a simple call to GameInfo's Broadcast():
Level.Game.Broadcast(Self, "Hello World!");
This will act as if a player has sent a message, using the same message queue.
Console output
For more permanent real-time output it is convenient to write directly to the console, which can hold many more messages than the simple player messaging system, and can be scrolled using PG-UP and PG-DOWN.
You can output to the console by calling its Message() function:
function Timer() { local PlayerController PC; PC = Level.GetLocalPlayerController(); if (PC != none) PC.Player.Console.Message("Timer called", 0); }
If you are calling from an interaction you can access Player through ViewportOwner:
ViewportOwner.Player.Console.Message("Humans must die!", 0);
Direct screen writing
More flexible (albeit more complicated) than the other methods, this allows you to draw text and images directly to the screen, saving the need to work with the console or the player messaging system. If writing a mutator the simplest way to do this is by using an interaction. See here for examples.