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

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Main Script)
m
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 
|-
 
|-
| Kill Background Text (character) || Definition || AFRLme
+
| 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 the current character, or all characters.
+
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.
 
 
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
 
<span class="bold">Additional Info</span>
 
<div class="mw-collapsible-content">
 
<div class="tbl-alt">In regards to the alternative script...</div>
 
<div>I initially tried adding each text into the txt["char"] table. This would have displayed something like: "text (24,1)", but once the text is no longer active, it ends up being displayed as "''-- empty --''", which meant I could not select the text & remove it from the table; hence the reason why we are running the getBool(VTextActive) on each table entry - if it returns true then it will set the text to inactive.</div>
 
<div class="tbl-alt">&nbsp;</div>
 
<div>Additionally I have decided to loop through the table in reverse, on the assumption that the most recent text entries are more likely to be active, as opposed to the earlier entries.</div>
 
<div class="tbl-alt">&nbsp;</div>
 
<div>the table should be cleared every so often to reduce the workload of the loop iterator.</div>
 
</div></div><br/>
 
  
 
== Instructions ==
 
== Instructions ==
1. Select which script you want to use.
+
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br />
=== Kill background text (current character) ===
+
2a. To kill '''''all''''' currently active background texts: create an ''execute a script'' action containing...
2. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
+
<syntaxhighlight lang="lua">
3. To kill currently active background text of current character: create an ''execute a script'' action containing...
+
killText(1)
<syntaxhighlight>
+
</syntaxhighlight>
killCurrentBgText()
+
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>
 
</syntaxhighlight>
 
=== Kill background text (all characters) ===
 
2. Add the [[#Alternative_Script|alternative script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
3. to do...
 
  
 
== Main Script ==
 
== Main Script ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
 
--[[
 
--[[
Kill background text (multiple options) [v3] (30/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 44: 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
 
+
-- * function which kills active background text (1 = all, 2 = all characters, 3 = current character) * --
+
-- * 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 = table.maxn(txt), 1, -1 do  
+
  for i = #txt, 1, -1 do  
   if val == 1 and txt[i]:getBool(VTextActive) then txt[i]:setValue(VTextActive, false) -- all background text
+
   if val == 1 and txt[i].Active then txt[i].Active = false -- all background text (both character &; narration)
   elseif val == 2 and txt[i]:getBool(VTextActive) and txt[i]:getLink(VTextOwner):getId().tableId == eCharacters then txt[i]:setValue(VTextActive, false) -- all character 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
   elseif val == 3 and txt[i]:getBool(VTextActive) and txt[i]:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() then txt[i]:setValue(VTextActive, false); break -- current 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
 
  end
 
end
 
end
 
+
 
-- * on text display function * --
 
-- * on text display function * --
function hText(text)
+
function sText(text)
  if text:getBool(VTextBackground) then table.insert(txt, text) end
+
  if text.Background then table.insert(txt, text) end
-- * --
 
return false -- prevent text from being repositioned
 
 
end
 
end
 
+
 
-- * function for text finished * --
 
-- * function for text finished * --
 
function eText(text)
 
function eText(text)
  for i = table.maxn(txt), 1, -1 do if not txt[i]:getBool(VTextActive) then table.remove(txt, i) end end -- if text is inactive, remove from txt table
+
  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
 
end
 
+
 
-- * event handlers * --
 
-- * event handlers * --
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
+
registerEventHandler("textStarted", "sText") -- event handler for begin text
registerEventHandler("textStopped", "eText") -- event handler for finished text
+
registerEventHandler("textStopped", "eText") -- event handler for end text
</syntaxhighlight>
+
</syntaxhighlight>{{toc}}
 
 
== Alternative Script ==
 
<syntaxhighlight>
 
--[[
 
Kill background text (all characters) [v2] (28/02/2014)
 
Written by AFRLme [Lee Clarke]
 
-- + --
 
alternatingfrequencies@hotmail.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
 
txt["char"] = {}
 
 
 
-- * function for checking which character texts are active; if active then set inactive  * --
 
function killCharBgText()
 
for i = 1, table.maxn(txt["char"]) do  -- for i = 1 to txt["char"] table total do...
 
  if txt["char"][i]:getBool(VTextActive) then txt["char"][i]:setValue(VTextActive, false) end -- if text[i] is active then set inactive
 
end
 
-- * --
 
txt["char"] = {} -- reset the table.
 
end
 
 
 
-- * on text display function * --
 
function hText(text)
 
if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getBool(VTextBackground) then table.insert(txt["char"], text) end -- text belongs to character & is background text, insert into table
 
-- * --
 
return false -- prevent text from being repositioned
 
end
 
 
 
-- * event handlers * --
 
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
 
</syntaxhighlight>
 

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