Help with running program from list

Hi, I am trying to recreate the game Lightbot. I have created a list that would store the commands (walk forward, left turn, right turn), and wish to move the robot sprite when the user clicks on the Run button. How would I link the lists to the robot sprite?
And second question: I want the robot tile to move on cube tiles, how would this be different to having 2D tiles? Thanks

Hi, welcome to the forum!

Are the items in your list blocks, or text? In other words, did you say
untitled script pic
or did you say

In the latter case, you can just say
untitled script pic (2)
(where COMMAND is an item number) but in the former you have to do
untitled script pic (3)
... etc. (where COMMAND is text the user typed).

As for 3D, I recommend getting 2D working first!

I used sprites (forward, left right), and when the user selects the sprites it is added to the list.
For the forward command I used the following script for the sprite:
Lightbot script pic (1)

And the following script for the Run Button:

Lightbot script pic (3) .

For the run button, you would need to drag the item variable from the for loop into the run command, like this:

untitled script pic (5)

It would be easier to help you if you could share the project with us. Just go to the SNAP! homepage, click on your name in the top right, then select My Projects and find the project you want to share. Then click on it, hit Share and post the link here. Hope this helps!

I added the item variable, and when I run the program to move the robot, the "Forward" sprite moved as well.

There is also another problem: the if-else statement on my robot sprite is not working properly. When the program runs, it only executes the else statement.

the "Forward" sprite moved as well.

When you are running the FOR loop, the "move 30 steps" belongs to the "Forward Command" sprite, if you know what I mean. Even if it wasn't like that, it would be the "Run Button" sprite that would run it.
The only reason the robot is moving is because of the "Run Commands" message.
Try this: Lightbot script pic

it only executes the else statement

All I can say is that "[move 30 steps]=[move 30 steps]" gives false as a result.

Nope. It works either way. Dragging down the variable is parallel to the numeric FOR block, which requires dragging the index variable into the script. Leaving the slot empty is parallel to MAP, KEEP, and COMBINE, which use implicit binding of empty input slots. Since FOR EACH sort of has a foot in each world, it accepts both.

thanks, I think it worked. And another question: I would like my robot to move along the tiles with a change in y=17 and a change in x=28. How can I do this? I have tried this, but it does not work.
Lightbot script pic (4)

When I added "move by [] steps" the robot does not move evenly along the tiles.

I don't understand why you have any of that code in the robot. You let the user set up an arbitrary list of commands, but instead of just running them, you have a specific set of actions built in. That's the whole point of the FOR EACH -- to run whatever steps the user provided, in the order the user clicked on them.

Also, CONTAINS isn't what you mean, because it matters what order the commands are in.

You can compare a ringed block against the very same ringed block:

Google Chrome002

Oops. I completely forgot about the implicit slot-filling. :upside_down_face:

I also found that if you do this untitled script pic (6) it always works.