Difference between revisions of "ObjName (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
m
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
|}
 
|}
  
This small function allows you to return the action text name of the specified object; returns name based on current active language.
+
This small function allows you to quickly return the action text name of the linked Visionaire Studio Object (visOBJ).
 +
<hr>
 +
{| class="ts"
 +
|-
 +
| ''Quick note: returns name associated with current active language.''
 +
|}
 +
<hr>
 +
 
  
 
== Instructions ==
 
== Instructions ==
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
2. To use this function you should create an ''execute a script'' action containing...  
+
2a. Usage Example #1: return name belonging to a scene object belonging to the current scene.
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
objName(game.CurrentScene.SceneObjects["example"]) -- return name of a specified object
+
objName(game.CurrentScene.SceneObjects["object_name"])
 +
</syntaxhighlight>
 +
2b. Usage Example #2: return name belonging to the visObj currently below the mouse cursor.
 +
<syntaxhighlight lang="lua">
 +
objName(game.CurrentObject)
 +
</syntaxhighlight>
 +
2c. Usage Example #3: return name belonging to a character.
 +
<syntaxhighlight lang="lua">
 +
objName(Characters["character_name"])
 
</syntaxhighlight>
 
</syntaxhighlight>
''or...''
+
2d. Usage Example #4: return name belonging to an interface button.
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
objName(game.CurrentObject) -- return name of object currently underneath the cursor
+
objName(Interfaces["interface_name"].Buttons["button_name"])
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Main Script ==
 
== Main Script ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
-- * returns the objects, buttons or characters name * --
 
 
function objName(obj)
 
function objName(obj)
   local table = obj:getId().tableId
+
   local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ
   if table == eObjects then
+
  -- + --
     return obj:getTextStr(VObjectName)
+
   if t == eObjects then -- check if scene object or item
   elseif table == eCharacters then
+
     return obj:getTextStr(VObjectName) -- return object/item name
     return obj:getTextStr(VCharacterName)
+
   elseif t == eCharacters then -- check if character
   elseif table == eButtons then
+
     return obj:getTextStr(VCharacterName) -- return character name
     return obj:getTextStr(VButtonName)
+
   elseif t == eButtons then -- check if interface button
 +
     return obj:getTextStr(VButtonName) -- return interface button name
 
   end
 
   end
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Syntax Breakdown ==
 
== Syntax Breakdown ==
Line 39: Line 56:
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
|-
 
|-
| obj || link || This should be a link to the object you want to return the name for. The object can be a scene object, a character, an item or an interface button.
+
| 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.
 
|}{{toc}}
 
|}{{toc}}

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.