This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
setActionText(
cmd:getCurrentLanguageName()
.." "..
getScene(walkto):getCurrentLanguageName()
)
The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license. Until 1 Dec 2026 all licenses are 30 % off, for example the Indie Bundle for €69.30 instead of €99. The code BLACKFRIDAY is applied automatically at checkout.
See licenses Try it for free-- * function which updates the action text of an object for the current language * --
function setText(obj, txt)
local texts = obj.TextTextLanguages -- get all texts belonging to the object
-- + --
for i = 1, #texts do -- iterate through the stored texts
if texts[i].language == game.StandardLanguage:getId().id then
texts[i].text = txt; obj.TextTextLanguages = texts -- update old text with new text
break -- no need to keep iterating, cancel the loop
end
end
endsetText(game.CurrentScene.SceneObjects["example"].ObjectName, "some new text")function getObjLangName(obj)
if obj:isEmpty() then
return nil
end
local name
if obj:getId().tableId == eObjects then
name = obj:getLink(VObjectName)
elseif obj:getId().tableId == eCharacters then
name = obj:getLink(VCharacterName)
end
if name:isEmpty() then
return obj:getName()
end
local names = name.TextTextLanguages
for _,v in ipairs(names) do
if v.language == game.StandardLanguage:getId().id then
return v.text
end
end
end
ObjName(game.UsedItem)function ObjName(obj)
local table = obj:getId().tableId
if table == eObjects then
return obj:getTextStr(VObjectName)
elseif table == eCharacters then
return obj:getTextStr(VCharacterName)
elseif table == eButtons then
return obj:getTextStr(VButtonName)
end
endScenes["example"]:getTextStr(VSceneName)Scenes["example"]:getTextStr( VSceneName, Languages["English"]):getId().id )Ah yeah, sorry. I used an online translator to translate your text. I guess something got lost in the translation.no, you were right, AFRLme. He wanted to set a language depending text. But his last post was regarding getting it.Scenes["example"]:getTextStr(VSceneName)
Will return the name of the scene based on the currently active language. You can also return the name of a specified language too, but it requires the id rather than the language name. Like so...Scenes["example"]:getTextStr( VSceneName, Languages["English"]):getId().id )
ObjName(game.UsedItem)function ObjName(obj) local table = obj:getId().tableId if table == eObjects then return obj:getTextStr(VObjectName) elseif table == eCharacters then return obj:getTextStr(VCharacterName) elseif table == eButtons then return obj:getTextStr(VButtonName) end end
mostly historical reasons and the slow process of transition to the new naming system they introduced in V5.ObjName(game.UsedItem)function ObjName(obj) local table = obj:getId().tableId if table == eObjects then return obj:getTextStr(VObjectName) elseif table == eCharacters then return obj:getTextStr(VCharacterName) elseif table == eButtons then return obj:getTextStr(VButtonName) end end
Ok, makes it a little bit easier. Now tell me:
Why do I have to call the same function on different objects with different arbitrary constants to get the same result (current language ingame name)?
Why not have getGuiName() that every object understands?
At least, shouldnt it be the job of the object to know where to find its name?
Now I just need to know:There is a whole hook function which gets triggered when the action text changes it returns the new actiontext..
how do I change the action text?
if (_qp == nil) then
_qp = {}
math.randomseed( os.time() )
end
_qp.cmd = {}
_qp.cmd.objThis = emptyObject
_qp.cmd.objLast = emptyObject
_qp.cmd.cmdLast = emptyObject
_qp.cmd.altAction = nil
_qp.cmd['cmdWalk'] = getObject('Interfaces[_default].InterfaceButtons[cmdWalk]')
_qp.cmd['cmdLook'] = getObject('Interfaces[_default].InterfaceButtons[cmdLook]')
_qp.cmd['cmdUse'] = getObject('Interfaces[_default].InterfaceButtons[cmdUse]')
_qp.cmd['cmdTalk'] = getObject('Interfaces[_default].InterfaceButtons[cmdTalk]')
_qp.cmd['cmdGive'] = getObject('Interfaces[_default].InterfaceButtons[cmdGive]')
_qp.cmd['cmdTake'] = getObject('Interfaces[_default].InterfaceButtons[cmdTake]')
_qp.cmd['cmdPush'] = getObject('Interfaces[_default].InterfaceButtons[cmdPush]')
_qp.cmd['cmdPull'] = getObject('Interfaces[_default].InterfaceButtons[cmdPull]')
_qp.cmd['cmdOpen'] = getObject('Interfaces[_default].InterfaceButtons[cmdOpen]')
_qp.cmd['cmdClose'] = getObject('Interfaces[_default].InterfaceButtons[cmdClose]')
registerEventHandler('mainLoop', '_qpmain')
_qp.getObjLangName = function(obj)
if obj:isEmpty() then
return "--: empty :--"
end
local id = obj:getId().tableId
if id == eObjects then
return obj:getTextStr(VObjectName)
elseif id == eCharacters then
return obj:getTextStr(VCharacterName)
elseif id == eScenes then
return obj:getTextStr(VSceneName)
elseif id == eButtons then
return obj:getTextStr(VButtonName)
end
end
_qp.cmd.setActionText = function(text)
print(text)
end
_qp.cmd.callItemCommand = function(_cmd, _item)
-- NYI
return false
end
function _qpmain()
_qp.cmd.objThis = game:getLink(VGameCurrentObject)
-- skip if nothing happend
if _qp.cmd.objThis == _qp.cmd.lastObj
then return end
_qp.cmd.altAction = nil
_qp.cmd.onChangeObjectcommand()
_qp.cmd.lastObj = _qp.cmd.objThis
end
_qp.cmd.onChangeObjectcommand = function()
if _qp.cmd.objThis:isEmpty() or
_qp.cmd.objThis:getId().tableId ~= eObjects then
return false
end
-- get command object and internal command name
local cmd = game:getLink(VGameActiveCommand)
local cmdName = cmd:getName()
for _,v in ipairs(_qp.cmd.objThis:getLinks(VObjectValues)) do
local valName = v:getName()
local valStr = v:getStr(VValueString)
-- check if cmd is overridden by object
if valName == cmdName then
if _qp.cmd[valStr] ~= nil then
game:setValue(VGameActiveCommand, _qp.cmd[valStr])
end
return true
end
-- check for cmdWalk with walkto
if cmdName == "cmdWalk" and valName == "walkto" then
-- change action text
_qp.cmd.altAction = _qp.getObjLangName(cmd)..
" ".._qp.getObjLangName(Scenes[valStr])
return true
end
-- check if object represents an item
if valName == "item" then
-- call items command action
return _qp.cmd.callItemCommand(cmd, Items[valStr])
end
end
return false
endThis thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.
New threadDeponia, The Whispered World and more than 160 other games were made with Visionaire Studio. The free version covers up to 25 scenes. For more scenes there is Visionaire Studio PRO from €75, and to sell your game the Indie Bundle for €99.
Through December 1: all licenses 30% off, for example the Indie Bundle for €69.30 instead of €99. Applied automatically at checkout.