Chalwk

Name Replacer

Tiddy-bits:

Update:

 

Small bug fix for a random number generator that returns a number between 1 and the length of an array.

I am using SAPP's built-in rand() function for this, but for some reason the maximum number is exclusive.

 

All I had to do was define the max number (+1).

For example:

local array = {"a", "b", "c"}

-- gurantees that "a", "b" or "c" are potential candidates for selection.
local n = rand(1,#array+1) -- min, max+1

print(array[n])

 

Edited by Chalwk
Denn and Takka like this

- I invite you to join my Halo Discord Server.

- Add me on discord: Chalwk#9284
- HSP Repo

- HSP Repo Wiki (new)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.