Possibly a bug or my misunderstanding of coding

I tried to have user ids you will find that if you press refresh the ending numbers will not match.

I have a len()-2 to get rid of the “.0”

Is this due to possibly some automated rounding?


function setup()
    user = "david.hall"
    x = math.random(1000, 1000000000000)
    y = tostring(x)
    z = string.sub(y, 0, y:len()-2)
    UserID = z
    print(UserID.." UID")
    saveLocalData(user.."UserID", UserID)
    
    a = readLocalData(user.."UserID")
    b = tostring(a)
    c = string.sub(a, 0, b:len()-2)
    LoginUser = c
    print(LoginUser.." LU")
end

@FearMe2142 - First, please keep all questions about one project, in the same thread, to avoid cluttering the forum. You can change the title by editing the first post in the thread.

Rather than generating user IDs randomly, I suggest you create them in sequence, i.e. 1,2,3…

You can use saveLocalData to store the latest allocated, then when you need a new ID, read in that number and increase by one and save it again.

@Ignatz
Alright, thank you!