Asked
— Edited

I cant seem to get this script to do anything other than to assign a random number to the $personality variable. When I run the script, it changes the variable and does nothing. I have been watching the variable change and it does hit 1, 2, 10 and 19 but nothing fires from there. Does anyone see anything wrong with the script? I am on version 2014.5.27 of the ARC software and this is running in a script manager. Thanks for any help you can provide.
# Get a response value
$personality = GetRandom(0,19)
If($personality = 0)
# dance
ElseIf($personality = 1)
ControlCommand("Script Manager", ScriptStart, "TellMeAJoke")
ElseIf($personality = 2)
ControlCommand("Script Manager", ScriptStart, "SayRandomFact")
ElseIf($personality = 3)
# ask if anyone else is getting hungery
ElseIf($personality = 4)
# Call Maples name and start autonimous movement
ElseIf($personality = 5)
# make a huge expression then look down with your arms hung low.
ElseIf($personality = 6)
#check the temp and if it is hot or cold, make a comment about it
ElseIf($personality = 7)
#Act like you are reading
ElseIf($personality = 8)
#look up and find someone, identify them, and ask how they are doing today.
ElseIf($personality = 9)
#see if it dark and if so, see if it is after 9 PM. if so, ask if it is bedtime
ElseIf($personality = 10)
Say("Can I chase the ball?")
:ChaseBall
WaitForChange($QuestionsAnswer)
if ($QuestionAnswer = "yes")
ControlCommand("Script Manager", ScriptStart, "ChaseColor")
Elseif ($QuestionAnswer = "no")
#look sad
else
say("I did not hear you. Can I chase the ball?")
endif
If($QuestionAnswer = "")
Goto(ChaseBall)
endif
$QuestionAnswer = ""
ElseIf($personality = 11)
say("Did you know it is ")
ControlCommand("Script Manager", ScriptStart, "SayTime")
ElseIf($personality = 12)
#autonomous collision avoidance
ElseIf($personality = 13)
#look mad and play mad sound
ElseIf($personality = 14)
#sway from side to side and play song
ElseIf($personality = 15)
#find someone and wave at them
ElseIf($personality = 16)
#look sad and say eve
ElseIf($personality = 17)
#scratch head - Thinking
ElseIf($personality = 18)
#Raise arms and gears
#Make yawn sound
ElseIf($personality = 19)
#look up and find someone
ControlCommand("Script Manager", ScriptStart, "FollowMotion")
ControlCommand("Soundboard", Track_4)
ControlCommand("Script Manager", ScriptStart, "kiss")
Left(255,1000)
Right(255,1000)
else
endif
If you are implying that the issue is with the variable $QuestionsAnswer having the "s" between "$Question" and "Answer", I corrected that silly mistake. Thanks DJ for finding that. It would have driven me crazy, but that isn't the issue that I am seeing.
To try to get to the bottom of what is going on, I did this.
This works.
However, when I change the script to this
The script breaks. It looks like there is an issue with placing #comments inside of an if statement?
It's not the # in the elseif I think that's the problem. I think you need some code after each "if" and "elseif" statement... Your code didn't work for me either until I threw in a print("anything here") command after each if and elseif statement... It then worked as expected... Ignore the smilely face, it's a known bug on the webpage... supposed to be a close bracket
Thanks Richard!
I was using those as place fillers but replaced them with Say("the description") until I could script each section. This works.
Have a great day!
Hey, you're welcome... This helped me learn as well, because I didn't know this until just now either...
That was going to be my next item to get you to look at. You can't have an empty IF or ELSEIF because it's an empty instruction. It needs at least something in there.. Otherwise it assumes the ELSEIF is from a different nest in the stack.
Back to the first problem i'm helping you identify. It had nothing to do with the variable name spelling (although I didn't catch that and you did).
I'd like you to tell me what you think the command WaitForChange() does and how it pertains to Speech Recognition...
Ok, looks like I am in this too.... Hmmm... WaitForCange() I am also trying to grasp what you are getting at with it, DJ..... I too am missing something here and I really want to learn why...
As a side note... One thing great about what you have created here with ARC is software that is easy enough to initially grasp, yet can take a lifetime to master... This way it keeps you hooked because learning is ongoing.... ARC can match a persons abilities and knowledge as you learn... And no, I haven't had any beer (yet) today... Just lamenting on how much I have learned programming wise since I stated using ARC about 8 months ago.... Learned more in that time frame then I did in the last 10 years of this hobby...
sorry about that. well, I is waiting for a variable to change.
What happens in the script is the robot asks a question. It then waits for the variable to change. The voice recognition section sets the variable to yes or no depending on the response, thus changing the variable and allowing this script to then evaluate the variable and continue based on the value of the variable. That's what it's doing and how it is working anyway. Do I understand this correctly?
Can you post the code on the Speech Recognition Section that changes the variable based on the speech input?