This is indeed jolly hard stuff for an old brain to absorb and to master - it’s a bit like wading through treacle!
I am about twentyfive pages into what, I hope, will be a reassuring and simple explanation of what mBlock’s ‘Extension Builder’ actually does and the best way to start using it successfully. After much cross-referencing of all of the help files, being totally misguided by some of the information available here on the Forum and trying the provided, but mostly unhelpful extension examples; together with a lot of experiments (with many aborted attempts & frequently frustrating failures) ; I have eventually come up with my own method of creating a set of working blocks that amazingly DO work.
As you can see from the image below, I have three blocks that do run the code that I have specified in the declare: editor and then activated by running my run-once-only coding sequence of named procedures in the setup: editor of the Upload transcode tab for each block.
As stand-alone blocks, they each run perfectly when downloaded into mBlock’s ‘Extension Centre’ and then uploaded into an mBot 1.0 robot as shown in the next image. I have not incidentally, added or tweaked any other code anywhere else on any other of the software’s many tabs and their sub-settings (other than specifying Arduino C as the transcoding language).
The next two images show a little more detail of the transcode from the two blocks shown above:
Together, these two blocks (uploaded in ‘Upload’ mode and starting with the ‘when mBot (mcore) starts up’ hat block) add their codes together and transcode correctly causing the robot to sound it’s buzzer, flash its LEDs and turn left, right and back to the position it started from.
BUT - If the two blocks that define the buzzer and LEDs are used together (or with other similar block types from the blocks palette list) then the code that they generate duplicates the definition of any connected Me modules & Me device components that have been already specified in the transcode, and these double-entries of common code that cause the code to crash and not upload correctly. Why, and how can I fix this?
The two blocks shown above do work together - but only because they have no definition conflicts. Could anyone who knows about these things kindly explain what bit of extra coding I need to add (& where) to prevent such duplication when similar block types, as described above, are joined into one programme.
A second problem zone occurs here too. If I add a third block, let’s say my ‘Wiggle Waggle’ block and set it above the first two blocks in my demonstration, then whilst it doesn’t have any coding conflicts with the other blocks the lowest ‘Wiggle Waggle’ block seems to be ignored and does not add a further three ‘twisting’ lines of code (one set at the top and one set at the bottom) of the setup section of the resultant transcode. Any ideas regarding both of these problems would be gratefully received.
Apart from these small glitches, that’s one small step for mankind completed; and any further help or support in my endeavours on this front would be most welcome.