Difference between revisions of "Displayrand" - EDukeWiki

# Difference between revisions of "Displayrand"

From EDukeWiki

Revision as of 03:45, 10 November 2011 (view source) Plugwash (talk | contribs) ← Older edit | Revision as of 08:45, 10 November 2011 (view source) TX (talk | contribs) m (Reverted edits by Plugwash (talk) to last revision by Helixhorned) Newer edit →
Line 1: | Line 1:
| '''displayrand''' <gamevar><br> |  | '''displayrand''' <gamevar><br>
− | generates a random number between 0 and a system-specific maximum value and assigns it to <gamevar>. Specifically, the maximum values may differ between EDuke32 builds produced with the GCC and MSVC compilers, and/or operating systems. Use of this function is thus discouraged. | + | generates a random number between 0 and a certain maximum value 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> |  | '''displayrandvar''' <gamevar> <maxvalue_constant><br>
| '''displayrandvarvar''' <gamevar> <maxvalue_gamevar> |  | '''displayrandvarvar''' <gamevar> <maxvalue_gamevar>
− | The '''displayrandvar''' commands limit the number to be between 0 and <maxvalue>. | + | 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>. |  | '''displayrandvarvar''' takes a [[gamevar]] rather than a constant or a [[define]]d label for <maxvalue>.
− | This function must ONLY be used in unsynchronized code. Use in syncronized code is almost certain to cause desyncs. | + | Since this function is sync safe, it can be used in unsynchronized code.
| See [[randomseed]]. |  | See [[randomseed]].

## Revision as of 08:45, 10 November 2011

displayrand <gamevar>
generates a random number between 0 and a certain maximum value 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.

Retrieved from "http://wiki.eduke32.com/w/index.php?title=Displayrand&oldid=10017"
Categories:

- EDuke32 specific commands
- Gamevar manipulation