Discuss Scratch

Kingawesometk
Scratcher
43 posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

For example: the noob is 200 so i buy it and it is 250 now and instead of the noob sprite showing the price as 200 it shows 250

press shop to see the noob

Game: https://scratch.mit.edu/projects/806634179/
legendary34678
Scratcher
1000+ posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

To change the price of a shop item, you'll have to save the value in a variable. Then, whenever an item is bought, you just increment that variable by 50. If you are displaying prices as costumes, you'll have to switch to using a text engine to display the price.
A_Dilophosaurus
Scratcher
31 posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

Since you want it to increase by $50 every time, you'll probably need to make a new sprite with costumes for number's 0-9 and then you should be able to make a fairly simple script that cycles through the letters of a “noob price” variable and switches the costume to that number, then creates a clone and moves x steps to align it for the next number creation

Edit: engrish

Last edited by A_Dilophosaurus (May 13, 2023 01:30:21)

medians
Scratcher
1000+ posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

You can use a variable or a list (if you have multiple items you want to do this for) by going into the orange Data category and clicking “Make a Variable” or “Make a List”, and then entering the name you want for it.
If you're using a variable, you can use this block:
change [price v] by (50)
If you're using a list, you can use these blocks:
replace item (1 v) of [prices v] with [thing]

(item ( v) of [prices v])
melonmasteristaken
Scratcher
23 posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

A_Dilophosaurus wrote:

Since you want it to increase by $50 every time, you'll probably need to make a new sprite with costumes for number's 0-9 and then you should be able to make a fairly simple script that cycles through the letters of a “noob price” variable and switches the costume to that number, then creates a clone and moves x steps to align it for the next number creation

Edit: engrish

You could watch griffpatches video on that
Hollowness
Scratcher
54 posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

Nah you don't need a new variable. If you're using a sprite as a button to buy the noob thing, just make it go to the next costume every time it is bought, and the price will be:-

((50) * (costume #))

Also write the prices on the costumes, that way you don't need to get a text engine
Kingawesometk
Scratcher
43 posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

Hollowness wrote:

Nah you don't need a new variable. If you're using a sprite as a button to buy the noob thing, just make it go to the next costume every time it is bought, and the price will be:-

((50) * (costume #))

Also write the prices on the costumes, that way you don't need to get a text engine

medians wrote:

You can use a variable or a list (if you have multiple items you want to do this for) by going into the orange Data category and clicking “Make a Variable” or “Make a List”, and then entering the name you want for it.
If you're using a variable, you can use this block:
change [price v] by (50)
If you're using a list, you can use these blocks:
replace item (1 v) of [prices v] with [thing]

(item ( v) of [prices v])
I knew i could do that i was just wondering how i could use less sprites so its not so laggy to do it
medians
Scratcher
1000+ posts

How can i make it so the price is changed by 50 every time the noob is bought and the price text says the price

Kingawesometk wrote:

I knew i could do that i was just wondering how i could use less sprites so its not so laggy to do it
Well, you don't really have to create sprites to do this, but if you want to cut down on existing sprites, you could try clones
If you don't want to use many variables, a list could help.

Powered by DjangoBB