Displayrand: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
No edit summary
mention that displayrand uses the "system" PRNG (which is libc rand() with potential truncation now, but that's an implementation detail)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''displayrand''' <gamevar>
'''displayrand''' <gamevar><br>
generates a random number between 0 and a certain maximum value (using the system PRNG in a not further specified fashion) and assigns it to <gamevar>. With EDuke32 revisions prior to r2105, the maximum values may differ between EDuke32 builds produced with the GCC and MSVC compilers, and/or operating systems. Revisions r2105 and up always generate numbers from 0 to 32767 (inclusive).
 
'''displayrandvar''' <gamevar> <maxvalue_constant><br>
'''displayrandvarvar''' <gamevar> <maxvalue_gamevar>
 
The '''displayrandvar''' commands limit the number to be between 0 and <maxvalue>, inclusive.
 
'''displayrandvarvar''' takes a [[gamevar]] rather than a constant or a [[define]]d label for <maxvalue>.


This function generates a random number and assigns it to <gamevar>.
Since this function is sync safe, it can be used in unsynchronized code.
Since this function is sync safe, it can be used in unsynchronized code.


See [[displayrandvar]], [[displayrandvarvar]], [[randomseed]].
See [[randomseed]].


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]
[[Category:Gamevar manipulation]]
[[Category:Gamevar manipulation]]

Latest revision as of 12:52, 21 March 2012

displayrand <gamevar>
generates a random number between 0 and a certain maximum value (using the system PRNG in a not further specified fashion) and assigns it to <gamevar>. With EDuke32 revisions prior to r2105, the maximum values may differ between EDuke32 builds produced with the GCC and MSVC compilers, and/or operating systems. Revisions r2105 and up always generate numbers from 0 to 32767 (inclusive).

displayrandvar <gamevar> <maxvalue_constant>
displayrandvarvar <gamevar> <maxvalue_gamevar>

The displayrandvar commands limit the number to be between 0 and <maxvalue>, inclusive.

displayrandvarvar takes a gamevar rather than a constant or a defined label for <maxvalue>.

Since this function is sync safe, it can be used in unsynchronized code.

See randomseed.