Interfaces["dialog_portraits"].Visible = false
-- * table to store character names & portrait_index value (case sensitive) * --
local portraits = {
["Tom"] = 1,
["Barry"] = 2,
["Angela"] = 3
}
-- * 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
Values["portrait_index"].Int = portraits[ text.Owner:getName() ] -- specify which character portrait to show
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
function setTextPosHook(text)
if text.Owner:getId().tableId == eCharacters then
if text.Owner:getName() == game.CurrentCharacter:getName() then
text.Position = { x = 358, y = 281}
else -- text doesn't belong to current character
text.Position = { x = 100, y = 100}
end
return true
end
end
-- let's create the event listener for handling position of displayed text
registerHookFunction("setTextPosition", "setTextPosHook")
Hi,I would recommend using Lua script & specifically the event handlers for textStarted & textStopped, why? because it will let you automate the whole thing instead of having to manually show/hide the interface & change conditions/values.Let's say you have created an interface & called it "dialog_portraits". You want to go into the properties for it & tick the "show interface permanently" option - this will allow the interface to be shown during cutscene events.Now assign the interface to your playable character via the "interfaces" tab.Next open up the main game settings section of the editor, & open up the "at begin start following action" as we need to add a line of code to hide the interface when the game starts. So create an execute a script action part & add this line of code to it.Interfaces["dialog_portraits"].Visible = false
Now open up the script section of the editor, & add this to it - edit it to suit your needs.-- * table to store character names & portrait_index value (case sensitive) * -- local portraits = { ["Tom"] = 1, ["Barry"] = 2, ["Angela"] = 3 } -- * 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 Values["portrait_index"].Int = portraits[ text.Owner:getName() ] -- specify which character portrait to show 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
Now go to the dialog_portraits interface you created. Click on the "values" tab & create a new value & call it "portrait_index".Now you need to start creating buttons, 1 per character (rename each button so that it has the same name as the character) & start adding images or animations to each of them (add images to inactive image section if you plan on using static sprites instead of animations). If you plan on using animations then don't forget to set them as active in the properties section for the button. Also don't forget to set the button types to "action area". You also need to link the portrait_index value to each of the buttons you have created ( use operator type = ) & make sure they reflect what values you added inside of the "portraits" table in the script.What should happen is that whenever text is started it should show the dialog interface & update the value based on which character is talking, which should display the correct portrait image/animation. Then when text ends it should hide the interface & portrait image/animation.
I know this is a massive wall of text, but I don't have any examples setup to screenshot/record, so this will have to do.
Anyway, good luck.