Jump to content

Search the Community

Showing results for tags 'ZombRand'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Twitter


Interests

Found 1 result

  1. ZombRand() is used in many mods to get random numbers. However, many are using it incorrectly, and because it returns a random value, they are not realizing they have a bug. The most common problem I have seen is when code is written similar this; n = ZombRand(2);if n == 2 then....else....endn == 2 will always be false as ZombRand(2) will never return 2, only 0 or 1. What is ZombRand(n)? ZombRand is an exposed implimentation of rand.Int(n) with a couple of changes. What does it do? Given value n, ZombRand will return a pseudo random number from the set of INTEGERS from 0 to n-1 inclusive. Why ask for n if it only gives up to n-1? The n in ZombRand(n) is not the maximum value wanted, but the range of the result wanted. For example, ZombRand(4) can return 0, 1, 2, or 3, which is exactly 4 values. If you desire results from 1 to n just do foo = ZombRand(n)+1;Special Cases ZombRand(0) is always 0 ZombRand(-n) = -1*ZombRand(n) Hope that clears some things up!
×
×
  • Create New...