Jump to content

Lua Question


NCrawler

Recommended Posts

Does Kahlua have them?

Why not use ZombRand() instead?

 

Lol, I really should look at the internal functions before running off and finding an alternate method.  I actually found a pretty robust pseudo-random number generator and converted my code to use it already.  Thanks for pointing out the ZombRand function though.  If you'd like to see the method that I am now using just let me know and I'll post it.  In fact, it may be a good function to include in your utility functions RoboMat...

Link to comment
Share on other sites

  • 6 months later...

 

Does Kahlua have them?

Why not use ZombRand() instead?

 

Lol, I really should look at the internal functions before running off and finding an alternate method.  I actually found a pretty robust pseudo-random number generator and converted my code to use it already.  Thanks for pointing out the ZombRand function though.  If you'd like to see the method that I am now using just let me know and I'll post it.  In fact, it may be a good function to include in your utility functions RoboMat...

 

 

Sorry to revive this thread but I need to be able to generate a random number for a project. It seems to me math.random() (unless there is something I need to do with randomseed()) doesn't work with lua files for PZ mods. But that aside, how are you supposed to use ZombRand()? Is there something that needs to be imported into the lua file to be able to use that function? 

Link to comment
Share on other sites

 

No need to import anything. Usage is pretty straight forward:

if ZombRand(10) == 0 then   foo();else   bar();end

 

Yeah, but won't ZombRand(10) return a value between 0 - 9?  If I understand the previous reply he probably needs a number between 1 - xx.  I'd suggest he use the function from your RMUtility library:

function rnd(_value)	return ZombRand(_value) + 1;end

That's what I use and it makes it so much easier than having to remember to +1 every time I need a random value.  Thank you for that library, btw.  I use a couple of functions in there extensively...  :)

Link to comment
Share on other sites

Yeah, but won't ZombRand(10) return a value between 0 - 9?

 

Yes exactly :) It's just an example of how it could be used.

That's what I use and it makes it so much easier than having to remember to +1 every time I need a random value.  Thank you for that library, btw.  I use a couple of functions in there extensively...  :)

Glad the library helped someone :) I really should go back and improve it though ... a lot of the stuff that's in there is from the early beginnings of my lua career :D

Link to comment
Share on other sites

Glad the library helped someone :) I really should go back and improve it though ... a lot of the stuff that's in there is from the early beginnings of my lua career :D

 

 

Yes, please do.  I, for one, would use it...  :)

Link to comment
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
×
×
  • Create New...