Discuss Scratch

ValdezFirewolf15
Scratcher
7 posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

So in my clicker game, you can buy any upgrade infinitely with enough points. I'm trying to figure out how to make it so that you can only get it once.
Code (number values vary):
whenthisspriteclickedifPoints>9thenswitchcostumetocostume2changePointsby-10changePoints per Secondby3stopthis script

Last edited by ValdezFirewolf15 (Sept. 22, 2021 15:48:36)

--Dovahkiin--
Scratcher
100+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

So that wouldn't work because the script will turn off already without the “stop this script” block, and will reactivate when the sprite is clicked. Depending on how many upgrades you have, I would label them with numbers and create a list to see if its already been bought.
whenclickedrepeat6addtolist upgrades change the 6 to how many upgrades you havewhenthisspriteclickedifitem1oflist upgrades=0thenifPoints>9thenswitchcostumetocostume2changePointsby-10changePoints per secondby3replaceitem1oflistwith1 change the item 1 to whatever upgrade number it iselse change the item 1 part to what ever upgrade number it is

Now you can have this on all your upgrades and you don't need a ton of variables

Last edited by --Dovahkiin-- (Sept. 22, 2021 16:28:36)

aarizkamran
Scratcher
100+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

simple:
whenclickedrepeatnumberoftimesyouneedtoupgradewaituntilpoints>9andmousedown?andtouchingmouse pointer?changepointsby-10changepoints per secondby3
LG125
Scratcher
500+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

aarizkamran wrote:

simple:
whenclickedrepeatnumberoftimesyouneedtoupgradewaituntilpoints>9andmousedown?andtouchingmouse pointer?changepointsby-10changepoints per secondby3

Here’s a better version and why: (common mistake i see)
whenclickedrepeatnumberoftimesyouneedtoupgradewaituntilpoints>9andmousedown?andtouchingmouse pointer?i could click and hold, then hover over the thing and it would continue the script because all if statements are true, also.changepointsby-10changepoints per secondby3there is no wait until not mouse down which means if i hold down the button, it will continue buying.

Revised version:
whenclickedrepeatnumberoftimesyouneedtoupgradewaituntilpoints>9andmousedown?iftouchingmouse pointer?thenchangepointsby-10changepoints per secondby3waituntilnotmousedown?also bug fixed.bug fixed

Last edited by LG125 (Sept. 22, 2021 22:44:28)

--Dovahkiin--
Scratcher
100+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

This isn't what he wanted. He wanted a upgrade that could only be bought once

“I'm trying to figure out how to make it so that you can only get it once”

You making it possible for it to be bought more than once
LG125
Scratcher
500+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

--Dovahkiin-- wrote:

This isn't what he wanted. He wanted a upgrade that could only be bought once

“I'm trying to figure out how to make it so that you can only get it once”

You making it possible for it to be bought more than once
Oh.

Then a list wouldn’t be necessary, only a variable. When the flag is clicked, set it to 0 (unless you wont reset everyone’s progress when flag clicked) and when item bought, set variable to 1.
cs3432909
Scratcher
75 posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

--Dovahkiin-- wrote:

This isn't what he wanted. He wanted a upgrade that could only be bought once

“I'm trying to figure out how to make it so that you can only get it once”

You making it possible for it to be bought more than once

This script should make it possible for it to only be bought once


whenclickedsetbuyable?to1


whenthisspriteclickedifbuyable?=1thensayPut your script here that adds a multipliersetbuyable?to0

Last edited by cs3432909 (Sept. 23, 2021 13:17:47)

--Dovahkiin--
Scratcher
100+ posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

LG125 wrote:

--Dovahkiin-- wrote:

This isn't what he wanted. He wanted a upgrade that could only be bought once

“I'm trying to figure out how to make it so that you can only get it once”

You making it possible for it to be bought more than once
Oh.

Then a list wouldn’t be necessary, only a variable. When the flag is clicked, set it to 0 (unless you wont reset everyone’s progress when flag clicked) and when item bought, set variable to 1.
The thing is, depending on how many upgrades there are, a list would hold all of them in one spot while on the other hand if you used variables you would need like 10 for 10 upgrades which could get chaotic
ValdezFirewolf15
Scratcher
7 posts

How To Make A Clicker Game Shop: Upgrade Buy Limit

--Dovahkiin-- wrote:

So that wouldn't work because the script will turn off already without the “stop this script” block, and will reactivate when the sprite is clicked. Depending on how many upgrades you have, I would label them with numbers and create a list to see if its already been bought.
whenclickedrepeat6addtolist upgrades change the 6 to how many upgrades you havewhenthisspriteclickedifitem1oflist upgrades=0thenifPoints>9thenswitchcostumetocostume2changePointsby-10changePoints per secondby3replaceitem1oflistwith1 change the item 1 to whatever upgrade number it iselse change the item 1 part to what ever upgrade number it is

Now you can have this on all your upgrades and you don't need a ton of variables
Thank you so much!

Powered by DjangoBB