My student is making an escape/puzzle game. We created a variable to act as a “counter” so when the third “E” was clicked the clue was revealed. It will not recognize the collection of the items. The code shows it processing but the system isn’t recognizing when we get the required number. Any thoughts?
use the block “change “variable” by 1” instead of “add…”, then you have to control forever the value of the variable so you have to use the forever block.
Please see the code below:
hope this helps.
If you think that is the solution please mark this reply as solution.
@Giuseppe_Schiuma is quite right about using the change variable CoBlock, as the add CoBlock is actually add Item to List.
A list is a variable which can hold multiple values for a single name, each accessible individually. The change variable CoBlock increases or decreases a variable’s numerical value (if it has one).
The only thing which is redundant in Giuseppe’s code is the run_parallel block - it’s unnecessary, as the events get set up so fast, and are constantly listening for the event to occur.
However, your student might want to have a further think about the logic of the code, and if this reflects what they wish to happen.
For example, at the moment, I could press any E three times to activate the hedgehog. They may like to use the remove when item is clicked from Item block inside the event itself to prevent further clicks on that Item.
An alternative to having code constantly running like this is to put your code into a function and call it from within the event blocks, like this:
This wouldn’t work so well if you want to remove the event after it’s clicked, but just food for thought.
Hope this helps! Let me know if you have any further questions about this.
Geoff @ TechLeap
This is great. Thank you. We had used the “change” block initially but still didn’t get results but I see now it was checking back to get the resulting clicks/numbers.