Sign in to follow this  
Clopen

Using DST's Util Module

Recommended Posts

Clopen    11

DST has a module called "util" in its scripts bundle which contains various scripting paraphernalia that one may find useful.

I'd like to use the weighted_random_choice() function it has, but when I use require "util" to import the code (currently to my modmain file but I plan on moving it out of there shortly) and then use it, I get an error for invoking a nil value.

I know I can copy the function, of course but since it's already there and various game scripts use it, I figure there should be a way to import it into a mod environment as well - or am I wrong?

Assistance would be appreciated, like always. =)

Share this post


Link to post
Share on other sites
Cunning fox    141

You don't need to load it, it's loaded already in the global env. Use

GLOBAL.weighted_random_choice()

 

  • Like 1

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

Sign in to follow this