Ranger and Ultimate 2 Code Limt


#1

I am curious about how many lines code can work regulary ranger and ultimate 2.0?


#2

Using mBlock blocks coding, you can create some very big files (good enough for most purposes). Its not the number of lines that is a limit though - its what those lines are doing.

I did once generate an mBlock 5 ‘white screen of death’ and crashing this usually very stable piece of software is almost unheard of - but can be caused it seems by having too many ‘project assets’.

image

In my case, this was too many graphics. In the creation of a ‘stage’ feedback screen (see below) for the Me Gyro I needed to make 360 costumes for the Z axis (the directional heading) of the gyro and that is a lot of costumes to duplicate and edit - so many (and such a tedious a task to do) that I had to do them in batches over quite a few days.

image

Once I had duplicated 200-or-so entries, the Costume Editor became noticeably sluggish. By the time that I passed 350 costumes, my first software crash happened; and whilst I could restart and run mBlock with my project functioning normally, as soon as I entered the Costume Editor screen it crashed again.

Whilst trying to find my way around this problem, as a test I found that I could make a new sprite in the same project and duplicate costumes quite happily; but the many costumed Gyro sprite always crashed on opening it in the Editor!

I removed (by exporting it) my ‘Gyro_Z ‘ sprite from my project and reloaded the resultant .sprite3 file (270Kb in size) into a new project with no other assets present and then the resultant .mblock file became approx. 430Kb in size. It should be mentioned here that my sprite also contained the matching decision-making (if/then) block scripts needed to interpret module feedback into costume output. Sadly, this new project file also crashed mBlock as soon as I opened the Costume Editor - so what was I to do? …

image

… As a last resort, I tried opening this new single sprite project in the online mBlock Web version of the software (I always use the Desktop PC version).

Amazingly the Costume Editor ran much more smoothly and it was now possible to create more costumes, and these were quicker to implement by copying rather than duplicating) and I could now complete my total of 360 costumes with ease; including their accompanying block scripts - which for ease of visibility (and duplication) I broke into vertical runs of 22 if/then decisions under 16 ‘My Blocks’ headings (see part of the first three of these above).

I loaded (imported) my newly completed ‘Gyro_Z ‘ sprite back into my original project where it worked perfectly giving me 0º to 360º Headings for the Gyro feedback screen. All that I had to do now was NOT open this sprite in the Costume Editor.

So, don’t worry about lines of code - just beware creating memory hungry ‘project assets’.


#3

@ozgetasmanisa @CommandeR is 100% correct. :slight_smile: Of course, there is a limit to the board memory for the mBot Ranger and mBot Ultimate, but it’s really high. You shouldn’t have to worry about it.
I can try to find the exact numbers if you’d like me to.