I know how I can create a list of 4 objects (eg. "addition", "subtraction", "multiplication", "division"). How do I then select one of the items and feed that selection as the answer so that my if statements can proceed with the desired operation? Thanks a lot.
Offline
Put this in the addition sprite and similar code in the others (replace the word "addition" with the other operators).
<when[ addition ]clicked>
<set{ operator }to( addition )>
To do math:
<when I receive[ DoMath ]>
<if><( <{ operator }> <=> addition )>
<set{ result }to( (( <{ x }> <+> <{ y }> ))
<else>
<if>
etc. for all the operators
Offline
I could not find a way to do when "addition" clicked. I have posted a picture online for you to look at.
https://picasaweb.google.com/111947489942124903382/ScratchPorgraming#5668347145801730898
My script makes the list but relies and text input to proceed. How do I make it wait for me to select something from the list and how does it store what I selected? I would love your help. I can program in R but have just started Scratch.
Offline
There is a block under Control (third from the top) that activates the script under it when a sprite is clicked. I believe you are trying to replace your <ask ("what equation") and wait> block with buttons.
What I would do is make it so when the "addition" button is clicked, set a variable (called operator) to "addition" and compare that with the if statements.
Instead of
<if><( <answer> <=> addition )>
<say[ (( <{ first }> <+> <{ second }> )) ]>
<end>
use:
<if><( <{ operator }> <=> addition )>
<say[ (( <{ first }> <+> <{ second }> )) ]>
<end>
Last edited by MoreGamesNow (2011-10-28 09:50:46)
Offline
Thanks so much for your help but I am still stuck.
MoreGamesNow wrote:
make it so when the "addition" button is clicked, set a variable (called operator) to "addition"
>
That is the part I am having trouble with. I wish there was a control that said "when sprite1 operations, item 1 is clicked". Instead there is only "when sprite1 clicked". Does that mean that I need to have a separate sprite for each operation. In other words is it true to say that Scratch does not support selectable drop down lists?
Offline