Difference between revisions of "Dynamic Action Names (CMS)"
m (Text replacement - "wikitable" to "ts") |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="ts" 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 |
|- | |- | ||
− | | Dynamic Action Names || Definition || AFRLme | + | | Dynamic Action Names || Definition || [https://www.patreon.com/AFRLme AFRLme] |
|} | |} | ||
Line 9: | Line 9: | ||
== 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. Create language tables inside of the '''t''' table; language names should reflect languages names assigned to your project. | 2. Create language tables inside of the '''t''' table; language names should reflect languages names assigned to your project. | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
-- * tables * -- | -- * tables * -- | ||
local t = {} | local t = {} | ||
Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
3. Add action names to each language table; <span class="red">!important</span> - they must all be written in the same order. | 3. Add action names to each language table; <span class="red">!important</span> - they must all be written in the same order. | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
t["English"] = {"Use", "Pick Up", "Push", "Pull"} | t["English"] = {"Use", "Pick Up", "Push", "Pull"} | ||
t["German"] = {"Benutzen", "Nehmen", "Drucken", "Ziehen"} | t["German"] = {"Benutzen", "Nehmen", "Drucken", "Ziehen"} | ||
Line 25: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
4. On mouse enter for each object, character, or item; create an execute a script action containing... | 4. On mouse enter for each object, character, or item; create an execute a script action containing... | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
renameBtn(integer value) | renameBtn(integer value) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
example | example | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
renameBtn(1) -- returns "Use", "Benutzen" etc... | renameBtn(1) -- returns "Use", "Benutzen" etc... | ||
renameBtn(2) -- returns "Pick Up", "Nehmen" etc... | renameBtn(2) -- returns "Pick Up", "Nehmen" etc... | ||
Line 35: | Line 35: | ||
-- it will return a single name from the tables based on integer value of '''val''' & the current game language. | -- it will return a single name from the tables based on integer value of '''val''' & the current game language. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | 5. On mouse out for each | + | 5. On mouse out for each object, character or item; create an execute a script action containing... |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
resetBtn() | resetBtn() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
--[[ | --[[ | ||
Dynamic action names [v3] (14/03/2014) | Dynamic action names [v3] (14/03/2014) | ||
Written by AFRLme [Lee Clarke] | Written by AFRLme [Lee Clarke] | ||
-- + -- | -- + -- | ||
− | + | email: afrlme@outlook.com | |
+ | paypal: afrlme@zoho.com | ||
+ | patreon: https://www.patreon.com/AFRLme | ||
+ | portfolio: https://afrl.me | ||
-- + -- | -- + -- | ||
This script is donation optional. In game credit is non-negotiable. | This script is donation optional. In game credit is non-negotiable. | ||
Line 65: | Line 68: | ||
-- * set new action name * -- | -- * set new action name * -- | ||
function renameBtn(val) | function renameBtn(val) | ||
− | btn = game | + | btn = game.ActiveCommand:getLink(VButtonName) -- store current command |
texts = btn:getLinks(VTextAll) -- get all texts related to the button | texts = btn:getLinks(VTextAll) -- get all texts related to the button | ||
lang = game:getLink(VGameStandardLanguage):getName() -- get current game language | lang = game:getLink(VGameStandardLanguage):getName() -- get current game language | ||
Line 78: | Line 81: | ||
for i = 1, table.maxn(texts) do texts[i]:setValue(VTextLanguageText, "") end | for i = 1, table.maxn(texts) do texts[i]:setValue(VTextLanguageText, "") end | ||
end | end | ||
− | </syntaxhighlight> | + | </syntaxhighlight>{{toc}} |
Latest revision as of 12:58, 15 September 2022
Name | Type | By |
---|---|---|
Dynamic Action Names | Definition | AFRLme |
This script allows you to create dynamic action names that are set on mouse over; this script is especially useful for developers using the broken sword style command interface or a coin based command interface with limited commands.
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. Create language tables inside of the t table; language names should reflect languages names assigned to your project.
-- * tables * --
local t = {}
t["English"]
t["German"]
-- etc...
3. Add action names to each language table; !important - they must all be written in the same order.
t["English"] = {"Use", "Pick Up", "Push", "Pull"}
t["German"] = {"Benutzen", "Nehmen", "Drucken", "Ziehen"}
-- etc...
4. On mouse enter for each object, character, or item; create an execute a script action containing...
renameBtn(integer value)
example
renameBtn(1) -- returns "Use", "Benutzen" etc...
renameBtn(2) -- returns "Pick Up", "Nehmen" etc...
-- it will return a single name from the tables based on integer value of '''val''' & the current game language.
5. On mouse out for each object, character or item; create an execute a script action containing...
resetBtn()
Main Script
--[[
Dynamic action names [v3] (14/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: 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 texts, lang, btn, val -- empty variables
-- * tables * --
local t = {}
t["English"] = {"Use", "Pick up", "Push", "Pull"}
t["French"] = {"Usage", "Prendre", "Appuyer", "Arracher"}
t["German"] = {"Benutzen", "Nehmen", "Drucken", "Ziehen"}
t["Spanish"] = {"Usar", "Cojer", "Empujar", "Tirar"}
-- * set new action name * --
function renameBtn(val)
btn = game.ActiveCommand:getLink(VButtonName) -- store current command
texts = btn:getLinks(VTextAll) -- get all texts related to the button
lang = game:getLink(VGameStandardLanguage):getName() -- get current game language
-- * --
for i = 1, table.maxn(texts) do
if texts[i]:getLink(VTextLanguageLanguage):getName() == lang then texts[i]:setValue(VTextLanguageText, t[lang][val]) end
end
end
-- * reset action names back to default * --
function resetBtn()
for i = 1, table.maxn(texts) do texts[i]:setValue(VTextLanguageText, "") end
end