Input from sensor and user
Passing a parameter to the program using the console and on chat command
An on chat command in a MakeCode program open in code connection can be activated by entering its name in the Minecraft console. Parameters for the on chat command can be passed by leaving a space and putting the parameter value.
For example:
The on chat command: On chat command <command> <variable>
The console: <command> space <value>
TASK
Try making a MakeCode program that does what the pseudocode asks.
Passing a parameter to the program using the console and on chat command
An on chat command in a MakeCode program open in code connection can be activated by entering its name in the Minecraft console. Parameters for the on chat command can be passed by leaving a space and putting the parameter value.
For example:
The on chat command: On chat command <command> <variable>
The console: <command> space <value>
TASK
Try making a MakeCode program that does what the pseudocode asks.
Sensors
Using MakeCode in Minecraft allows programs to sense the environment. An example of this could be detecting something in front of the agent.
Some examples of sensor blocks are:
Using MakeCode in Minecraft allows programs to sense the environment. An example of this could be detecting something in front of the agent.
Some examples of sensor blocks are:

These sensors allow the agent to gain knowledge of the environment. They can be effectively used to add a degree of intelligence to the program. For example when an agent detects a wall it seems to know when the wall ends and then stops and moves over it and down the other side.
TASK
Complete the task which uses a sensor to help the agent detect a block in front of it. The program uses a variable to hold a value of the height of the wall so it can descend the same number of blocks it climbed.
TASK
Complete the task which uses a sensor to help the agent detect a block in front of it. The program uses a variable to hold a value of the height of the wall so it can descend the same number of blocks it climbed.
Functions
These are smallish chunks of code that do one specific task. They can be called by their name (In MakeCode they cannot use parameters). They are called from the main program (usually after an on chat command). These functions help the organisation of the program in small easy to understand units.
TASKS
1. Find out about functions in MakeCode, go to this URL: https://minecraft.makecode.com/types/function
2. Try to make the Leap of faith mini game using functions: https://minecraft.makecode.com/courses/csintro/functions/activity-1
These are smallish chunks of code that do one specific task. They can be called by their name (In MakeCode they cannot use parameters). They are called from the main program (usually after an on chat command). These functions help the organisation of the program in small easy to understand units.
TASKS
1. Find out about functions in MakeCode, go to this URL: https://minecraft.makecode.com/types/function
2. Try to make the Leap of faith mini game using functions: https://minecraft.makecode.com/courses/csintro/functions/activity-1
Comments
These are added to the code to explain what the code does and how it does it. These comments are added for the programmer and other people that need to understand the code.
For achieved: documenting the program with comments
For merit: documenting the program with variable names and comments that describe code function and behaviour
In the agent climbs the wall program there is no comment to explain what the item variable is used for. Also the variable name item is not descriptive of its use so it could be renamed to 'height'. In the example below the before pseudocode is at achieved level and the after pseudocode is at merit level.
These are added to the code to explain what the code does and how it does it. These comments are added for the programmer and other people that need to understand the code.
For achieved: documenting the program with comments
For merit: documenting the program with variable names and comments that describe code function and behaviour
In the agent climbs the wall program there is no comment to explain what the item variable is used for. Also the variable name item is not descriptive of its use so it could be renamed to 'height'. In the example below the before pseudocode is at achieved level and the after pseudocode is at merit level.
To add a comment
TASK
Open the Agent Climbs the Wall program. Add comments to Achieved or Merit level, as explained.
Open the Agent Climbs the Wall program. Add comments to Achieved or Merit level, as explained.