Discuss Scratch

CyclonicFrost
Scratcher
7 posts

Making upgrades for my Tower Defense game.

Hey, I need help with making upgrades in my Tower Defense game, specifically more than 1 upgrade, like around 4 - 5 upgrades per tower. I'm currently confused on how i can start making upgrades, and also without upgrading the other clones of the tower. I would appreciate it very much if anybody could send me a simple script or advice with how to start adding upgrades into the game, Thanks!

Link to the game: https://scratch.mit.edu/projects/661763139
Torqueboostjr
Scratcher
49 posts

Making upgrades for my Tower Defense game.

There is a solution!
When creating a variable, you can set it to “For this sprite only.” To explain what that does, here is an example:
when green flag clicked
set [IsClone? v] to [0]
when I start as a clone
set [IsClone? v] to [1]

“IsClone?” is a variable set to “For this sprite only.” These two scripts mean that the original sprite will have a variable saying that it is NOT a clone, while any clones will be set to clones. Because the variable is set to “For this sprite only”, the clones will not be changing the same variable as the main sprite. A possible usage for this script here is for broadcasted messages, where you can make use of the “IsClone?” variable (or any variable used as such) to make sure only the original sprite runs the code attached to the broadcast receiver.

For your uses:
when this sprite clicked
if <(cash) > [100]> then
change [CASH v] by (-100)
change [UPGRADE v] by (1)
end
Cash could be whatever your global money variable is, and Upgrade can be a variable set to “For this sprite only” that determines the state of the clone's upgrade.

Please tell me if this helped!
CyclonicFrost
Scratcher
7 posts

Making upgrades for my Tower Defense game.

I can see how this could work, but I'm still confused because I want to have separate upgrades for separate towers, And I also want a button that says “Upgrade” and once you press on it, it changes the upgrade of the specific tower you want, similar to what your script says.
Torqueboostjr
Scratcher
49 posts

Making upgrades for my Tower Defense game.

CyclonicFrost wrote:

I can see how this could work, but I'm still confused because I want to have separate upgrades for separate towers, And I also want a button that says “Upgrade” and once you press on it, it changes the upgrade of the specific tower you want, similar to what your script says.
Well, it's most likely just going to be a slightly more advanced version of the script I gave. It's fully customizable! For example:
when this sprite clicked
if <(costume name) = [tower level 1]> then
if <<(cash) > [100]> or <(cash) = [100]>> then
change [cash v] by (-100)
switch costume to [tower level 2 v]
end
end
This is a version of the script that includes a costume number checker, which will only upgrade for a specific tower (assuming every tower has its own costume). You could use this script like a module and copy+paste it with modifying the costume number and cash amount to upgrade for different towers. This would also allow full upgrade paths from each individual starting tower.

Last edited by Torqueboostjr (March 23, 2022 13:33:23)

CyclonicFrost
Scratcher
7 posts

Making upgrades for my Tower Defense game.

Torqueboostjr wrote:

CyclonicFrost wrote:

I can see how this could work, but I'm still confused because I want to have separate upgrades for separate towers, And I also want a button that says “Upgrade” and once you press on it, it changes the upgrade of the specific tower you want, similar to what your script says.
Well, it's most likely just going to be a slightly more advanced version of the script I gave. It's fully customizable! For example:
when this sprite clicked
if <(costume name) = [tower level 1]> then
if <<(cash) > [100]> or <(cash) = [100]>> then
change [cash v] by (-100)
switch costume to [tower level 2 v]
end
end
This is a version of the script that includes a costume number checker, which will only upgrade for a specific tower (assuming every tower has its own costume). You could use this script like a module and copy+paste it with modifying the costume number and cash amount to upgrade for different towers. This would also allow full upgrade paths from each individual starting tower.

What will the script be to check the costume name? sorry for responding so late, I was doing something.

Powered by DjangoBB