Your example runs code that defines the function. But nothing actually calls the function. When you call GetGlobalValue, you're just getting back the reference to the function, not the result of calling it.
From what you describe, I think what you want is something like the "Event Pump" example in the Unity Integration Guide. (If you're not using Unity, that's OK, this section still applies to you.)
Also, I might be able to help you better if you join our Discord — I see messages there right away if I'm at my desk, instead of hours later when I check my email or the forums. Just a thought. The link, if you want it, is at the bottom of https://miniscript.org .
Can't wait to hear more about your project!