Accessing character object via lua dynmically

  • #1, by sebastianSunday, 16. August 2015, 22:59 9 years ago
    how do i can get character data via a lua function but defining the char inside the function?

    What works (static):

    function get_char()
      local char = getObject("Characters[name_of_character]")
     ...
    end
    

    gets Object of "name_of_character"
    ---------------------------
    What doesn't work:
    function get_char(char)
      local char = getObject("Characters["..char.."]")
     ...
    end
    


    am i doing something wrong here? How can i do this dynamically?

    Thread Captain

    2346 Posts


  • #2, by ke4Monday, 17. August 2015, 15:23 9 years ago
    Hm weird, looks correct...
    I've just pasted it in Visionaire and it works fine for me.

    Do you have anything else in the function?

    Key Killer

    810 Posts

  • #3, by sebastianMonday, 17. August 2015, 18:15 9 years ago
    i will post the rest of the funcion after i come home from work smile

    Thread Captain

    2346 Posts

  • #4, by Simon_ASAMonday, 17. August 2015, 19:22 9 years ago
    Sorry I never work with characters, but it looks good.

    Great Poster

    321 Posts

  • #5, by sebastianMonday, 17. August 2015, 22:10 9 years ago
    @Simon_ASA: then just use condition for reference:
    function get_a_conditon(conditionname)
      local condition = getObject("Conditions[".. conditionname.."]")
     ...
    end
    


    EDIT: Ok, now it worked. I use the tupel of the object to get the object because they will not change as much as the name does (maybe).

    All i have to do is get the table and id of that object out of the explorer (Dump to log) and use the given numbers to get the desired object.


    I will post my solution in http://www.visionaire-studio.net/forum/thread/dialog-area-dy... when the whole thing is finished and cleaned up. Aim is to set the height and position of the dialog area by knowing the number of available displayed lines to avoid the arrows for scrolling.

    Thread Captain

    2346 Posts