--[[
Kill background text (multiple options) [v5] (27/06/2022)
Written by AFRLme [Lee Clarke]
-- + --
https://afrl.me | afrlme@outlook.com
-- + --
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.
--]]
-- * tables * --
txt = {} -- create table
txt["_temporary_"] = "" -- set table as temporary
-- * function which kills active background text (1 = all, 2 = all characters, 3 = current character, 4 = narration texts) * --
function killText(val)
for i = #txt, 1, -1 do
if val == 1 and txt[i].Active then txt[i].Active = false; table.remove(txt, i) -- all background text (both character &; narration)
elseif val == 2 and txt[i].Active and txt[i].Owner:getId().tableId == eCharacters then txt[i].Active = false; table.remove(txt, i) -- all character background text
elseif val == 3 and txt[i].Active and txt[i].Owner == game.CurrentCharacter then txt[i].Active = false; table.remove(txt, i) -- current character background text
elseif val == 4 and txt[i].Active and txt[i].Owner:isEmpty() then txt[i].Active = false; table.remove(txt, i) -- narration background text
end
end
end
-- * on text display function * --
function sText(text)
if text.Background then table.insert(txt, text) end
end
-- * function for text finished * --
function eText(text)
if text.Background and #txt > 0 then
for i = #txt, 1, -1 do if text == txt[i] then table.remove(txt, i) end end
end
end
-- * event handlers * --
registerEventHandler("textStarted", "sText") -- event handler for begin text
registerEventHandler("textStopped", "eText") -- event handler for end text