text stringlengths 0 897 |
|---|
The reason quotes are needed is that `cd` here is just a MiniScript function, and `"/sys"` is just a MiniScript string. MiniScript requires strings to be quoted. Without the quotation marks, it would look like you were trying to do math (`cd` divided by `sys`), and would not work at all. So even though these *loo... |
D> Always put quotation marks around paths and file names in Mini Micro. |
Now examining the file listing that `dir` gave you, you can see a half-dozen subdirectories, plus a MiniScript file (`startup.ms`) and a text file (`tips.txt`). Let's ignore those for a moment and focus on the subdirectories... and in particular, the `demo` directory. |
```terminal |
]cd "demo" |
]dir |
``` |
I haven't included the result of this `dir` command for two reasons: the demos will have probably changed a bit by the time you read this, and in any case, there are too many! When a directory listing is more than a screenful of lines, you will see something like `[3 more]` in inverse text at the bottom, and Mini Micr... |
{i:"`/sys/demo`"} |
What you find in this `/sys/demo` directory is a whole bunch of MiniScript programs. Some of them are tiny, like `countdown.ms`, which is only 70 characters. Others are quite large; the `speedConquest.ms` game is over 24 thousand characters! A few are simple text demos that could have been done in command-line MiniS... |
To play any of these programs, you first `load` it with a full or partial file path, and then `run`. For example: |
{i:"`/sys/demo`,`mochiBounce`"} |
```terminal |
]load "mochiBounce.ms" |
193 lines loaded from /sys/demo/mochiBounce.ms |
]run |
``` |
{width:"75%"} |
 |
PRINT>That should produce a screen that looks like this picture on the previous page. |
EBOOK>That should produce a screen that looks like the picture above. |
Now you can play the game! Hold the space bar to make the mochi jump, and use the left and right arrow keys to make it veer left or right. See how far you can climb! Be sure your computer speakers are on to hear the sound effects. The game will end when you miss, or you can exit out by pressing the Escape key. |
D> To exit out of most Mini Micro programs, press Escape. If that doesn't work, you can always break out by pressing Control-C. |
To try the program again, just enter `run` again. Or as a shortcut, you can press the up-arrow key to bring back the last command, and then hit Return. |
D> At any blinking input prompt, you can use the up and down arrows to step through previous inputs. |
That was fun! Let's try a much simpler one. Clear the screen, then load a different demo: |
```terminal |
]clear |
]load "countdown" |
]run |
``` |
PRINT>This is a very simple program indeed. But let's use it to explore editing and saving a program. Enter `edit`. The Mini Micro program editor opens, as shown in the picture on the next page. |
EBBOK>This is a very simple program indeed. But let's use it to explore editing and saving a program. Enter `edit`. The Mini Micro program editor opens, as shown in the picture below. |
 |
{i: "code editor, Mini Micro"} |
Here you can use the mouse and keyboard as you would in any code editor. It supports undo and redo, cut/copy/paste, a sophisticated search & replace function, a Navigate menu (much more useful on bigger programs), and a Code menu that can insert various code snippets for you. Hover over any of the buttons at the top ... |
Right now the program counts down from 10 to 1, waiting for 1 second (the default time for `wait`) between each number. Let's say we're impatient. Change line 3 to read |
{number-from: 3} |
```miniscript |
wait 0.25 |
``` |
so that it waits only a quarter second between each number. Now click the "X" (Close) button at the left end of the toolbar. The program editor closes. Now `run` the program again. You should see it count down much faster. |
But our changes at this point are only in memory; they have not been saved to disk. So if you quit Mini Micro at this point, your changes would be gone. Normally you could just enter `save` (or use the save button in the code editor) to save a file to wherever it came from, but this file came from the `/sys` disk, wh... |
```terminal |
]save "/usr/fastCountdown" |
6 lines saved to /usr/fastCountdown.ms |
``` |
Now that you know how to load, run, edit, and save the demos, explore! There are are over two dozen demos in `/sys/demo`, all of them different. Most of them will be fairly obvious how to use; for anything that looks like a graphical game, try the arrow keys and spacebar, or in some cases the mouse. If you see a bli... |
If you have trouble figuring out how to use a demo, `edit` it and read the comments at the top of the file. In fact, even if you *don't* have trouble using a program, look over the script anyway! There may be much you don't understand yet, but don't get discouraged. A few weeks ago you didn't know how to read MiniSc... |
For now, just skim them over, read the comments at the top, and see if you can find the main loop (usually at the bottom). This will prepare your brain for all the fun new stuff we're going to pour into it over the next two weeks. |
## Getting Help |
Mini Micro has a lot of new functions and classes for you to use. Fortunately you don't have to remember them; there are several good resources to teach or remind you about them. |
This book is one, of course. Here you find more in-depth explanation of the key features and step-by-step examples, all presented in a thoughtful order where each day builds on what you did the days before. |
Another resource is the `help` command built into Mini Micro. Just type `help` at the prompt and it will print some introductory help, with a prompt to get to more by using `help "topics"`. That leads you to things like `help "files"` or `help "graphics"`. The help you find this way is brief, but may be a good enoug... |
{i:"Mini Micro, Cheat Sheet;documentation, Mini Micro Cheat Sheet"} |
Next, keep in mind the Mini Micro Cheat Sheet, a very short (currently 4-page) expansion of the MiniScript Quick Reference you used in the first half of the book. The additional pages cover almost everything there is to know about Mini Micro: all the built-in classes and functions. They are organized by topic, so you... |
{width:"95%"} |
 |
When you need more detail than the built-in help or the cheat sheet can provide, a good place to turn is the MiniScript Wiki. This is a community-edited reference for everything having to do with MiniScript and Mini Micro. You can find it via the MiniScript home page, or go to it directly at `https://miniscript.org/w... |
Finally, of course, you are encouraged to join the MiniScript community. There is an active Discord server as well as web forums, and users there — including me — will be happy as a clam to help you with your MiniScript and Mini Micro questions. It's also a great place to show off what you have created! |
{pageBreak} |
## Language vs. Environment |
I'd like to close this first chapter about Mini Micro with a reminder about the difference between a programming *language* and a programming *environment*. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.