Today in Programming: MakeCode and Python

Python

A user of my Extra Life Donation Tracker program discovered that I had introduced a regression for brand new users who didn’t have a persistent setting. I thought about it overnight and it was exactly what I thought it would be – when I switched away from threading for the GUI, I forgot to add a way to tell participant.py to reload its settings values. I also decided to take a page from a programming podcast I heard recently and change the settings GUI to only have a “Save” button instead of a persistent save button AND a Save button. Especially when I wanted most people to hit persistent save, and that’s not what they’d most likely do by default. So I ended up making 5.2 release to fix both of those issues.

MakeCode

For the past week I’ve been wracking my brain trying to figure out how to get Scarlett’s Sibling chooser to actually be random in its selections. Turns out that it was very predictably random because of the fact that, unlike a real computer, it doesn’t have a way to create a true random seed. (On Linux computers a few years ago it was an explicit step you’d see as part of the install) If I were coding in Arduino or Python, I’d be able to create a seed for the program via reading the light sensor. But that’s not possible in MakeCode. SO I came up with another way to introduce randomness. I have the random function running in a forever loop. Since that’s going to be running “infinitely” fast, it’s very unlikely that the user is going to be able to always hit the same sequence and it’ll be random enough. In my testing it was very random-seeming, so that works out well. Here’s the new code:

Sibling Chooser Code as Microsoft MakeCode blocks
Sibling Chooser Code as Microsoft MakeCode blocks

Published by Eric Mesa

To find out a little more about me, see About Me