Difference between revisions of "Kill Background Text (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "''''' * late now - will finish this page the morrow - might even create a global kill background text version * ''''' == Main Script == <syntaxhighlight> --[[ Kill background...")
 
m
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
''''' * late now - will finish this page the morrow - might even create a global kill background text version * '''''
+
{| class="ts" style="width:100%"
 +
|-
 +
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 +
|-
 +
| Kill Background Text (multiple options) || Definition || [https://www.patreon.com/AFRLme 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|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br />
 +
2a. To kill '''''all''''' currently active background texts: create an ''execute a script'' action containing...
 +
<syntaxhighlight lang="lua">
 +
killText(1)
 +
</syntaxhighlight>
 +
2b. To kill '''''all''''' currently active character based background texts: create an ''execute a script'' action containing...
 +
<syntaxhighlight lang="lua">
 +
killText(2)
 +
</syntaxhighlight>
 +
2c. To kill currently active background text of current character: create an ''execute a script'' action containing...
 +
<syntaxhighlight lang="lua">
 +
killText(3)
 +
</syntaxhighlight>
 +
2d. To kill currently active narration background texts: create an ''execute a script'' action containing...
 +
<syntaxhighlight lang="lua">
 +
killText(4)
 +
</syntaxhighlight>
  
 
== Main Script ==
 
== Main Script ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
 
--[[
 
--[[
Kill background text (current character) [v1] (25/02/2014)
+
Kill background text (multiple options) [v4] (15/04/2017)
 
Written by AFRLme [Lee Clarke]
 
Written by AFRLme [Lee Clarke]
 
-- + --
 
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
+
email: afrlme@outlook.com
 +
paypal: afrlme@zoho.com
 +
patreon: https://www.patreon.com/AFRLme
 +
portfolio: https://afrl.me
 
-- + --
 
-- + --
 
This script is donation optional. In game credit is non-negotiable.
 
This script is donation optional. In game credit is non-negotiable.
Line 13: Line 42:
 
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
txt["state"] = 0 -- default state of text (0 = normal, 1 = background text)
+
 
+
-- * function which kills active background text (1 = all, 2 = all characters, 3 = current character, 4 = narration texts) * --
-- * on text displayed function * --
+
function killText(val)
function hText(text)
+
  for i = #txt, 1, -1 do
  if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
+
  if val == 1 and txt[i].Active then txt[i].Active = false -- all background text (both character &; narration)
  txt["state"] = 1 -- text is now background text
+
  elseif val == 2 and txt[i].Active and txt[i].Owner:getId().tableId == eCharacters then txt[i].Active = false -- all character background text
   txt["text"] = text --store the current text
+
  elseif val == 3 and txt[i].Active and txt[i].Owner:getName() == game.CurrentCharacter:getName() then txt[i].Active = false -- current character background text
 +
   elseif val == 4 and txt[i].Active and txt[i].Owner:isEmpty() then txt[i].Active = false -- narration background text
 +
  end
 
  end
 
  end
return false -- prevent text from being repositioned
 
 
end
 
end
 
+
-- * on text end function * --
+
-- * on text display function * --
 +
function sText(text)
 +
if text.Background then table.insert(txt, text) end
 +
end
 +
 +
-- * function for text finished * --
 
function eText(text)
 
function eText(text)
  if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
+
  for i = #txt, 1, -1 do if not txt[i].Active then table.remove(txt, i) end end -- if text is inactive, remove from txt table
  txt["state"] = 0 -- set state back to default value
 
  txt["text"] = nil -- clear text
 
end
 
 
end
 
end
 
+
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
+
-- * event handlers * --
registerEventHandler("textStopped", "eText") -- event handler for text end
+
registerEventHandler("textStarted", "sText") -- event handler for begin text
</syntaxhighlight>
+
registerEventHandler("textStopped", "eText") -- event handler for end text
 +
</syntaxhighlight>{{toc}}

Latest revision as of 13:54, 15 September 2022

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 texts: 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]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
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 -- 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 -- all character background text
  elseif val == 3 and txt[i].Active and txt[i].Owner:getName() == game.CurrentCharacter:getName() then txt[i].Active = false -- current character background text
  elseif val == 4 and txt[i].Active and txt[i].Owner:isEmpty() then txt[i].Active = false -- 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)
 for i = #txt, 1, -1 do if not txt[i].Active 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