Discuss Scratch

Tanman399
Scratcher
33 posts

exponents

how do I add an exponent to my game, I want to make diminishing returns for a certain upgrade and know an equation to do it but it involves an exponent and there is no ^ equation block
GamesReinvented
New Scratcher
100+ posts

exponents

nvm

Last edited by GamesReinvented (Oct. 3, 2024 21:20:37)

happywaffle0
Scratcher
100+ posts

exponents

GamesReinvented wrote:

I might wanna erase this stuff…
([10 ^ v] of ([log v] of ((x) * (y))))
ohh how'd that get there lol

Well, speaking that 10^x and log10(x) cancels out, this doesn't work.

Last edited by happywaffle0 (Oct. 3, 2024 21:31:28)

GamesReinvented
New Scratcher
100+ posts

exponents

nvm

Last edited by GamesReinvented (Oct. 3, 2024 21:20:28)

happywaffle0
Scratcher
100+ posts

exponents

GamesReinvented wrote:

Try using the block, it's not 10 ^ (log(x)), it's first multiplying the power.

Well, it multiplies the power first, then takes the log10 value of it, then 10 is raised to the power of that number.

You see, logarithms undo the power it's raised to. Scratch uses base 10 for this.

here's an example of that:
logb(b^a) = a

After you log it, it gets reraised to the original base it was (b in this case)

b^a.

——————-

the equation you put at the start is the exact same as

([e^ v] of ([ln v] of ((a) * (b)))::operators

Last edited by happywaffle0 (Oct. 3, 2024 21:08:47)

Tanman399
Scratcher
33 posts

exponents

I know one of the variables is the amount of the upgrade owned but what is the other variable in the equation?
GamesReinvented
New Scratcher
100+ posts

exponents

editted: I hate getting my math messed up, quite embarrassing
idk how I didn't realize that the block I gave earlier is the same as just doing x*y

Correct block is shown below:
([10 ^ v] of ((y) * ([log v] of (x))))
If you're getting x^y.

For example, if you're getting 7^3, you'd use the block like so:
([10 ^ v] of ((3) * ([log v] of (7))))

Additionally, you can round the answer to fix any floating point errors that occur, because it doesnt always give an exact answer:
((round (([10 ^ v] of ((y) * ([log v] of (x)))) * (1000))) / (1000))

Last edited by GamesReinvented (Oct. 3, 2024 21:28:22)

Powered by DjangoBB