combined ("and"-)conditions are counting always as "false" in LUA

  • #1, by sebastianMonday, 29. August 2016, 00:05 4 years ago
    Hey there,

    while doing some LUA stuff this day I recognized that conditions which are "combined" are always "false". Even if the two condition parts of it are true.
    Is this right? How do i check if a combined condition is true?

    Do i really have to check both separate condition parts for itself or am I doing something wrong?

    kind regards
    Sebastian

    Thread Captain

    2337 Posts


  • #2, by afrlmeMonday, 29. August 2016, 00:40 4 years ago
    You are talking about combined conditions created inside of the Visionaire Studio editor? Actually, I've never tried querying a combined and/or condition with Lua script before. It's simple enough to query multiple instances of conditions with Lua script though, so just query the two conditions or as many conditions / values as you like with Lua script directly...
    if Conditions["x"].ConditionValue and not Condition["y"].ConditionValue then
    -- do something
    end
    1
    2
    3
    4

    if game.CurrentScene.SceneConditions["x"].ConditionValue then
    -- do something
    end
    1
    2
    3
    4

    if game.CurrentScene.SceneObjects["example"].ObjectConditions["x"].ConditionValue then
    -- do something
    end
    1
    2
    3
    4

    ... I guess you get the idea! You can create some fairly complex if queries with Lua script compromising of various different query types from boolean, to integer, to float, to "string", etc.

    Imperator

    6842 Posts

  • #3, by sebastianMonday, 29. August 2016, 00:55 4 years ago
    just looked up in the wiki. As guessed when the condition is a "combined" version, TRUE and FALSE are not valid here. It just links to the two sub parts.

    Thread Captain

    2337 Posts

  • #4, by afrlmeMonday, 29. August 2016, 01:02 4 years ago
    Aye it seems you have to query both of them...
    local var = Conditions["combined_example"]

    if var.Condition1.ConditionValue and var.Condition2.ConditionValue then
    print("true")
    else
    print("false")
    end
    1
    2
    3
    4
    5
    6
    7
    8

    Not really much point to doing that with Lua script. Same amount of work more or less as querying individual conditions.

    Imperator

    6842 Posts

  • #5, by sebastianTuesday, 30. August 2016, 08:15 4 years ago
    thanks, mate. I think this is a great addition to the workflow functions in the wiki. something like

    condition(conditionname)
    condition(objectname.conditionname)
    condition(scenename.objectname.conditionname)

    function should split up the string at each "." and build the VS correct string, then checks if the condition is combined or not.
    if not, return its state (true/false)
    if combined then get its childs and return their and/or combined value

    only problem i see here is what the syntac should look like when requesting something from interfaces, characters, etc...

    Thread Captain

    2337 Posts

  • #6, by sebastianTuesday, 30. August 2016, 08:18 4 years ago
    i guess it is suffivient to just use condition(conditionname)...

    Thread Captain

    2337 Posts

  • #7, by afrlmeTuesday, 30. August 2016, 11:37 4 years ago
    It's possible to use .name for pathing as both...
    game.CurrentScene.SceneObjects.object_name.ObjectConditions.condition_name.ConditionValue
    1
    2

    or...
    game.CurrentScene.SceneObjects["object_name"].ObjectConditions["condition_name"].ConditionValue
    1
    2

    are valid.

    Conditions on it's own can be used globally, but only be used if you are using unique names for each of your conditions, otherwise direct path linking is desired as it's the safest method.

    Anyway... I believe I already added some workflow stuff for conditions, no?

    Imperator

    6842 Posts

  • #8, by sebastianTuesday, 30. August 2016, 11:55 4 years ago
    i only found setcondition in the wiki

    yeah i know that the conditionnames should be globally unique for this to work.
    setcondition in the wiki does the same^^

    Thread Captain

    2337 Posts

  • #9, by afrlmeTuesday, 30. August 2016, 12:05 4 years ago
    I think I wrote that workflow function back before we had shorthand, as it was supposed to just get rid of having to type out the full getObject() method...
    getObject("Conditions[condition_name]"):getBool(VConditionValue) -- I think it was... been so long since I used getObject method, I can't really remember.
    1
    2

    The only thing your workflow functions would save on is having to type .ConditionValue at the end, so not much point really.

    Imperator

    6842 Posts

  • #10, by sebastianTuesday, 30. August 2016, 18:02 4 years ago
    ah ok. wasnt sure about the short hand method. =)

    Thread Captain

    2337 Posts

Write post