Loading Screen Text
- In TDM 2.03 and before, this works only on a fresh game start, not when loading a saved game. It'll be changed in TDM 2.04.
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.
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.
Changes in TDM 2.04
In TDM 2.03, the "OnRandomValueInitialised" GUI code is activated only on new mission starts, not when the player is loading a saved game. In TDM 2.04, the GUI event will be activated during save game loads too, including for quick loads.
Quick loads can be very fast, so you might want to suppress your text (or other random GUI actions) during quickloading. TDM 2.04 will add another flag to the state information available to your gui: "gui::quickloading" which will be set to 1 when quickloading or 0 when not.
Example usage:
onNamedEvent OnRandomValueInitialised { if ("gui::quickloading" == 0) // Don't display text when quickloading { 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) { ... etc etc } }