License from €75 Log in
DE EN FR ES IT CZ

Getting an object's name

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

  1. · 17 years ago
    Getting the name of the object/person currently underneath the cursor.
    
    local obj = game:getLink(VGameCurrentObject)
    if not obj:isEmpty() then
      local text
      if obj:getId().tableId == eObjects then
        text = obj:getLink(VObjectName)
      elseif obj:getId().tableId == eCharacters then
        text = obj:getLink(VCharacterName)
      end
      
      if not text:isEmpty() then
        local texts = text:getLinks(VTextAll)
        for i=1,table.maxn(texts) do
          local name = texts:getStr(VTextLanguageText)
          local lang = texts:getLink(VTextLanguageLanguage)
          if lang:getName() == 'Deutsch' then
            print('german name: ' .. name)
          elseif lang:getName() == 'English' then
            print('english name: ' .. name)
          end
        end
      end
    end
    
    Originally posted somewhere in the Visioniare forum by Alex.
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 15 years ago
    I just saw the script is not correct. this one works:
    
    local obj = game:getLink(VGameCurrentObject)
    if not obj:isEmpty() then
      local text
      if obj:getId().tableId == eObjects then
        text = obj:getLink(VObjectName)
      elseif obj:getId().tableId == eCharacters then
        text = obj:getLink(VCharacterName)
      end
    
    if not text:isEmpty() then
        local texts = text:getLinks(VTextAll)
        for i=1,table.maxn(texts) do
          local text = texts[i]
          local name = text:getStr(VTextLanguageText)
          local lang = text:getLink(VTextLanguageLanguage)
          if lang:getName() == 'Deutsch' then
            print('german name: ' .. name)
          elseif lang:getName() == 'English' then
            print('english name: ' .. name)
          end
        end
      end
    end
    

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?