Difference between revisions of "Dynamic Action Names for Dragged Items (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
+
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By {{lee_PP}}
 
|-
 
|-
 
| Dynamic Action Names for Dragged Items || Definition || AFRLme
 
| Dynamic Action Names for Dragged Items || Definition || AFRLme
Line 10: Line 10:
 
== 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. Add/Remove language tables to/from the ''main script''; as required.<br/>
+
2. Add/Remove language tables to/from the '''iw''' & '''cj''' tables inside of the ''main script''; as required.<br/>
3. Edit the string values inside of the iw table; as required. iw stands for initial word. It is the word that will be displayed before the currently held items name. The order of the strings inside of the table should reflect the integer value of the conjunction_class value.
+
3. Edit the string values inside of the '''iw''' table; as required. '''iw''' stands for initial word. It is the word that will be displayed before the currently held items name. The order of the strings inside of the table should reflect the integer value of the ''conjunction_class'' value. There should be a space after the word like so: '''"word "'''.
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
 
iw = {} -- initial word table
 
iw = {} -- initial word table
 
iw["English"] = {"Use ", "Give ", "Show ", "Combine "}
 
iw["English"] = {"Use ", "Give ", "Show ", "Combine "}
Line 19: Line 19:
 
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}
 
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}
 
</syntaxhighlight>
 
</syntaxhighlight>
4. Create a new ''Value'' called '''conjunction_class'''.<br/>
+
4. Edit the string values inside of the '''cj''' table; as required. '''cj''' stands for conjunction word. It is the word that is displayed after the currently held items name. The order of the strings inside of the table should reflect the integer value of the ''conjunction_class'' value. There should be a space on both side of each word like so: '''" word "'''.
5. On mouse enter for each object/character/item, set '''conjunction_class''' value; as required.
+
<syntaxhighlight lang="lua">
 +
cj = {} -- conjunction word table
 +
cj["English"] = {" on ", " to ", " to ", " with "}
 +
cj["French"] = {" en ", " à ", " à ", " avec "}
 +
cj["German"] = {" auf ", " zu ", " zu ", " mit "}
 +
cj["Spanish"] = {" en ", " a ", " a ", " con "}
 +
</syntaxhighlight>
 +
5. Create a new ''value'' in the Visionaire Studio editor & call it: '''conjunction_class'''.<br/>
 +
6. On mouse enter for each object/character/item, set '''conjunction_class''' value; as required.
  
 
== Main Script ==
 
== Main Script ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
 
--[[
 
--[[
Dynamic action names for dragged items (v2) [20/02/2014]
+
Dynamic action names for dragged items [v2] (20/02/2014)
Written by AFRLme
+
Written by AFRLme [Lee Clarke]
 
-- + --
 
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
+
afrlme@outlook.com | https://afrl.me
 +
-- + --
 +
This script is donation optional. In game credit is non-negotiable.
 +
You are free to: ¹ use it in your game(s). ² modify the script.
 +
Do not remove - or edit - this comment block.
 
--]]
 
--]]
  
Line 42: Line 54:
 
iw["German"] = {"Benutzen ", "Geben ", "Zeigen ", "Kombinieren "}
 
iw["German"] = {"Benutzen ", "Geben ", "Zeigen ", "Kombinieren "}
 
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}
 
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}
cj = {} -- conjunction word
+
cj = {} -- conjunction word table
 
cj["English"] = {" on ", " to ", " to ", " with "}
 
cj["English"] = {" on ", " to ", " to ", " with "}
 
cj["French"] = {" en ", " à ", " à ", " avec "}
 
cj["French"] = {" en ", " à ", " à ", " avec "}
Line 57: Line 69:
 
  if not item:isEmpty() then -- if held item exists then...
 
  if not item:isEmpty() then -- if held item exists then...
 
   txt = item:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the held item
 
   txt = item:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the held item
   for i = 1, table.maxn(txt) do if txt[i]:getLink(VTextLanguageLanguage):getName() == lang then item = txt[i]:getStr(VTextLanguageText) end end -- store item name
+
   for i = 1, #txt do if txt[i]:getLink(VTextLanguageLanguage):getName() == lang then item = txt[i]:getStr(VTextLanguageText) end end -- store item name
 
   -- + --
 
   -- + --
 
   new = current:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the object under cursor
 
   new = current:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the object under cursor
   for i = 1, table.maxn(new) do table.insert(old, new[i]:getStr(VTextLanguageText))  end -- insert string names of table above
+
   for i = 1, #new do table.insert(old, new[i]:getStr(VTextLanguageText))  end -- insert string names of table above
 
   -- + --
 
   -- + --
   for i = 1, table.maxn(new) do if new[i]:getLink(VTextLanguageLanguage):getName() == lang then new[i]:setValue(VTextLanguageText, iw[lang][val] .. item .. cj[lang][val] .. old[i]) end end -- update object name with action text (initial word, item, conjunction word, target)
+
   for i = 1, #new do if new[i]:getLink(VTextLanguageLanguage):getName() == lang then new[i]:setValue(VTextLanguageText, iw[lang][val] .. item .. cj[lang][val] .. old[i]) end end -- update object name with action text (initial word, item, conjunction word, target)
 
  end   
 
  end   
 
end
 
end
Line 68: Line 80:
 
-- * function for resetting object name back to original name * --
 
-- * function for resetting object name back to original name * --
 
function resetItemActionName()
 
function resetItemActionName()
   for i = 1, table.maxn(new) do new[i]:setValue(VTextLanguageText, old[i]) end -- reset all text (for each language) back to original text...
+
   for i = 1, #new do new[i]:setValue(VTextLanguageText, old[i]) end -- reset all text (for each language) back to original text...
 
end
 
end
</syntaxhighlight>
+
</syntaxhighlight>{{toc}}
{{i18n|Dynamic_Action_Names_for_Dragged_Items_(CMS)}}
 

Latest revision as of 13:56, 20 April 2022

Name Type By

Dynamic Action Names for Dragged Items Definition AFRLme

This script allows you to create dynamic action words to place before & after the item name. For example: "Give money to Barkeep" or "Combine glass with whiskey", etc...

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. Add/Remove language tables to/from the iw & cj tables inside of the main script; as required.
3. Edit the string values inside of the iw table; as required. iw stands for initial word. It is the word that will be displayed before the currently held items name. The order of the strings inside of the table should reflect the integer value of the conjunction_class value. There should be a space after the word like so: "word ".

iw = {} -- initial word table
iw["English"] = {"Use ", "Give ", "Show ", "Combine "}
iw["French"] = {"Usage ", "Donner ", "Montrer ", "Combiner "}
iw["German"] = {"Benutzen ", "Geben ", "Zeigen ", "Kombinieren "}
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}

4. Edit the string values inside of the cj table; as required. cj stands for conjunction word. It is the word that is displayed after the currently held items name. The order of the strings inside of the table should reflect the integer value of the conjunction_class value. There should be a space on both side of each word like so: " word ".

cj = {} -- conjunction word table
cj["English"] = {" on ", " to ", " to ", " with "}
cj["French"] = {" en ", " à ", " à ", " avec "}
cj["German"] = {" auf ", " zu ", " zu ", " mit "}
cj["Spanish"] = {" en ", " a ", " a ", " con "}

5. Create a new value in the Visionaire Studio editor & call it: conjunction_class.
6. On mouse enter for each object/character/item, set conjunction_class value; as required.

Main Script

--[[
Dynamic action names for dragged items [v2] (20/02/2014)
Written by AFRLme [Lee Clarke]
-- + --
afrlme@outlook.com | https://afrl.me
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]

-- * local variables * --
local item, txt, current, lang, old, new, iw, cj, val  -- empty variables

-- * tables * --
old = {} -- table which will contain original item names
new = {} -- table which will contain updated names
iw = {} -- initial word table
iw["English"] = {"Use ", "Give ", "Show ", "Combine "}
iw["French"] = {"Usage ", "Donner ", "Montrer ", "Combiner "}
iw["German"] = {"Benutzen ", "Geben ", "Zeigen ", "Kombinieren "}
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}
cj = {} -- conjunction word table
cj["English"] = {" on ", " to ", " to ", " with "}
cj["French"] = {" en ", " à ", " à ", " avec "}
cj["German"] = {" auf ", " zu ", " zu ", " mit "}
cj["Spanish"] = {" en ", " a ", " a ", " con "}

-- * function for udating object name with action text * --
function itemActionName()
 item = game:getLink(VGameUsedItem) -- get currently held item
 current = game:getLink(VGameCurrentObject) -- get current object (under cursor)
 lang = game:getLink(VGameStandardLanguage):getName() -- get current game language
 val = getObject("Values[conjunction_class]"):getInt(VValueInt) -- get conjunction class value
 -- + --
 if not item:isEmpty() then -- if held item exists then...
  txt = item:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the held item
  for i = 1, #txt do if txt[i]:getLink(VTextLanguageLanguage):getName() == lang then item = txt[i]:getStr(VTextLanguageText) end end -- store item name
  -- + --
  new = current:getLink(VObjectName):getLinks(VTextAll) -- get all texts for the object under cursor
  for i = 1, #new do table.insert(old, new[i]:getStr(VTextLanguageText))  end -- insert string names of table above
  -- + --
  for i = 1, #new do if new[i]:getLink(VTextLanguageLanguage):getName() == lang then new[i]:setValue(VTextLanguageText, iw[lang][val] .. item .. cj[lang][val] .. old[i]) end end -- update object name with action text (initial word, item, conjunction word, target)
 end  
end

-- * function for resetting object name back to original name * --
function resetItemActionName()
  for i = 1, #new do new[i]:setValue(VTextLanguageText, old[i]) end -- reset all text (for each language) back to original text...
end