Asked — Edited
Resolved Resolved by Dunning-Kruger!

Random Personality Script Not Running

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


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

#17  

yes $QuestionAnswer = "yes" no $QuestionAnswer = "No"

I will post my entire solution to the cloud as public if that helps.

#18  

posted it to incomplete bots, called Wall-e_Full-dcochran

PRO
Synthiam
#19  

Can you post the piece of code that assigns the values to the $QuestionAnswer from the speech recognition?

#20  

all it does, in the voice recognition section is a single line for yes and for no. The box looks like this

Phrase | Command -----------------+----------------------------------- Yes | $QuestionAnswer = "yes" -----------------+--------------------------------- No | $QuestionAnswer = "No" -----------------+----------------------------------

drawn in asci for those of us that remember BBS systems:)

PRO
Synthiam
#21  

Roger that, okay!

That was my biggest concern is because no where in the code you pasted is the variable changed.

Keep in mind that every time the personality script runs, the variable will equal the last value. If you said YES last time, and say YES again - the WaitForChange() will never stop.

I would recommend clearing the variable at the top of the script. Set the variable to = "" at the top of the script.

#22  

There is a chunk after the variable is evaluated and the robot does what it is going to do that it sets this variable back to ""

Thanks for digging into this so much DJ. I do really appreciate it.

PRO
Synthiam
#23  

oops I didn't fix the missing code within the IF conditions for you. Here is the working proper code... You always need something in the IF or ELSEIF or ELSE condition. You can't have a condition that is empty, otherwise it doesn't make logical sense to the stack. You need to always have something in there. More than just a comment. Programming is a logical execution of commands, it's pretty straight forward. The challenge is identifying the order of those commands. But having empty commands doesn't make logical sense:)


:GeneratePersonality

$QuestionAnswer = ""

$personality = GetRandom(0,19)

IF ($personality = 0)
  
  say($personality)
  
ELSEIF ($personality = 1)
  
  ControlCommand("Script Manager", ScriptStart, "TellMeAJoke")
  
ELSEIF ($personality = 2)
  
  ControlCommand("Script Manager", ScriptStart, "SayRandomFact")
  
ELSEIF ($personality = 3)
  
  say($personality)
  
ELSEIF ($personality = 4)
  
  say($personality)
  
ELSEIF ($personality = 5)
  
  say($personality)
  
ELSEIF ($personality = 6)
  
  say($personality)
  
ELSEIF ($personality = 7)
  
  say($personality)
  
ELSEIF ($personality = 8)
  
  say($personality)
  
ELSEIF ($personality = 9)
  
  say($personality)
  
ELSEIF ($personality = 10)
  
  Say("Can I chase the ball?")
  
  :ChaseBall
  
  WaitForChange($QuestionAnswer)
  
  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 
    
ELSEIF ($personality = 11)
  
  say("Did you know it is ")
  ControlCommand("Script Manager", ScriptStart, "SayTime")
  
ELSEIF ($personality = 12)
  
  say($personality)
  
ELSEIF ($personality = 13)
  
  say($personality)
  
ELSEIF ($personality = 14)
  
  say($personality)
  
ELSEIF ($personality = 15)
  
  say($personality)
  
ELSEIF ($personality = 16)
  
  say($personality)
  
ELSEIF ($personality = 17)
  
  say($personality)
  
ELSEIF ($personality = 18)
  
  say($personality)
  
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 
  
  say($personality)
  
ENDIF 
  
SleepRandom(1000,6000)

goto(GeneratePersonality)

#24  

@DJ said; "Programming is a logical execution of commands". Humm, I must be too much in touch with my feminine side and that's why I sometimes struggle with writing code that works. :P

Sorry gals. ;)