Resource icon

[Open Assets] FlowerRNG (Discontinued) 2.0

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
I made sure my file(s) follow the Submissions Guidelines
  1. Yes
I named my file(s) correctly (see Filename Conventions)
  1. Yes
This library has been discontinued. I recommend using another library, such as my FlowerRNG Lite instead.

FlowerRNG is a revamped version of my old SeedRng project for v2.1 (hence the name) which has more robust random number generation and is also simpler to use in a correct way. It lets you create multiple random number generator states which need to be seeded, can be network synchronized, et cetera. It provides most of the features of the standard SRB2 random number generator functions (all except RandomChance) and a few additional ones (random 32-bit integers, arrays of those, array shuffling, approximately normally distributed numbers).

L_FlowerRNG_v2.0.wad contains extensive documentation and L_FlowerRNG_tests_v2.0.wad contains some usage examples, but the general way it works is pretty simple. Call FRNG.Hud_Create or FRNG.Sim_Create (more on that distinction later) and you get a state token that represents that stream of random numbers. Call the other functions (e. g. FRNG.*_GetFixed) to get random numbers. When you're done with a particular stream, call FRNG.*_Destroy to delete it.

Note that there are both Sim and Hud functions. Hud functions can only be called in HUD or ticcmd hooks and Sim functions can only be called outside them. If you pass a state token that was created with Sim_Create to a Hud function or vice-versa, you will get an error. This is to make it harder to accidentally write code that will desync. Also, Sim states are automatically network-synchronized, while Hud states are not and cannot be network-synchronized.

As stated above, L_FlowerRNG_v2.0.wad contains FlowerRNG itself with full comments and credits; documentation is available there in LDoc format for user-visible functions. L_FlowerRNG_v2.0_commentless.lua is the same library but with blank lines and comments removed, so it's about 10KB smaller before compression. L_FlowerRNG_tests_v2.0.wad adds a console command that tests all of the basic functions of the library and should not be included in mods that use it.

While mainly designed for SRB2 v2.2, it works equally well on SRB2Kart v1.3 and use of it there is supported.

Known issues
  • None currently.
Changes since XRNG v1.0
  • To prevent name conflicts with another similar library called XRNG, the name has been changed to FlowerRNG and the library is now in the table FRNG. The library is otherwise compatible.
  • FRNG.*_GetInt32Array: Returns a specified number of 32 bit integers in an array.
  • FRNG.GetVersion : Returns a table containing the major, minor, and patch version number (currently 2.0.0).
  • Bug and documentation fixes.
  • srb20003.png
    30.8 KB · Views: 369
First release
Last update
0.00 star(s) 0 ratings

Share this resource

Latest updates

  1. Discontinuing development in favor of FlowerRNG Lite

    I will no longer be updating this library. Any future development will be on FlowerRNG Lite...
  2. FlowerRNG 2.0 released

    After almost a year, I have finally updated FlowerRNG. The work was done a few months ago, I...