Help

Hello.

How can i save „h“ „t“ „zt“ „ht“ „m“ and „pres“ in this code??

-- Clickers


displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    fontSize(100)
    fill(0, 224, 255, 255)
    h=0
    h=readLocalData("save_h") or 0
    t=0
    t=readLocalData("save_t") or 0
    zt=0
    zt=readLocalData("save_zt") or 0
    ht=0
    ht=readLocalData("save_ht") or 0
    m=0
    m=readLocalData("save_m") or 0
    pres=0
    pres=readLocalData("save_pres") or 0
end

-- This function gets called once every frame
function draw()

    -- This sets a dark background color 
    sprite("Cargo Bot:Opening Background",512,384,1024,768)

    -- This sets the line thickness
    strokeWidth(5)
    
    text("Hundert: "..math.ceil(h), 500, 100)
    text("Tausend: "..math.ceil(t), 500, 200)
    text("Zentausend: "..math.ceil(zt), 500, 300)
    text("Hunderttausend: "..math.ceil(ht), 500, 400)
    text("Milionen: "..math.ceil(m), 500, 500)
    text("Prestiue: "..math.ceil(pres), 500, 700)


    --Aufstufung

    if h == 1000 then
        t=t+1
        h=h-h
        end

    if t == 10 then
        zt=zt+1
        t=t-t
        end

    if zt == 10 then
        ht=ht+1
        zt=zt-zt  
        end

    if ht == 10 then
        m=m+1
        ht=ht-ht
        end
    if m == 1 then
        h=h-h
        t=t-t
        zt=zt-zt
        ht=ht-ht
        m=m-m
        pres=pres+1
    end
end

function touched(touch)
    if touch.state==BEGAN then
        h=h+1
        saveLocalData=("save_h"), h
        end
    end

Ok thank you and Sorry… i understand it now :slight_smile:

Here’s how to save those values.

function touched(touch)
    if touch.state==BEGAN then
        h=h+1
        saveLocalData("save_h",h)
        saveLocalData("save_t",t)
        saveLocalData("save_zt",zt)
        saveLocalData("save_ht",ht)
        saveLocalData("save_m",m)
        saveLocalData("save_pres",pres)
    end
end

Thanks

@Biberjumper It takes time to understand how to do things. The best way to learn is to try different things and see what happens.

Ok. I will tri it :smiley:

@Biberjumper Please stop creating new discussions for each of your questions. When you have a question just post it in one of your existing posts. The format for saving local data is saveLocalData(“name”,value). When you have trouble with a Codea function, see the built in reference to see how to use that function. You can get into the reference from within the editor by pressing the key with a eye on it that’s above the e key or you can double tap on a word which will bring up a choice of options. From the option list, select reference.