DE EN FR ES IT CZ
Back Back to top

Set character to new scene (Lua)

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

  • #1, by darren-beckett 11 years ago Quote
    I'm trying to make a character change scene in Lua, but this doesn't seem to work?
    getObject("Characters[Receptionist].CharacterScene"):setValue(VCharacterScene, game:getLink("Game.GameCurrentCharacter.CharacterScene"))
  • New to Visionaire Studio?

    Create point and click adventures without coding. The free version covers up to 25 scenes per project. For more scenes or to earn money with your game, you need a license.

    See the Indie Bundle Try it for free
  • #2, by SimonS 11 years ago Quote
    Try:
    Characters["Receptionist"].Scene = game.CurrentCharacter.Scene
    
  • #3, by afrlme 11 years ago Quote
    Thing was that you didn't need to declare .CharacterScene in the getObject function as the setValue function would have taken care of that.

    Simon's shorthand method is definitely the way to go. wink
  • #4, by darren-beckett 11 years ago Quote
    This works:
    mChar = getObject("Characters[Receptionist]")
    mChar.CharacterScene = game.GameCurrentCharacter.CharacterScene

    Thanks
  • #5, by afrlme 11 years ago Quote
    Question: why did create variables? It seems like unnecessary work to me.

    Simon' one line would have worked. Speaking of faster workflow methods, you could actually create a Lua function to reduce the amount of characters / code / lines you need to type.


    function...
    function char2scn(c, s)
     -- + fallback + --
     if c == nil then c = game.CurrentCharacter:getName() end
     if s == nil then s = game.CurrentScene:getName() end
     -- + set character to scene + --
     Characters[c].Scene = Scenes[s]
    end
    

    usage...
    char2scn("Tom", "Kitchen") -- set character Tom to Kitchen scene
    ...
    char2scn(nil, "Kitchen") -- set active character to Kitchen scene
    ...
    char2scn("Tom") -- set character Tom to currently displayed scene
    

    ... I think you get the idea. smile
  • #6, by darren-beckett 11 years ago Quote
    Android cannot access the Characters[] table directly.
  • #7, by afrlme 11 years ago Quote
    Oh. Didn't know that. I would have thought that both the getObject & shorthand Lua access / update methods would be compatible across all the available platforms. Well, you could replace the Characters bit in the function I wrote with the getObject method instead.

    Are there any other shorthand tables that you've come across that can't be accessed directly on Android either?
  • #8, by darren-beckett 11 years ago Quote
    These do not work: ActiveAnimations[], Values[], Interfaces[], Characters[]

    Note: I believe it may be all of them.
  • #9, by afrlme 11 years ago Quote
    Ah... I guess it doesn't like shorthand in general. Strange, very strange.