@name Bank List
@inputs Scr:wirelink
@outputs Reset
@persist State
interval(1000)
Bank=gTable("sBank")
#gtable sBank
    #array Safelist
    #table Username
    #table GlobalData
        #table Vaults
            #table VaultObject
                # 1 - number Owned
                # 2 - array Owners
                    # string Owner
                # 3 - entity Door
    #string SteamID32 - table UserObject
        #number Timeleft
        #array Owned
if (first()) {
    function string getTime(Num:number) {
        Min=floor(Num/60)
        Sec=Num-(Min*60)
        if (Sec>=10) {
            return ""+Min+":"+Sec
        } else {
            return ""+Min+":0"+Sec
        }
    }
}
if (clk()) {
    local Line=0
    Scr:writeString(" ":repeat(30),0,0)
    Scr:writeString("Safe ID",0,0)
    Scr:writeString("Time",9,0)
    Scr:writeString("Owner",17,0)
    foreach(I,V:string=Bank["Safelist",array]) {
        Line++
        local Safe=Bank["GlobalData",table]["Vaults",table][V,table]
            #print(Safe["Owners",array]:count())
        local Steam=Safe[2,array][2,string]
        local UserData=Bank[Steam,table]
        local Timeleft=UserData["Timeleft",number]
        local Name=Bank["Username",table][Steam,string]
        Scr:writeString(" ":repeat(30),0,Line)
        local Color=Safe[1,number] ? vec(255) : vec(172)
        Scr:writeString(V,0,Line,Color)
        
            Scr:writeString(""+getTime(Timeleft),9,Line,Color)
        
        if (Safe[1,number]) {
            Scr:writeString(Name,17,Line,Color)
        } else {
            Scr:writeString("Unowned",17,Line,Color)
        }
    }
}
