Quick links:
blog post
· itch
Versions: GameMaker LTS / GM2022+
This is a script that tracks uses of random number generator functions in GameMaker!
So if you do something like this:
function scr_test() {
random_log_tag = "T1";
random_log("hey");
var a = random(10);
//
random_log_tag = "T2";
var b = choose("A", "B", "C");
//
show_debug_message(random_log_print());
}
The output would be:
T1 random_log("hey")
gml_Script_scr_test:3
gml_Object_obj_test_Create_0:1
T1 random(10) -> 8.0878257285803556
gml_Script_scr_test:4
gml_Object_obj_test_Create_0:1
T2 choose("A", "B", "C") -> "B"
gml_Script_scr_test:7
gml_Object_obj_test_Create_0:1
Check out the blog post for an explanation of how this works!
You can edit this macro to control the maximum number of RNG log entries that can be kept at once.
This only affects memory use.
This global variable controls whether logging should be enabled or not.
With logging disabled, RNG functions have minimal overhead.
This string is attached to each log entry and shows up in front of them when printing.
Typically this is either a frame number or the state that the game's in.
Adds an entry without modifying RNG state.
Good for attaching additional debug information!
Pretty-prints the log entries and returns them as a string.
Appends pretty-printed log entries to the given buffer as text.
Pretty-prints the log entries to a file.
Clears the log entries!
If you made random_log_size
a variable, you'll want to call this after changing the log size.
Since we're storing arguments instead of printing them on spot (that'd cost!), if you are doing a choose() or random_log() on structs/arrays, upon printing you'll see the current value of struct/array rather than the one as of the function being called.