Jump to content
UBot Underground

Is it possible to exclude numbers from $rand?


Recommended Posts

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

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

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)

Link to post
Share on other sites

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("1
2
3
4
5
6
7
8
9
10")), "Don\'t Delete""Global")
    add item to list(%randm list item$random list item($list from text("1
2
3
4
5
6
7
8
9
10"$new line)), "Don\'t Delete""Global")
}
divider
define $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("1
2
3
4")), "Don\'t Delete""Global")
    add item to list(%randm list item2$random list item($list from text("1
2
3
4"$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 .

 

 

 

TC

example-spintax-rand-list.ubot

Link to post
Share on other sites

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?

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...