-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1728fee
commit 19a8cee
Showing
7 changed files
with
112 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
Tutorial 01: Shell and Spy | ||
========================= | ||
|
||
This tutorial explain how to create your first JS script to configure BotJs. It describes 2 of the most usefull block of BotJs Shell and Spy. | ||
|
||
## The Shell | ||
|
||
At this point you have build and install BotJs in your environment. You have test it by simply executing BotJs. | ||
|
||
```bash | ||
botjs | ||
``` | ||
|
||
In your shell BotJs prompt has appeared. | ||
|
||
```bash | ||
TODO | ||
botjs> | ||
``` | ||
|
||
_Ok but why is there a BotJs prompt shell? I thought that BotJs was empty at start._ | ||
|
||
Yes it is true, BotJs is empty at start up. But when BotJs is executed without arguments, it loads its own configuration script. This simple script is provided below. It just starts the shell to allow user to configure the application. | ||
|
||
```js | ||
core.create("shell", "shell"); | ||
shell.start(); | ||
``` | ||
|
||
Every loadable module in BotJs is called a Block. Core is the first loaded block, it contains every other blocks of the application. Blocks can create other blocks with create function. The first argument of this function is the typename of the block and the second the name of the block (the name of its variable). | ||
|
||
```js | ||
// Create 3 shell block with 3 different names | ||
|
||
core.create("shell", "shell"); | ||
|
||
core.create("shell", "variableShell"); | ||
|
||
core.create("shell", "FOO"); | ||
``` | ||
|
||
When core create a block, this block is directly accessible through javascript. | ||
|
||
```js | ||
// Start the shell prompt | ||
shell.start(); | ||
``` | ||
|
||
But the block is also a sub block of core block. Therefore it is accessible with block function. | ||
|
||
```js | ||
// Start the shell prompt | ||
core.block('shell').start(); | ||
``` | ||
|
||
## The Spy | ||
|
||
To monitor your block architecture you can type javascript command through the shell and ask one by one information. Or use a Spy Block and get real time information ! | ||
|
||
A Spy can be created like any other block. | ||
|
||
```js | ||
// Create a spy | ||
core.create("spy", "agent007"); | ||
``` | ||
|
||
One Spy can spy one block at time. To spy a block use connect function. | ||
|
||
```js | ||
// Spy core block | ||
agent007.connect(core); | ||
``` | ||
|
||
Then to display the spy: | ||
|
||
```js | ||
// Spy core block | ||
agent007.show(); | ||
// or | ||
agent007.visible = true; | ||
``` | ||
|
||
## Log System | ||
|
||
Every block can log its activities on a file and/or in a the shell. | ||
|
||
```js | ||
// agent007 will log in its log file | ||
// In linux: $HOME/opt/botjs/log/agent007 | ||
agent007.logEnable = true; | ||
// agent007 will log in its log file and will print in cout | ||
agent007.logTalking = true; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Create the shell | ||
core.create("shell", "shell"); | ||
|
||
// Create spies | ||
core.create("spy", "agent007"); | ||
core.create("spy", "agent008"); | ||
|
||
agent007.logTalking = true | ||
|
||
// Connect spies to robot | ||
agent007.connect(agent008); | ||
agent008.connect(core); | ||
|
||
// Display spies | ||
agent007.show(); | ||
|
||
// Start shell | ||
shell.start(); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.