self.get_active_mode_id() produces a string, not an integer

108 viewsCSS BugsActive Mode Bug


I was trying to setup an Action Block with a Condition that checks the Active Mode number, and ran in some trouble. The condition asks for an integer, and when you log the Active Mode number it is in fact a number but it turns out that self.get_active_mode_id() produces a string of the number as output. So when filling in the integer in the Condition, the Condition won’t work because an integer is compared to the string from self.get_active_mode_id().

To make it work at the moment, it’s necessary to turn the filled in integer into a string.

JohnC Answered question July 8, 2024

Hmm yes you are correct.
I checked in the code and mode numbers are being stored as numbers in strings.
Here’s how they are stored in the ‘modes’ dictionary.

self.modes = {}
self.modes[0] = "1"
self.modes[1] = "7"

The values themselves are internal to the script and probably won’t really make sense from your point of view (but you can use them as in your screenshot).

Another way which might make more sense would be to call the dictionary ‘key’ as they count up from xero.
i.e. the first mode in your script will be self.modes[0], mode 2 will be self.modes[1] and so on.

To call the mode number via the key, you could enter the following code (this would be mode 2):


As it’s expecting a number, you will also need to change the field to ‘Custom’ so that you can enter the code.

Glenn Verhaeghe Posted new comment July 8, 2024

Cool to know! This seems more convenient, e.g. when sharing scripts.