Problem with variables

What about your Upgrade_Workers button on the Upgrades screen. Isn't that doing what you want ?

That's what my problem is about, it doesn't work at all. When I click it nothing happens when I was trying to see what is wrong with it, im pretty sure it is something with the if statement cause its not able to get pass through it and do the "then", its just stuck at the "if" statement for no reason. Cause the points label shows the correct number and when its over 50 then it should work but it doesnt for some reason

Ah, now we are getting somewhere, you have explained :wink:

Try this instead....

image

Note, it will only change things if it meets the condition. You may need to add the else section to do something if it doesn't meet the condition, otherwise nothing happens.....

Sorry, and thanks ill try that tomorrow and tell you if it worked.

Still it doesn't work and nothing is happening even tho I have 127 points. : (

I added this to see if it even detects that the number of points is higher than the upgrade price variable but it doesnt chnage the text to "worked" so it doesnt work. I don't know why cause last time I was doing the same thing but to show the price and it showed the correct price so upgrade price variable is set to 50 so I really dont know whats wrong with it.

Now I added an else statement and it did show "doesnt work" so it doesn't meet the condition somehow idk why

It will be faster to diagnose the problem on its own skin :grin:. Send the .aia file.

How do I send the .aia file?

In menu Projects, click "Export selected project (aia) to my compuuter."

And such a small note for beginners. Before you start building complex applications, start learning from simple projects, and most importantly from learning the appinventor interface, because that's the basics.

Thanks, here it is:

Business_Tycoon.aia (7.1 KB)

Should it work like this?
Business_Tycoon (1).aia (7.4 KB)

The problem is that you load the data from tinyDb into a variable, but you do math on the labels. Do math operations on variables and use labels only to display the results.

I did it like this:


I added a variable for points too, and it works but now when I click on it and have 135 points it automaticly buys me it twice instead of once

I didn't notice him buying twice. The price for the update goes up x2.7. So you have to collect more points each time to update. After updating, the price for the update is subtracted from the points. This is how it works in the aia file I posted.

It worked fine but I unplugged the tinyDB for points block in screen 1 and 2 so that the money will go back to 0 to test it and then plugged it back in but now when i go to screen 2 it shows text for label 1 when it should say 50 points or whatever the price is and for the number of upgrades it shows text for label 2

oh wait I see i moved few things in the upgrade button code to sort it but i broke it

For testing, set up a button somewhere that will clean the tags in tinyDb.

How do you reset the connection properly cause whenever i click on hard reset it isnt doing anything and it still remembers the number of points and stuff

Okay it all works now, Thank you so much for helping me again. And thanks for the tip you gave me, really useful. :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.