function setTxtPos(text)
if text.Owner:getId().tableId == eCharacters then
text.Position = {x = game.ScrollPosition.x + 100, y = game.ScrollPosition.y + 900}
return true
end
return false
end
registerHookFunction("setTextPosition", "setTxtPos")
(game.WindowResolution / 2)
-- * table to store character names & portrait_index value (case sensitive) * --
local portraits = {
["Tom"] = 1,
["Barry"] = 2,
["Angela"] = 4
}
-- * text started event listener * --
function sText(text)
if text.Owner:getId().tableId == eCharacters then -- check text belongs to a character
Interfaces["dialog_portraits"].Visible = true -- show the dialog_portraits interface
if text.Owner == Characters["Barry"] then
if characters["barry"].CurrentOutfit:getName() == "example" then
Values["portrait_index"].Int = 2
else
Values["portrait_index"].Int = 3
end
else
Values["portrait_index"].Int = portraits[ text.Owner:getName() ] -- specify which character portrait to show
end
end
end
-- * text finished event handler * --
function eText(text)
if text.Owner:getId().tableId == eCharacters then -- check text belongs to a character
Values["portrait_index"].Int = -1 -- reset portrait_index value back to -1 to hide all portrait images
Interfaces["dialog_portraits"].Visible = false -- hide the dialog_portraits interface
end
end
-- * event handlers * --
registerEventHandler("textStarted", "sText") -- event handler for begin text
registerEventHandler("textStopped", "eText") -- event handler for end text
This script is made to show portraits of the characters, not the characters themselves.Thank you for the answer.
I don't know the setup of your game. Are there characters in the game walking around, or is it more of a first person view and you use characters only for the dialogues?When using portraits, not the characters themselves: add portraits of the characters as buttons to the interface with your textbox. Assign a value for portrait_index to that button and change name and value according to your settings in the script.When using characters you could set the postion of the character so that it aligns with your box (but you would have to do this for every scene), leave all directions of the character empty, only add an image to the talk outfit. Then the character should appear when talking. But keep in mind, that the interface is above everything in the scene including the characters. So the characters can only be on the side, above, below the text box, not in front of it.