Add item 'envelope' to Character 'Timmy'

  • #1, by DundilWednesday, 06. March 2013, 14:47 12 years ago

    How can headline action be done with LUA? I mean, giving an item (i.e. envelope) to a Character (i.e. Timmy).
    I've looked for the action in Data Structure documentation, but the only similar thing I see there is the CharacterItems field in Character table. I have tried adding an object there, but I can't.



    19 Posts

  • #2, by afrlmeWednesday, 06. March 2013, 16:23 12 years ago
    hmm ...
    only thing I see in the data structure are the commands for listing game items & character items.

    I'm not sure based on this if you can give the characters items using lua (Alex would know- I think)
    you could try reading the lua files insie of the visionaire3 folder found in program files or maybe inside of the file itself by reading it with a text editor like notepad++ or sublime.

    I know you can write commands like game:getLink etc.


    7278 Posts

  • #3, by mowrenWednesday, 06. March 2013, 17:51 12 years ago
    Just use a function like this. i.g. addItemToChar( "Timmy", "evenlope" )

    function addItemToChar (iChar, iItem)
      local char = getObject("Characters[" .. iChar .. "]")
      local items = char:getLinks(VCharacterItems)
      local gameItem = getObject("Game.GameItems[" .. iItem.. "]")
      table.insert(items, gameItem)
      -- debugging
      for i = 1, table.maxn(items) do
        print('item ' .. i .. ': ')
      char:setValue(VCharacterItems, items)


    10 Posts

  • #4, by DundilWednesday, 06. March 2013, 19:38 12 years ago
    Yeah, it works!

    Thanks a lot. So, this is the way to add data to a table... Good to know. Thanks!


    19 Posts