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...")
 
Line 1: Line 1:
''''' * late now - will finish this page the morrow - might even create a global kill background text version * '''''
+
{| class="wikitable" style="width:100%"
 +
|-
 +
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 +
|-
 +
| Kill Background Text (character) || Definition || AFRLme
 +
|}
 +
 
 +
This script allows you to call a function which kills the active displayed text (''background'') of the current character, or all characters.
 +
 
 +
<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 ==
 +
1. Select which script you want to use.
 +
=== Kill background text (current character) ===
 +
2. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 +
3. To kill currently active background text of current character: create an ''execute a script'' action containing...
 +
<syntaxhighlight>
 +
killCurrentBgText()
 +
</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 ==
Line 18: Line 49:
 
txt["_temporary_"] = "" -- set table as temporary
 
txt["_temporary_"] = "" -- set table as temporary
 
txt["state"] = 0 -- default state of text (0 = normal, 1 = background text)
 
txt["state"] = 0 -- default state of text (0 = normal, 1 = background text)
 +
 +
-- * function which kills the active text of the current (playable) character * --
 +
function killCurrentBgText()
 +
if txt["state"] == 1 then txt["text"]:setValue(VTextActive, false) end
 +
end
  
 
-- * on text displayed function * --
 
-- * on text displayed function * --
Line 37: Line 73:
  
 
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
 
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
registerEventHandler("textStopped", "eText") -- event handler for text end
+
registerEventHandler("textStopped", "eText") -- event handler for text finished
 +
</syntaxhighlight>
 +
 
 +
== 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>
 
</syntaxhighlight>

Revision as of 15:05, 30 March 2014

Name Type By
Kill Background Text (character) Definition AFRLme

This script allows you to call a function which kills the active displayed text (background) of the current character, or all characters.

Additional Info

In regards to the alternative script...
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.
 
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.
 
the table should be cleared every so often to reduce the workload of the loop iterator.

Instructions

1. Select which script you want to use.

Kill background text (current character)

2. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
3. To kill currently active background text of current character: create an execute a script action containing...

killCurrentBgText()

Kill background text (all characters)

2. Add the alternative script to the Visionaire Studio Script Editor & set the script as a definition script.
3. to do...

Main Script

--[[
Kill background text (current character) [v1] (25/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["state"] = 0 -- default state of text (0 = normal, 1 = background text)

-- * function which kills the active text of the current (playable) character * --
function killCurrentBgText()
 if txt["state"] == 1 then txt["text"]:setValue(VTextActive, false) end
end

-- * on text displayed function * --
function hText(text)
 if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
  txt["state"] = 1 -- text is now background text
  txt["text"] = text --store the current text
 end
 return false -- prevent text from being repositioned
end

-- * on text end function * --
function eText(text)
 if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() and text:getBool(VTextBackground) then
  txt["state"] = 0 -- set state back to default value
  txt["text"] = nil -- clear text
 end
end

registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
registerEventHandler("textStopped", "eText") -- event handler for text finished

Alternative Script

--[[
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