art3mis Posted June 3, 2019 Share Posted June 3, 2019 What's the most efficient way in vex to choose between 4 different options? Right now I am simply using rand and a series of if statements to check the resulting value. Is there a better way? Quote Link to comment Share on other sites More sharing options...
anim Posted June 3, 2019 Share Posted June 3, 2019 you can use sample_discrete() function to get the index and then get your value from an array of values, it can be uniform or weighted or you can use ramp parameter with constant interpolation and look up the value using random 0-1 number Quote Link to comment Share on other sites More sharing options...
golubevcg Posted June 3, 2019 Share Posted June 3, 2019 (edited) i like this way like you said rand, but with floor function @choose=floor((rand(@ptnum)*4)+1); Edited June 3, 2019 by golubevcg Quote Link to comment Share on other sites More sharing options...
art3mis Posted June 3, 2019 Author Share Posted June 3, 2019 Thanks. Is there any way in vex to incorporate method calls directly with your solution, or would I still need to use an if, else once I get my @choose value? Quote Link to comment Share on other sites More sharing options...
anim Posted June 3, 2019 Share Posted June 3, 2019 just pick the value from an array based on that index 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.