Award
Congratulations JustinRatliff, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Array Entry Format

Assistance Requested

Help OldBotBuilder with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

OldBotBuilder claims to have checked these sources:
 
#1

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.

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

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.

#3

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.

#4

@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.

#5

Why not use the 'GetRandom(Min,Max)' 0-6 then use IF/Then logic for the movement commands. IF GetRandom = 0 then forward.

#6

@JustinRatliff,

I think you have the solution. I'll try it.
Thanks

#7

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.

#8

Nice going Jeremie, you broke the Internet! Tongue

j/k

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

#9

@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!

#10

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

Just a thought.