Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » can you import a text file as a script?
- nilanjenator
-
Scratcher
100+ posts
can you import a text file as a script?
I want to create a set of pen movements. Can I create a list of commands in a text file and import them into my script.
e.g., suppose I create a file such as:
pen down
goto 1,1
pen up
goto 1,12
e.g., suppose I create a file such as:
pen down
goto 1,1
pen up
goto 1,12
- footsocktoe
-
Scratcher
1000+ posts
can you import a text file as a script?
I want to create a set of pen movements. Can I create a list of commands in a text file and import them into my script.
e.g., suppose I create a file such as:
pen down
goto 1,1
pen up
goto 1,12
Yes. A text file will import as a list. So then you take the list and examine it one item at the time and do an IF-THEN on the item.
So it would be like
Set New Command to Item 5 of List of Commands
If New Command = “pen down” then
Pen Down
If New Command = “pen up” then
Pen Up
You will probably want to use abbreviations and simplifications, like pd = pen down and pu = pen up. Then you have to work out a system for the moves. For instance, when the New Command is “move” then the next item is how many steps.
- Discussion Forums
- » Questions about Scratch
-
» can you import a text file as a script?