[Tip] Hazard in timing of responses and triggers
I got caught out yesterday and today, helping Alisa do her password screens, by the fact that responses to triggers all happen simultaneously (well, unless delayed, but conditions cannot be delayed). I wrote responses to a receive trigger that I naturally interpreted in the order they were written on the page, but Protopie jumps at all of them together.
The solution I discovered is to make them into separate triggers.
My first attempt had the responses to a ‘Receive’ trigger as ‘assign’ and then ‘Condition’ based on the variable assigned.
The correct way is to do the ‘Assign’ in response to the ‘Receive’ and then do a ‘detect’ on the variable, as this forces the timing to be what I want.
The effects of these two methods can be seen in this pie (https://cloud.protopie.io/p/fdaee2940342c8d9ffef78fa?ui=true&scaleToFit=true&enableHotspotHints=true&cursorType=touch&mockup=true&bgColor=%23F5F5F5&playSpeed=1) – the left input field uses my first approach, and the right input field uses the second. Only the right input field behaves as you would expect.
Hopefully this description of the problem, which isn’t a bug, will help others avoid this hazard. – “Don’t use conditions on variables that you have assigned a new value to in the same trigger.”