License from €75 Log in
DE EN FR ES IT CZ

LUA : get / set scene value

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 12 years ago
    For documentation purposes. To set a scene int value "vvvv" with LUA as of Visionaire studio 4.1 :

    Values["vvvv"].Int = 100
    


    Also works :

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


    keywords : get value / set value / get scene value / set scene value
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 12 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)
    
  4. · 12 years ago
    Works too :

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

  5. · 12 years ago
    Aye, there's lots of combinations available since v4.x. smile
  6. · 12 years ago
    Also to get a scene value :
    local val = getObject("Scenes[000_Options].SceneValues[vvvv]"):getInt(VValueInt)
    


    Is there a way to get the value using Scenes["000_Options"].SceneValues["vvvv"].something ?
  7. · 12 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
    
  8. · 12 years ago
    “
    Works too :

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

    „

    hm... this don't work. I have tried to modify a character value with that method:
    Characters["char_hans"].CharacterValues["money"].ValueInt = 20
    
  9. · 12 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.
  10. · 12 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
    

    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?
  11. · 12 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)
    
  12. · 12 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.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?