
Hi everyone!
I’m happy to announce the final release of the SplitMix64 extension for Defold - fast, but non-cryptographic PRNG. While this extension has been around for over 5 years and personally we have been using the extension in all our games, it previously offered only a minimal API. This update turns it into a more flexible and robust tool!
What’s new:
- State Management: You can now get and set the PRNG state. This is essential for save games, allowing you to restore the exact sequence of “random” numbers.
- Multiple Instances: You are no longer limited to a single global state. You can now create multiple independent instances of the generator to use in different modules of your game without them interfering with each other.
- Additional Helper Functions!
Example:
-- Create two independent generators
local rng_enemies = splitmix64.new_instance(42)
local rng_loot = splitmix64.new_instance(999)
-- Each has its own state — they don't affect each other or the global module
print(rng_enemies.random(1, 100))
print(rng_loot.random(1, 100))
-- The global state is unchanged
print(splitmix64.random())
-- Save/restore instance state
local saved = rng_enemies.state()
rng_enemies.randomseed(saved)
Happy Defolding! ![]()