Tag like string.random?

is there any way that any type of tag will make any letter like string.random(8) will make different five letters or something like string.letter(“a, b, c, d”) will make only these letters. OffThisTopic: @Jmv38, why is everyone ignoring my topic “fun codes”?

@TokOut You can’t make people read or comment on your discussions. As for string.random(), there isn’t anything like that, but you can write your own function that does it.

@TokOut Here’s a function that will return 2 strings of random letters. One is upper case and the other is lower case. Just change the value sent to stringRandom for different string lengths.

function setup()
    print(stringRandom(8))
end

function stringRandom(x)
    local valU,valL="",""
    for _=1,x do
        valU=valU..string.char(math.random(string.byte("A"),string.byte("Z")))
        valL=valL..string.char(math.random(string.byte("a"),string.byte("z")))
    end
    return valU,valL
end

@TokOut Here one that will give you 8 random letters from the letters you send to the function.

function setup()
    print(stringLetter("qwertyuiop",8))    
end


function stringLetter(s,w)
    local str=""
    for _=1,w do
        v=math.random(1,s:len())
        str=str..string.sub(s,v,v)   
    end
    return str 
end

Thx

@dave1707, can you do with this something like

for x = string.byte("a"), string.byte("z") do
.....

And any way for this random strings, to use for a-z and the “_” symbol?

@TokOut You could use this. You could also add numbers or anything else you want to the list…

function setup()
    print(stringLetter("abcdefghijklmnopqrstuvwxyz_",8))    
end

function stringLetter(s,w)
    local str=""
    for _=1,w do
        v=math.random(1,s:len())
        str=str..string.sub(s,v,v)   
    end
    return str 
end