Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by JustinRatliff!

Array Entry Format

I am trying to write an Array of ControlCommand scripts but I get an error message when I Run it. What is the correct format for this kind of entry?




User-inserted image


Thank you.

PRO
Canada
#1  
Hello @OldBotBuilder,

I believe the Array is looking for a $value to store, rather than a ControlCommand.

Are you looking to have a quick way to switch between ControlCommand() movements quickly?

Could you describe what your end goal is? Likely if we get an idea of what you'd like to achieve a few of us can offer a couple different scenarios on how to get there.

For the future, you may want to mark this kind of thread as "Needing Assistance" as you'll likely have many people offering scripting help due to the fact that they may get ez-credit for answering the question.
PRO
Synthiam
#2  
You can't assign a procedure to a variable. Variables can store data, not commands. A variable can store things like numbers or strings. Variables cannot store another command.
#3  
@Jeremie,

Yes, I want to switch between ControlCommand() movements quickly to give my 'Segway' robot random movements. I was going to select these movements with a 'GetRandom(Min,Max)' index into an array of movement commands.

My Custom Movement Panel has the normal 4 movements but I have added 4 more commands, 'spin left', 'spin right', 'backward left', and 'backward right'.

Quote:

For the future, you may want to mark this kind of thread as "Needing Assistance" as you'll likely have many people offering scripting help due to the fact that they may get ez-credit for answering the question.

I did mark this thread as Needing Assistance.
#4  
Why not use the 'GetRandom(Min,Max)' 0-6 then use IF/Then logic for the movement commands. IF GetRandom = 0 then forward.
#5  
@JustinRatliff,

I think you have the solution. I'll try it.
Thanks
PRO
Canada
#6  
Interesting that this thread didn't have the red exclamation mark beside the title so I assumed it wasn't an "Assistance needed" thread, my apologies.
#7  
Nice going Jeremie, you broke the Internet! :P

j/k

P.S. BotBuilder, let me know if that works or if you need a better code example.
#8  
@JustinRatliff,

Worked exactly as I wanted. I should have looked for the obvious instead of the "elegant" solution.

Here is the script:

Code:


$y = GetRandom(0,7)
if ($y=0)
ControlCommand("Script Manager", ScriptStart, "Forward")
elseif ($y=1)
ControlCommand("Script Manager", ScriptStart, "Left")
elseif ($y=2)
ControlCommand("Script Manager", ScriptStart, "Right")
elseif ($y=3)
ControlCommand("Script Manager", ScriptStart, "Backward")
elseif ($y=4)
ControlCommand("Script Manager", ScriptStart, "Backward Left")
elseif ($y=5)
ControlCommand("Script Manager", ScriptStart, "Backward Right")
elseif ($y=6)
ControlCommand("Script Manager", ScriptStart, "Spin Left")
elseif ($y=7)
ControlCommand("Script Manager", ScriptStart, "Spin Right")
endif


Thanks!
#9  
Just a though, you could also use the personality generator for this type of random action.

Just a thought.
#10  
The personality generator is still a mystery to me. Have you used it Luis? I guess I never think about it because I have not seen many examples of how to use it.