Add item 'envelope' to Character 'Timmy'

  • #1, z DundilWednesday, 06. March 2013, 14:47 hodinky 12 years ago
    Hi,

    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.

    Thanks!

    Bažant

    19 Posts


  • #2, z afrlmeWednesday, 06. March 2013, 16:23 hodinky 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 projects.ve file itself by reading it with a text editor like notepad++ or sublime.

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

    Imperátor

    7285 Posts

  • #3, z mowrenWednesday, 06. March 2013, 17:51 hodinky 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 .. ': ')
        print(items[i])
      end
    
      char:setValue(VCharacterItems, items)
    end

    Bažant

    10 Posts

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

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

    Bažant

    19 Posts