When I create a cloud variable and Thunkable live is open, I can’t get it to initialize correctly. If I add the same cloud variable and code with Thunkable Live closed, then open Thunkable Live, it works.
Here is a more detailed description with sample app and video
Hmm…ok, we’ll fix that.
An explanation of what’s happening:
In the video thunkBug1.mp4, the problem occurs at 1 minute 32 seconds into the video. Since Thunkable Live is open, it runs the code every time the blocks update. When the code runs with what you see at 1:32, the cloud variable’s value is set to 0 (the default when nothing is attached). Then, when you put the blocks into it, since your variable is defined as 0, the code doesn’t run since the variable isn’t defined as null.
Temporary fixes you can do
- Construct the set block before putting it in the event
- Check for null or 0 in the conditional
Our long term fix
We should have the block not run when nothing is attached instead of setting the value to 0.
Great and thanks Paul, very interesting!
One additional piece of info-- I was doing a Technovation live demo of this previously and got the error. Unlike the video I sent you, I constructed the init blocks outside of the event handler (gray) before putting them in the event handler. So temporary fix #1 may not work-- maybe blocks outside of the event do get executed? The demo is at https://www.youtube.com/watch?v=zisCStLeL8Q and the error starts about 27:05
Hope you’re enjoying it here–its better if you can go outside of course
Two more thoughts:
-
Inserting into variables that haven’t been initialized as lists is one of the most common errors students get. I wonder if it would be better to allow the operation and convert the variable into a list automatically
-
The lack of Run-time error reporting is frustrating
-
Once you connect app to Firebase you can view cloud data while debugging. But prior to that, and for most beginners exploring cloud variables, there isn’t a view of the default db. That view would be huge for debugging.