charliefoxtwo / ViLA

Virpil LED Automator - a tool for programmatically changing the LEDs on your Virpil USB device.
GNU General Public License v3.0
39 stars 10 forks source link

How to use 'And', 'Or', etc. in config files ? #12

Closed k0pfweh closed 2 years ago

k0pfweh commented 2 years ago

I've done a quick and dirty approach on writing an Elite: Dangerous Plugin. Im trying to set a led to a different color if two values are true.

Example:

ELITE_LDG_DWN (Landing Gear Down): led is blue (working) ELITE_LDG_DWN and (ELITE_DOCKED or ELITE_LANDED) led is green

I can't figure out the correct syntax for the second one.

charliefoxtwo commented 2 years ago

Awesome! Sorry it's taken me so long to respond.

One thing to keep in mind is that the first rule will always be true. ViLA will run any rules which are true, when means that even if the second is correct it could then be overwritten by the first.

Your first rule should probably be ELITE_LDG_DWN and NOT(ELITE_DOCKED or ELITE_LANDED)

Here's a sample AND configuration I had written up in discord. These can be nested as deep as you like.

{
    "color": "ff0000",
    "trigger": {
        "value": [
            {
                "id": "c",
                "value": 1,
                "comparator": "EqualTo"
            },
            {
                "id": "d",
                "value": 1,
                "comparator": "EqualTo"
            }
        ],
        "comparator": "And"
    }
},
k0pfweh commented 2 years ago

Thanks 👍 I'll give it a try later this week :)