Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

LUA : get / set scene value

  • #1, by nelsonc 12 years ago Zitieren
    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, by afrlme 12 years ago Zitieren
    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)
    
  • #3, by nelsonc 12 years ago Zitieren
    Works too :

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

  • #4, by afrlme 12 years ago Zitieren
    Aye, there's lots of combinations available since v4.x. smile
  • #5, by nelsonc 12 years ago Zitieren
    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 ?
  • #6, by afrlme 12 years ago Zitieren
    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
    
  • #7, by Lebostein 11 years ago Zitieren
    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
    
  • #8, by afrlme 11 years ago Zitieren
    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.
  • #9, by Lebostein 11 years ago Zitieren
    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?
  • #10, by Lebostein 11 years ago Zitieren
    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)
    
  • #11, by afrlme 11 years ago Zitieren
    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.