Ever wanted the power to change traffic lights to red when you want to cross the road? Well now you can! Well, in the MineCraft world at least..
The aim of this challenge is for you to build a working traffic light on a pole. You should program the lights to turn from green through to red, and then back again, with appropriate time delays in between.
- Build a second traffic light and program it to change at the same time as the first light.
- Build a road in between the traffic lights.
- Program the traffic lights to turn to red when your player stands next to the lights.
- Add a car that moves along the road and stops when the lights are on red….
Step1. Create an empty space for your traffic light
First clear a nice big flat area for your lights, so use the setBlocks function with AIR to create a big open space.
Step2. Create your traffic light
Now create a traffic light pole made out of 5 blocks of wool, in the middle of the flat area.
Step3. Create procedures to turn set the lights on/off
First create a function to turn your lights on/off.
Now write the rest of the procedures for the other lights?
Can you think of a way of using parameters to improve your code by combining all the above functions in to one function?
Step4. Create procedures to create the light transitions.
Now create some more procedures to do the light transitions.
|def lightsGo(): # Turns the lights to go.
Wait 2 seconds
Step 5. set up a loop to automate your lights
Wait 5 seconds
Wait 5 seconds