Can an Object automatically check for multiple values?

  • #1, by jackieTuesday, 12. January 2021, 08:35 3 years ago
    Is there any way to make an object within a scene automatically check for multiple states of a value? For instance, in the "conditions" section on the properties tab there is an option for the object to check for a condition or value in order to become active. I need this object to automatically check for something like

    if (value)  >=100 and <= 200

    I'm new to Visionaire so maybe I'm missing something obvious but the only place I've found an option for multiple numbers like that is in the actions section. Unfortunately, I don't want the player to have to perform an input in order for this check to take place. I need it to be checked as soon as the scene loads as I'll be using this as a means to change the background to different times of the day as well as toggling the presence of certain NPCs.
    Is this something I'll have to write as a script? And if so, how would I go about automatically calling that script upon loading the scene?

    Newbie

    2 Posts


  • #2, by esmeraldaTuesday, 12. January 2021, 09:52 3 years ago
    As far as I'm aware there is no possibiltiy to check multiple values without using lua.
    I guess there are multiple ways to do it. This is what I would do:

    You could use the action part "if lua result" to check if the value (or multiple values) is in the desiered range and if so change a condition (or an other value) that is connected to your object.

    Actionparts:
    If lua result  ...
     change condition "x" to true
    else
     change condition "x" to false
    end if

    "if lua result" must return a boolean (true/false)
    So in this action part you write:
    return Values["name"].Int <= 200 and Values["name"].Int >= 100

    You can call this action at the beginning of a scene. Add an action in the scenes action tab (next to waysystems tab) and choose the execution type "at the beginning of the scene"

    Edit:
    (Or you could do it all as a script and call the script at the beginning of the scene or use the execute script action part. )
    If the objects apear slightly after the scenes has loaded you might consider calling the action in the action when changing the scene. (call action "at the beginning of a scene", change scene) Of course then you could also use the execution typ "called by other action" instead of "at the beginning of the scene".

    Key Killer

    513 Posts

  • #3, by jackieWednesday, 13. January 2021, 03:13 3 years ago
    Thank you so much! This is exactly what I needed smile 

    Newbie

    2 Posts