Solved Using Random Letters...

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

MisterBasic

Member
Dec 17, 2017
1
0
0
Dope Town
When i go to use my code, it causes tons of errors in the console.
Error here
Function Usage: randomString("a|b|c|d|e|f")
Outputs Random character that is defined, which could be a, b, c, d, e, f
code_language.skript:
function randomString(char: text) :: text:
    set {_characters::*} to {_char} split at "|"
    replace all "|" in {_char} with ""
    set {_length} to length of {_char}
    set {_return} to "%index (a random integer between 1 and ({_length})) of {_characters::*}%"
    return "%{_return}%"

Skript Version: 2.2-dev34
Minecraft Version: 1.12.2
Running:
SkQuery 1.6.0
Skellett 1.9.6b
SkUtilities
TuSke
 
the index expression starts at 0, you'll have to do do:
code_language.skript:
set {_index} to random integer between 0 and ({_length} - 1)
set {_return} to index {_index} of {_characters::*}
Although as Donut said, you could just use the random element expression to do it.
 
Status
Not open for further replies.