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
It looks like the there may be an issue with elseif. I rewrote this as follows and it seems to be working. I haven't checked all of the personalities yet, but ARC seems to be liking it better like this.
I won't tell you the solution right away - but i'll ask questions to help you solve it..
Q. Where does $QuestionsAnswer get set to a value, ever?
It gets set by voice recognition.
When someone says Yes, it gets set to "Yes", and when someone says no, it gets set to "no". The parameter is created during the startup script and is initially set to "".
here is the startup script
Found it. Thanks DJ.
Still an issue. When I run the script with the elseif commands, I get this Start 1: :GeneratePersonality 3: $personality = GetRandom(0,19) 5: If($personality = 0) 85: endif 86: SleepRandom(10000,60000)
This is the script I am using to get these results.
$Personality = 12. Why is it stopping at line 5 and not making it to the elseif in line 8 or any of the others.
When running with just if statements, it gets through the script showing all like numbers like this. Start 1: :GeneratePersonality 3: $personality = GetRandom(1,20) 4: print($personality) > 17 6: If($personality = 1) 8: endif 10: If($personality = 2) 12: endif 14: If($personality=3) 15: endif 17: If($personality = 4) 18: endif 20: If($personality = 5) 21: endif 23: If($personality = 6) 24: endif 26: If($personality = 7) 27: endif 29: If($personality = 8) 30: endif 32: If($personality = 9) 33: endif 35: If($personality = 10) 55: endif 57: If($personality = 11) 60: endif 62: If($personality = 12) 63: endif 65: If($personality = 13) 66: endif 68: If($personality = 14) 69: endif 71: If($personality = 15) 72: endif 74: If($personality = 16) 75: endif 77: If($personality = 17) 78: endif 80: If($personality = 18) 81: endif 83: If($personality = 19) 90: endif 92: If($personality = 20) 93: endif 95: SleepRandom(10000,60000)
This is the script I am using for these results
Might not make any difference whatsoever, but maybe try using GetRandomUnique(1,20) instead...? I also noticed you use random numbers 0,19 with the script using elseif and 1,20 with using just the "if" statements... maybe it is the 0 value as a random# that is giving you the problem...?
how does the $QuestionsAnswer get data from the "speech recognition"? What command is populating the value to $QuestionsAnswer from speech recognition?
Do you think WaitForChange() is populating $QuestionsAnswer from speech recognition?
You're almost there!
Bingo.... found your problem! Drop your linen and start your grin'in ..... your variable $QuestionsAnswer.... look closely at it.....
....DJ you're too funny....