Discuss Scratch

cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

I am having trouble with my script for my game Soccer Rush. For subtraction, I would like the first number to be bigger than the second number so there are no decimals or negatives when you subtract. I also want to make to the equation for a division problem able for you to divide without decimals.

Last edited by cs222885 (March 19, 2018 17:14:51)

RokCoder
Scratcher
1000+ posts

Cannot Subtract or Divide!

How about something like this?

set [num2 v] to (pick random (1) to (100))
set [num1 v] to (pick random (num2) to (100))
say (join (num1) (join [ minus ] (join (num2) (join [ equals ] ((num1) - (num2)))))) for (2) secs
set [num2 v] to (pick random (1) to (10))
set [num1 v] to ((num2) * (pick random (1) to (10)))
say (join (num1) (join [ divide ] (join (num2) (join [ equals ] ((num1) / (num2)))))) for (2) secs
wookie184
Scratcher
100+ posts

Cannot Subtract or Divide!

For minus the best would be:

when green flag clicked
set [Num1 v] to (pick random (1) to (100))
set [Num2 v] to (pick random (1) to (100))
if <(Num1) > (Num2)> then
set [Answer v] to ((Num1) - (Num2))
else
set [Answer v] to ((Num2) - (Num1))
end

Please say if you want me to make one for division
crisostimo
Scratcher
500+ posts

Cannot Subtract or Divide!

([abs v] of ((Num 1) - (Num 2)))
(round ((Num 1) / (Num 2)))
cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

wookie184 wrote:

For minus the best would be:

when green flag clicked
set [Num1 v] to (pick random (1) to (100))
set [Num2 v] to (pick random (1) to (100))
if <(Num1) > (Num2)> then
set [Answer v] to ((Num1) - (Num2))
else
set [Answer v] to ((Num2) - (Num1))
end

Please say if you want me to make one for division

Please do a division one. Thankyou!
crisostimo
Scratcher
500+ posts

Cannot Subtract or Divide!

Oh I see. You're doing a math learning game.

set [Result v] to (pick random (1) to (10))
set [Numerator v] to (pick random (1) to (10))
set [Denominator v] to ((Numerator) * (Result))
cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

I don't think any of your ideas work. Please check out my project and see if I did anything wrong.
deck26
Scratcher
1000+ posts

Cannot Subtract or Divide!

cs222885 wrote:

I don't think any of your ideas work. Please check out my project and see if I did anything wrong.
So which project is it? Is it even shared?

cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

deck26 wrote:

cs222885 wrote:

I don't think any of your ideas work. Please check out my project and see if I did anything wrong.
So which project is it? Is it even shared?

Yes. The game is shared. Its called Soccer Rush.
deck26
Scratcher
1000+ posts

Cannot Subtract or Divide!

Well at the moment you deliberately set number2 to be at least as big as number1. So you're going to do something like ask what is 25 - 35 but then you ask what is 35 - 25. You KNOW the second number can't be smaller than the first so you only need to ask what is number2 - number1.

Your block

if <(Time) = <[60] > []>> then

end
is unlikely to be what you want. 60 is always greater than 0 so the right hand part evaluates as true which will be treated as 1 when you check against Time. In any case, as far as I can see you only set Time to the timer's value before you ask the question so it's not giving you any test of how long they took to answer unless you're resetting Time somewhere else.

As far as I can see you haven't done the division yet.
cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

deck26 wrote:

Well at the moment you deliberately set number2 to be at least as big as number1. So you're going to do something like ask what is 25 - 35 but then you ask what is 35 - 25. You KNOW the second number can't be smaller than the first so you only need to ask what is number2 - number1.

Your block

if <(Time) = <[60] > []>> then

end
is unlikely to be what you want. 60 is always greater than 0 so the right hand part evaluates as true which will be treated as 1 when you check against Time. In any case, as far as I can see you only set Time to the timer's value before you ask the question so it's not giving you any test of how long they took to answer unless you're resetting Time somewhere else.

As far as I can see you haven't done the division yet.
Thanks! Can you please remix my project and add in the script? I tried with mine but still couldn't get it.
deck26
Scratcher
1000+ posts

Cannot Subtract or Divide!

https://scratch.mit.edu/projects/212292712/ - I've only remixed the subtraction. Since your on-screen variables expected number1 to be the larger I switched the logic. I've removed the chance to try again with the same question which seems unnecessary and is going to give problems with the time limit.
cs222885
Scratcher
20 posts

Cannot Subtract or Divide!

deck26 wrote:

https://scratch.mit.edu/projects/212292712/ - I've only remixed the subtraction. Since your on-screen variables expected number1 to be the larger I switched the logic. I've removed the chance to try again with the same question which seems unnecessary and is going to give problems with the time limit.
Thank you! I understand now.
deck26
Scratcher
1000+ posts

Cannot Subtract or Divide!

OK, I'll probably delete it tomorrow so get what you want from it. Change your addition to match.

Powered by DjangoBB