Difference between revisions of "ObjName (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
m |
||
(5 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 | + | 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/> | ||
− | + | 2a. Usage Example #1: return name belonging to a scene object belonging to the current scene. | |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | objName(game.CurrentScene.SceneObjects[" | + | 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> | ||
− | + | 2d. Usage Example #4: return name belonging to an interface button. | |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | objName( | + | objName(Interfaces["interface_name"].Buttons["button_name"]) |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | |||
function objName(obj) | function objName(obj) | ||
− | local | + | local t = obj:getId().tableId -- store table ID belonging to the linked visOBJ |
− | if | + | -- + -- |
− | return obj:getTextStr(VObjectName) | + | if t == eObjects then -- check if scene object or item |
− | elseif | + | return obj:getTextStr(VObjectName) -- return object/item name |
− | return obj:getTextStr(VCharacterName) | + | elseif t == eCharacters then -- check if character |
− | elseif | + | 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 | + | | 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}} |
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. |