Save File Button

The app is a clicker game so I would like to save the amount of clicks (represented on a button with text on it) to save.

2 Likes

You have to save only one value in your tinydb

How do I do that?

Does this work?Screenshot 2021-11-07 5.55.44 PM

1 Like

It will, but only if Counter_Button's text/value is updated each time you click the Button.

That's all I need

Do you want to update the Button's text or a separate label's text?

This won't work, if your intention is to save number of clicks, you should arrange your blocks this way

1 Like

Here, Counter_Button is just representing specific button object only, when we use dot operator to get value of specific property, that is returned.

image

To get property, we do
image

1 Like

This is what I put for when the button is clicked. Do I just put the .StoreValue by it? (Eddie is the click button)Screenshot 2021-11-08 10.32.04 AM

Values used on both side of an operator, should be of same type, this is not there

image

1 Like

If Eddie is click button then what's purpose of Counter_Button, use a globle variable instead, to keep count of clicks as I shown in earlier example code.

Since, with mathematical + you can have both operands as numbers only, else you will get error.

1 Like

The code didn't work @RamNaresh.

Please share your findings, where it doesn't work.

I used the code blocks that you said and when I downloaded the app, I clicked the button a few times. I closed the app and then opened it again and the button reset to 0.

I replicated with the same stapes, tested in companion and with apk installation as well, it's working as expected. I used the same code

blocks (16)

1 Like

@awesomesause1543, you may want to implement a "reset" Button as well...

1 Like

@RamNaresh maybe I just missed some blocks. I will look and test it later.

Ok, sure

Yes, that might be the blocks to be triggered on screen1.Initialize, to load the global i with old value from TinyDB, else it will be reinitialised with 0 every time when program start.

Thanks