Unique Save

Is there a way to assign a specific number to a specific savelocaldata()? I’m working on a model of a cashiers till and I need to add charge accounts.

Will something like this work for you.

EDIT: Or you can use account numbers to save amounts. Use listLocalData() to get accounts that have been used.


function setup()
    saveLocalData("penny",78)
    saveLocalData("nickle",20)
    saveLocalData("dime",6)
    saveLocalData("quarter",4)
    saveLocalData("half",0)
    saveLocalData("one",5)
    saveLocalData("five",10)
    saveLocalData("ten",4)
    saveLocalData("twenty",2)
    saveLocalData("fifty",0)
    saveLocalData("hundred",0)
    
    saveLocalData("112233",235.67)
    saveLocalData("223344",123.12)
    
    print(readLocalData("penny"))
    print(readLocalData("112233"))
    print(readLocalData("223344"))
end


local data is a set of key value pairs

if you want to store a whole lot of data under a particular account number, you can use the account number as the key and store the data in a table (although you would have to flatten the table into a string first)