Loading Screen Text

From The DarkMod Wiki
Revision as of 00:12, 12 July 2011 by Springheel (talk | contribs)
Jump to navigationJump to search

It's common to add flavour text to a loading screen to help set the mood and give the player something to read while the map is loading.

Mappers can now add a random selection of text, so players will see a different bit of text each time they load the map.

Use the following GUI event to read out the "gui::random_value" state variable. The event will be fired by the SDK code as soon as the random_value is set. Just copy and paste into your loading screen .gui.

edit: presently this doesn't seem to work when you load a game, only on a fresh start. [Springheel]

onNamedEvent OnRandomValueInitialised
{
if ("gui::random_value" < 0.1)
{
set "TextLoading::text" "Text1";     // Replace "TextLoading" with the name of your text windowdef.
}
else if ("gui::random_value" < 0.2)
{
set "TextLoading::text" "Text2";
}
else if ("gui::random_value" < 0.3)
{
set "TextLoading::text" "Text3";
}
else if ("gui::random_value" < 0.4)
{
set "TextLoading::text" "Text4";
}
else if ("gui::random_value" < 0.5)
{
set "TextLoading::text" "Text5";
}
else if ("gui::random_value" < 0.6)
{
set "TextLoading::text" "Text6";
}
else if ("gui::random_value" < 0.7)
{
set "TextLoading::text" "Text7";
}
else if ("gui::random_value" < 0.8)
{
set "TextLoading::text" "Text8";
}
else if ("gui::random_value" < 0.9)
{
set "TextLoading::text" "Text9";
}
else
{
set "TextLoading::text" "Text10";
}
}

(The indentation has been screwed by the forum code block). This is just an example supporting 10 different texts of roughly equal probability in a "TextLoading" windowDef. The "gui::random_value" will be in the range [0..1), so if you need more or less than 10 values as in the example, you need to adjust the if () clauses in the GUI code accordingly.