Difference between revisions of "ObjName (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
m
 
Line 39: Line 39:
 
function objName(obj)
 
function objName(obj)
 
   local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ
 
   local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ
   if table == eObjects then -- check if scene object or item
+
  -- + --
 +
   if t == eObjects then -- check if scene object or item
 
     return obj:getTextStr(VObjectName) -- return object/item name
 
     return obj:getTextStr(VObjectName) -- return object/item name
   elseif table == eCharacters then -- check if character
+
   elseif t == eCharacters then -- check if character
 
     return obj:getTextStr(VCharacterName) -- return character name
 
     return obj:getTextStr(VCharacterName) -- return character name
   elseif table == eButtons then -- check if interface button
+
   elseif t == eButtons then -- check if interface button
 
     return obj:getTextStr(VButtonName) -- return interface button name
 
     return obj:getTextStr(VButtonName) -- return interface button name
 
   end
 
   end

Latest revision as of 17:34, 23 August 2022

Name Type By
objName(obj) Definition Sebastian

This small function allows you to quickly return the action text name of the linked Visionaire Studio Object (visOBJ).


Quick note: returns name associated with current active language.


Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage Example #1: return name belonging to a scene object belonging to the current scene.

objName(game.CurrentScene.SceneObjects["object_name"])

2b. Usage Example #2: return name belonging to the visObj currently below the mouse cursor.

objName(game.CurrentObject)

2c. Usage Example #3: return name belonging to a character.

objName(Characters["character_name"])

2d. Usage Example #4: return name belonging to an interface button.

objName(Interfaces["interface_name"].Buttons["button_name"])


Main Script

function objName(obj)
  local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ
  -- + --
  if t == eObjects then -- check if scene object or item
    return obj:getTextStr(VObjectName) -- return object/item name
  elseif t == eCharacters then -- check if character
    return obj:getTextStr(VCharacterName) -- return character name
  elseif t == eButtons then -- check if interface button
    return obj:getTextStr(VButtonName) -- return interface button name
  end
end


Syntax Breakdown

Name Type Description
obj link This should be a link to the visOBJ you want to return the name for. The object can be a scene object, a character, an item, or an interface button.