Difference between revisions of "Kill Background Text (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
Line 21: | Line 21: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
killText(3) | killText(3) | ||
+ | </syntaxhighlight> | ||
+ | 2d. To kill currently active narration background text: create an ''execute a script'' action containing... | ||
+ | <syntaxhighlight> | ||
+ | killText(4) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 26: | Line 30: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
--[[ | --[[ | ||
− | Kill background text (multiple options) [ | + | Kill background text (multiple options) [v4] (15/04/2017) |
Written by AFRLme [Lee Clarke] | Written by AFRLme [Lee Clarke] | ||
-- + -- | -- + -- | ||
− | + | https://de.tail.studio | afrlme@outlook.com | skype @ AFRLme | |
-- + -- | -- + -- | ||
This script is donation optional. In game credit is non-negotiable. | This script is donation optional. In game credit is non-negotiable. | ||
Line 35: | Line 39: | ||
Do not remove - or edit - this comment block. | Do not remove - or edit - this comment block. | ||
--]] | --]] | ||
− | + | ||
-- * tables * -- | -- * tables * -- | ||
txt = {} -- create table | txt = {} -- create table | ||
txt["_temporary_"] = "" -- set table as temporary | txt["_temporary_"] = "" -- set table as temporary | ||
− | + | ||
− | -- * function which kills active background text (1 = all, 2 = | + | -- * function which kills active background text (1 = all, 2 = all characters, 3 = current character, 4 = narration texts) * -- |
function killText(val) | function killText(val) | ||
− | for i = | + | for i = #txt, 1, -1 do |
− | if val == 1 and txt[i] | + | if val == 1 and txt[i].TextActive then txt[i].TextActive = false -- all background text (both character &; narration) |
− | elseif val == 2 and txt[i] | + | elseif val == 2 and txt[i].TextActive and txt[i].TextOwner:getId().tableId == eCharacters then txt[i].TextActive = false -- all character background text |
− | elseif val == 3 and txt[i] | + | elseif val == 3 and txt[i].TextActive and txt[i].TextOwner:getName() == game.CurrentCharacter:getName() then txt[i].TextActive = false -- current character background text |
+ | elseif val == 4 and txt[i].TextActive and txt[i].TextOwner:isEmpty() then txt[i].TextActive = false -- narration background text | ||
end | end | ||
end | end | ||
end | end | ||
− | + | ||
-- * on text display function * -- | -- * on text display function * -- | ||
− | function | + | function sText(text) |
− | if text | + | if text.TextBackground then table.insert(txt, text) end |
− | |||
− | |||
end | end | ||
− | + | ||
-- * function for text finished * -- | -- * function for text finished * -- | ||
function eText(text) | function eText(text) | ||
− | for i = | + | for i = #txt, 1, -1 do if not txt[i].TextActive then table.remove(txt, i) end end -- if text is inactive, remove from txt table |
end | end | ||
− | + | ||
-- * event handlers * -- | -- * event handlers * -- | ||
− | + | registerEventHandler("textStarted", "sText") -- event handler for begin text | |
− | registerEventHandler("textStopped", "eText") -- event handler for | + | registerEventHandler("textStopped", "eText") -- event handler for end text |
</syntaxhighlight>{{toc}} | </syntaxhighlight>{{toc}} |
Revision as of 11:34, 13 July 2017
Name | Type | By |
---|---|---|
Kill Background Text (multiple options) | Definition | AFRLme |
This script allows you to call a function which kills the active displayed text (background) of current character, all characters, or all background texts in general.
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. To kill all currently active background texts: create an execute a script action containing...
killText(1)
2b. To kill all currently active character based background texts: create an execute a script action containing...
killText(2)
2c. To kill currently active background text of current character: create an execute a script action containing...
killText(3)
2d. To kill currently active narration background text: create an execute a script action containing...
killText(4)
Main Script
--[[
Kill background text (multiple options) [v4] (15/04/2017)
Written by AFRLme [Lee Clarke]
-- + --
https://de.tail.studio | afrlme@outlook.com | skype @ AFRLme
-- + --
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].TextActive then txt[i].TextActive = false -- all background text (both character &; narration)
elseif val == 2 and txt[i].TextActive and txt[i].TextOwner:getId().tableId == eCharacters then txt[i].TextActive = false -- all character background text
elseif val == 3 and txt[i].TextActive and txt[i].TextOwner:getName() == game.CurrentCharacter:getName() then txt[i].TextActive = false -- current character background text
elseif val == 4 and txt[i].TextActive and txt[i].TextOwner:isEmpty() then txt[i].TextActive = false -- narration background text
end
end
end
-- * on text display function * --
function sText(text)
if text.TextBackground then table.insert(txt, text) end
end
-- * function for text finished * --
function eText(text)
for i = #txt, 1, -1 do if not txt[i].TextActive then table.remove(txt, i) end end -- if text is inactive, remove from txt table
end
-- * event handlers * --
registerEventHandler("textStarted", "sText") -- event handler for begin text
registerEventHandler("textStopped", "eText") -- event handler for end text