Harisc1990 1 Posted June 29, 2014 Report Share Posted June 29, 2014 I wanted to know whether or not it's possible to exclude numbers from the $rand command. Quote Link to post Share on other sites
the_way 52 Posted June 29, 2014 Report Share Posted June 29, 2014 not sure if you can do anything except numbers with the rand() function, you might need to create a custom function if its specific letters you need. Can you eleborate a bit more on what you need? Cheers Quote Link to post Share on other sites
UBotDev 276 Posted June 29, 2014 Report Share Posted June 29, 2014 Hm..."$rand" function returns only numbers, so if you exclude them your string will be blank....so I don't think you are looking for that... The only thing that came to my mind is that you want to use "$random text" function which also returns numbers. There it would be the easiest way to use regex replace and replace all digits at once. Since I'm not sure if regex is available in STD edition, an alternative there is to use "replace" command and manually replace all 10 digits. 1 Quote Link to post Share on other sites
Lombi 34 Posted June 30, 2014 Report Share Posted June 30, 2014 Im guessing he might mean just specific numbers? If that is the case you would need to build a simple custom function that would first set a rand, then loop while (if it contains the banned numbers, then repeat rand) Quote Link to post Share on other sites
Seth Turin 223 Posted June 30, 2014 Report Share Posted June 30, 2014 I would fill a list with all the possible choices and then use $random list item Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 1, 2014 Report Share Posted July 1, 2014 Here is an example of both $random list item and using $spin. In my opinion both are the same, just showing another option. In the function I created you will need to edit the return node after you paste it into Ubot and change back to node view by pressing the "" button then hit ok. clear list(%spintax)clear list(%randm list item)loop(10) { add item to list(%spintax, $spin($spin syntax("12345678910")), "Don\'t Delete", "Global") add item to list(%randm list item, $random list item($list from text("12345678910", $new line)), "Don\'t Delete", "Global")}dividerdefine $spin syntax(#list) { return("\{{$text from list($list from text(#list, $new line), "|")}\}")}clear list(%spintax2)clear list(%randm list item2)loop(10) { add item to list(%spintax2, $spin($spin syntax("1234")), "Don\'t Delete", "Global") add item to list(%randm list item2, $random list item($list from text("1234", $new line)), "Don\'t Delete", "Global")} But it will be best especially for standard version users to download it. May still have to edit return node . TCexample-spintax-rand-list.ubot Quote Link to post Share on other sites
malefic 48 Posted July 4, 2014 Report Share Posted July 4, 2014 How about making a list with the numbers you want to exclude to start with, then do a $rand and then if the result from $rand is in the list, redo the $rand or continue on with your script? Quote Link to post Share on other sites
runsoftware 14 Posted July 4, 2014 Report Share Posted July 4, 2014 do the $rand function normally and store the number in to a #var, then check if the var is a certain number you dont want, if it is then repeat the rand function Quote Link to post Share on other sites
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.