Asked
— Edited

I have switched my robot over to Ez-Robot and I need some help converting the following Python script over the EZ-Robot language.
if (data == "lets do some math"): math()
if (data == "one"):
one()
global first
first += 1
print(first)
if (data == "two"):
two()
global first
first += 2
print(first)
if (data == "three"):
three()
global first
first += 3
print(first)
if (data == "four"):
four()
global first
first += 4
print(first)
if (data == "five"):
five()
global first
first += 5
print(first)
if (data == "add one"):
plusone()
global second
second += 1
print(second)
if (data == "add two"):
plustwo()
global second
second += 2
print(second)
if (data == "add three"):
plusthree()
global second
second += 3
print(second)
if (data == "add four"):
plusfour()
global second
second += 4
print(second)
if (data == "add five"):
plusfive()
global second
second += 5
print(second)
if (data == "what does that equal"):
equals()
global number
number = (first+second)
i01.mouth.speak(str(first) + "plus" + str(second) + "is" + str(number))
global first
first = (first + second)
global second
second = 0
if (data == "start over"):
i01.mouth.speak("OK")
rest()
sleep(2)
i01.mouth.speak("ready")
global first
first = 0
global second
second = 0
print("starting from 0")
It's a script where the robot does addition. Can anyone help me out with this, thanks
What's up with the
?
Still working on it, when I run the script it says "false" - progress!
Sayezb("$x" + "$y" = "number")
sure the variables should be in quotes?
@bhouston, the sooner you forget everything about other languages the easier it will become. Your code above, as far as EZ-Script is concerned, doesn't make much sense.
EZ-Script is script. It will follow it line by line. Where you set the variable $data on line 5 and 6, line 5 is pretty much redundant as it immediately changes to what it's set as in line 6.
Also, "$x + $y =" is not valid.
Where does $x come from? Your IF checks against $x yet it's set to "first number" at the start of the script, nothing changes it from that.
To be honest there is a lot wrong with the script and very little that is right. Read through the EZ-Script manual, follow the EZ-Script tutorial and check out some other projects scripts from the cloud and the examples folder in ARC. For variables and IFs etc. check out the Introduction To Scripting topic I wrote some time ago, while there may have been some minor syntax changes since (possibly) it was minimal and pretty much limited to requiring quotes around strings.
@ Rich, as you can see, I am not a script "writer", I am more of a script "user". Once having script that is similar to what I want, I can manipulate it to meet my needs. Having said that it is my goal to become a script "writer", however, it will be a long road. I am reading what you suggested.
Backing up to my first post;
if (data == "lets do some math"): is "heard data" from a voice command. In your "Introduction to Scripting" is see how to add input from a sensor but I'm not clear on how you add input from a voice command into a variable.
Thanks
There is a sample project that I put out on the cloud a while back that might help you. I am busy with work this week so I wont have much time to help, but this should help you get an idea of what needs to be done.
:D my wall-e
There is a script called something like personality. It will help with scripting.
There is one called Init that will help you setup your variables. There is a voice recognition command that is yes. it will help show you how to set a variable based on a voice command.
There is a lot more in there but these 3 things should help you get moving.
The name of the script is Personality Generator
if you look at personality 10, you will see the WaitForChange command that you will need to use. It also shows how to use labels and goto.
Look up the WaitForSpeech() command in the EZ-Script manual and check out the example for WaitForSpeech() in the ARCs examples. Both should help you answer your own question (hopefully).
If not, come back and ask again and I'll give you some more help.