When trying to create or playback a TAS, one of the most important aspects in assuring deterministic input is the ability to control and predict the game's random number generator, or RNG. For many games, this is relatively simple, as the game would simply initialize the RNG seed as the same value every time on startup.
However, some games, such as Pikmin 2, initialize the seed based on something else - In this case, the game looks at the system's RTC. Newer versions of Dolphin (since this PR was merged) include this as a configurable option, however Dolphin Lua Core seems to have branched before that merge happened.
So, my proposed solution is to either port that PR to Lua Core, or alternatively implement a similar thing your own way.
If you want to take the latter solution, all I can help you with is this. According to Ghidra, getting the value of the system clock seems to be as simple as moving the value from the Time Base Lower register, or TBLr.