## The 3 types of Block (Event Block, Branching Block, Standard Block)
## The 3 types of Block (Event Block, Branching Block, Standard Block)
@ -128,15 +88,13 @@ To move / rearrange Blocks in the Flowchart window do the following:
Fungus Flowcharts visually differentiate three differents kinds of Block behavior:
Fungus Flowcharts visually differentiate three differents kinds of Block behavior:
1. Event Block - blue rounded rectangle (Block execution triggered by an event)
1. Event Block - blue rounded rectangle (Block execution triggered by an event)
2. Branching Block - orange polygon (passes control to 2 or more other Blocks, and not and Event Block)
1. Branching Block - orange polygon (passes control to 2 or more other Blocks, and not and Event Block)
3. Standard Block - yellow rectangle (no event, passes control to 0 or 1 other blocks)
1. Standard Block - yellow rectangle (no event, passes control to 0 or 1 other blocks)
### 1: Event Block - blue rounded rectangle
### 1: Event Block - blue rounded rectangle
One way Fungus decides when to start executing the Commands inside a Block is if a Block has defined an Execute On Event. If a Block has any of the possible Execute On Events chosen (such as Game Started, Message Received, Sprite Drag Completed, Key Pressed etc.) then this Block will be displayed as a **blue rounded rectangle**:
One way Fungus decides when to start executing the Commands inside a Block is if a Block has defined an Execute On Event. If a Block has any of the possible Execute On Events chosen (such as Game Started, Message Received, Sprite Drag Completed, Key Pressed etc.) then this Block will be displayed as a **blue rounded rectangle**:
As we can see, the default Block created with every new Flowchart automatically defines the Game Started Execute On Event, so this default Block always is displayed as an Event Block.
As we can see, the default Block created with every new Flowchart automatically defines the Game Started Execute On Event, so this default Block always is displayed as an Event Block.
@ -145,12 +103,12 @@ NOTE: A Block with an Execute On Event will always appear as an Event Block in t
### 2: Branching Block - orange polygon
### 2: Branching Block - orange polygon
If a Block is *not* an Event Block, and its Commands include Calls and/or Menu commands to execute Commands in 2 or more other Blocks, then in the Flowchart window this Block will be displayed as a Branching Block, visually appearing as an **orange polygon**.
If a Block is *not* an Event Block, and its Commands include Calls and/or Menu commands to execute Commands in 2 or more other Blocks, then in the Flowchart window this Block will be displayed as a Branching Block, visually appearing as an **orange polygon**.
@ -158,8 +116,7 @@ If a Block is *neither* an Event Block *nor* a Command Block, then it is a Stand
A whole scene's logic can rarely fit all into a single Block, therefore we need ways for one Block to pass execution control to other Blocks. There are several ways to do this, the most common being:
A whole scene's logic can rarely fit all into a single Block, therefore we need ways for one Block to pass execution control to other Blocks. There are several ways to do this, the most common being:
6. Add to Block "Block2" a Call Command, by choosing menu: ```Flow | Call```:
<br>
![flow call]
7. With this Call Command Selected, in the Inspector choose Block2 from the list of Blocks for property **Target Block**:
1. Add a new Block to your Flowchart named "Block2".
![call block menu]
8. Note: We will keep the default of **Target Flowchart** (None), which means the current Flowchart.
1. Add to Block "Block2" a Say Command with the Story Text "I am in Block2".
9. Note: We will keep the default of **Call Mode** Stop, which means that execution in the current Block (Start) will stop once execution of the called Block has begun.
<br>
10. You should now see an arrow in the Flowchart window, connecting Block "Start" with Block "Block2". This visually tells us (the game developer) that a Call or Menu Command is present inside Block "Start" that tells Fungus to execute commands in Block "Block2":
1. Note: We will keep the default of **Target Flowchart** (None), which means the current Flowchart.
1. Note: We will keep the default of **Call Mode** Stop, which means that execution in the current Block (Start) will stop once execution of the called Block has begun.
1. You should now see an arrow in the Flowchart window, connecting Block "Start" with Block "Block2". This visually tells us (the game developer) that a Call or Menu Command is present inside Block "Start" that tells Fungus to execute commands in Block "Block2":
<br>
![arrow between blocks](./images/002_call_other_blocks/5_arrow.png "arrow between blocks")
<br>
<br>
<!--**************************************** -->
<!--**************************************** -->
## Executing Commands in another Block with Menu Commands
## Executing Commands in another Block with Menu Commands
@ -214,78 +148,37 @@ Let's use a Say command above to ask a tricky mathematical question, and demonst
Do the following:
Do the following:
1. (setup) Create a new scene, add a Fungus Flowchart to the scene, and select the Block in the Flowchart.
1. (setup) Create a new scene, add a Fungus Flowchart to the scene, and select the Block in the Flowchart.
2. Rename the Block in the Flowchart to "Question".
1. Rename the Block in the Flowchart to "Question".
3. Create a Say command, with **Story Text** to ask the question: "Is 2 + 2?".
4. Uncheck the "Wait For Click" checkbox (this is so we see the menu options immediately after the Say command has displayed the question):
1. Create a Say command, with **Story Text** to ask the question: "Is 2 + 2?".
![maths say command]
5. Create a new Block, named "Correct" which contains a **Say** command with the text "Well done, you are very mathematical!". Click the plus-sign button in the Flowchart window to add a new Block to the Flowchart, rename it "Correct" and then add that Say command:
2. Uncheck the "Wait For Click" checkbox (this is so we see the menu options immediately after the Say command has displayed the question):
![correct block]
<br>
6. Select the "Question" block, and add a Menu command by clicking the plus-sign add Command button in the Inspector and then choosing menu: ```Narrative | Menu```.
![maths say command](./images/004_menu_maths/2_edited_say.png "maths say command")
![add menu command]
<br>
7. With this new Menu command selected (green) in the top half of the Inspector window, set the **Text** to "Yes" and the **Target Block** to your new "Correct" block:
<br>
![menu command]
8. You should now see how the 'flow' of commands can change from Block "hello" to Block "Correct" in the Flowchart window:
3. Create a new Block, named "Correct" which contains a **Say** command with the text "Well done, you are very mathematical!". Click the plus-sign button in the Flowchart window to add a new Block to the Flowchart, rename it "Correct" and then add that Say command:
![flow between blocks in Flowchart]
<br>
9. Add a second new Block named "Wrong", containing a Say command with text "Bad luck, perhaps consider a non-mathematical career path..."
10. Now we need to add another Menu command to our "hello" block, offering the user the "No" answer to our maths question, and passing control to Block "Wrong" if they disagree that 2 + 2 = 4. Select the "hello" block, and add a Menu command. With this new Menu command selected (green) in the top half of the Inspector window, set the **Text** to "No" and the **Target Block** to your new "Wrong" block.
<br>
11. You should now see in the Flowchart window how block "hello" can pass control to either block "Correct" or Block "Wrong" - depending on which menu answer the user selects.
![block connected to 2 others]
4. Select the "Question" block, and add a Menu command by clicking the plus-sign add Command button in the Inspector and then choosing menu: ```Narrative | Menu```.
12. Run the scene, and you should see the Say question appear at the bottom of the screen, and also the two Menu buttons "Yes" and "No" in the middle of the screen. Clicking "Yes" then runs the "Correct" Block's commands, and clicking "No" runs the "Wrong" block's commands:
<br>
![add menu command](./images/004_menu_maths/6_add_menu.png "add menu command")
![menu running]
<br>
<br>
![correct screen]
5. With this new Menu command selected (green) in the top half of the Inspector window, set the **Text** to "Yes" and the **Target Block** to your new "Correct" block:
6. You should now see how the 'flow' of commands can change from Block "hello" to Block "Correct" in the Flowchart window:
<br>
![flow between blocks in Flowchart](./images/004_menu_maths/5_connected_blocks.png "flow between blocks in Flowchart")
<br>
<br>
7. Add a second new Block named "Wrong", containing a Say command with text "Bad luck, perhaps consider a non-mathematical career path..."
<br>
![block for wrong answer](./images/004_menu_maths/7_wrong_block.png "block for wrong answer")
<br>
<br>
8. Now we need to add another Menu command to our "hello" block, offering the user the "No" answer to our maths question, and passing control to Block "Wrong" if they disagree that 2 + 2 = 4. Select the "hello" block, and add a Menu command. With this new Menu command selected (green) in the top half of the Inspector window, set the **Text** to "No" and the **Target Block** to your new "Wrong" block.
9. You should now see in the Flowchart window how block "hello" can pass control to either block "Correct" or Block "Wrong" - depending on which menu answer the user selects.
<br>
![block connected to 2 others](./images/004_menu_maths/8_three_block_menu.png "block connected to 2 others")
<br>
<br>
10. Run the scene, and you should see the Say question appear at the bottom of the screen, and also the two Menu buttons "Yes" and "No" in the middle of the screen. Clicking "Yes" then runs the "Correct" Block's commands, and clicking "No" runs the "Wrong" block's commands:
## Highlighting connection between blocks by selecting command
## Highlighting connection between blocks by selecting command
In the Inspector window, if you select a Call or Menu Command (executing Commands in another Block in **the same Flowchart**), then you'll see the arrow between the 2 Blocks highlighted in GREEN:
In the Inspector window, if you select a Call or Menu Command (executing Commands in another Block in **the same Flowchart**), then you'll see the arrow between the 2 Blocks highlighted in GREEN:
@ -300,12 +193,48 @@ Events are one way to declare when you want execution of the Commands in a Block
The most common Event used to define when a Block should start execution is, of course, the **Game Started** event. Each new Flowchart automatically starts with a single empty Block that is defined to begin execution when the game starts:
The most common Event used to define when a Block should start execution is, of course, the **Game Started** event. Each new Flowchart automatically starts with a single empty Block that is defined to begin execution when the game starts: