1 | You might have wondered what the "go", "want", "get" and "grab" functions in the API are for. Well, it's easy: They're all synonyms :) [Originally, I wanted to call the function "in", but sadly, that is a keyword in Lua.]
|
2 |
|
3 | It's just one of the most-used functions in TinyBrain: Including another snippet. You just pass the snippet ID and the snippet is loaded and expands into you current context.
|
4 |
|
5 | For example, both of these statements have the same result:
|
6 |
|
7 | get("#175")
|
8 | go(175)
|
9 |
|
10 | The former is a little better because it automatically turns the #175 into a link in the program listing. Function-wise, there's no difference.
|
11 |
|
12 | Each of these statements gives you the "tableToString" function which is defined in #175.
|
13 |
|
14 | If you want to run the included snippets in a separate sandbox, you can pass the sandbox as a second argument:
|
15 |
|
16 | env = newCleanEnv()
|
17 | get("#175", env)
|
18 | assert(env.tableToString)
|
19 |
|
20 | newCleanEnv means the included snippet does not see any of the variables or functions you define in your snippet. Safety is our first goal! :-) |