LUA : get / set scene value

  • #1, by nelsoncSunday, 01. February 2015, 04:43 6 years ago
    For documentation purposes. To set a scene int value "vvvv" with LUA as of Visionaire studio 4.1 :

    Values["vvvv"].Int = 100
    1
    2


    Also works :

    getObject("Values[vvvv]"):setValue(VValueInt, 100)
    1
    2


    keywords : get value / set value / get scene value / set scene value

    Newbie

    43 Posts


  • #2, by afrlmeSunday, 01. February 2015, 13:45 6 years ago
    Um yes I know. wink

    I would however like to point out that both of the examples you provided are global access, which is not as secure as direct access, because you need to be careful to use unique names for everything.

    Here's a quick example of direct access...
    getObject("Scenes[bedroom].SceneValues[vvvv]"):setValue(VValueInt, 100)
    1
    2

    Imperator

    6841 Posts

  • #3, by nelsoncSunday, 01. February 2015, 17:04 6 years ago
    Works too :

    Scenes["000_Options"].SceneValues["vvvv"].Int = 25
    1
    2

    Newbie

    43 Posts

  • #4, by afrlmeSunday, 01. February 2015, 17:10 6 years ago
    Aye, there's lots of combinations available since v4.x. smile

    Imperator

    6841 Posts

  • #5, by nelsoncSunday, 01. February 2015, 17:42 6 years ago
    Also to get a scene value :
    local val = getObject("Scenes[000_Options].SceneValues[vvvv]"):getInt(VValueInt)
    1
    2


    Is there a way to get the value using Scenes["000_Options"].SceneValues["vvvv"].something ?

    Newbie

    43 Posts

  • #6, by afrlmeSunday, 01. February 2015, 17:53 6 years ago
    The new shorthand code automatically detects if it's read or write.

    print( Values["value_name"].Int ) -- print value to log

    if Values["value_name"].Int == 10 then
    -- do something
    end

    local x = Values["value_name"].Int
    1
    2
    3
    4
    5
    6
    7
    8

    Imperator

    6841 Posts

  • #7, by LebosteinTuesday, 17. February 2015, 23:07 6 years ago
    Works too :

    Scenes["000_Options"].SceneValues["vvvv"].Int = 25
    1
    2


    hm... this don't work. I have tried to modify a character value with that method:
    Characters["char_hans"].CharacterValues["money"].ValueInt = 20
    1
    2

    Key Killer

    601 Posts

  • #8, by afrlmeTuesday, 17. February 2015, 23:20 6 years ago
    it's .Int not .ValueInt wink

    VValueInt is for the getObject method. The shorthand method requires a bit of trial & error to find out which is the correct way to access or write a value.

    Imperator

    6841 Posts

  • #9, by LebosteinWednesday, 18. February 2015, 08:14 6 years ago
    With .Int it don't work too. I have tried to modify two variables:
    Characters["char_hans"].CharacterValues["money"].Int = 20
    Scenes["room_title"].SceneValues["score"].Int = 20
    1
    2
    3

    This script is called if I press [D] on my keyboard.

    PS: Have a look in the data structure tables (value section). Here you can find .ValueInt and .ValueString as parameters of CharacterValues or SceneValues. Why the shorthand method not follow the official structure?

    Key Killer

    601 Posts

  • #10, by LebosteinWednesday, 18. February 2015, 09:13 6 years ago
    The direct method with values seems buggy
    -- works:
    local char = getObject("Characters[char_hans]")
    char:setValue(VCharacterPosition, {x=100,y=300})

    -- works (same above with direct method):
    local char = Characters["char_hans"]
    char:setValue(VCharacterPosition, {x=100,y=300})

    -- works:
    local money = getObject("Characters[char_hans].CharacterValues[money]")
    money:setValue(VValueInt, 20)

    -- don't work (same above with direct method):
    local money = Characters["char_hans"].CharacterValues["money"]
    money:setValue(VValueInt, 20)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    Key Killer

    601 Posts

  • #11, by afrlmeWednesday, 18. February 2015, 11:27 6 years ago
    Some of the stuff is still not accessible with shorthand. It's early days, but it's working a lot better now than the first time Simon tried implementing it.

    It would be impossible & unrealistic for me to even attempt providing documentation for all the different getobject, direct path & shorthand methods of accessing the / writing to the data structure fields & tables.

    Imperator

    6841 Posts

Write post