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

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "wikitable" to "ts")
m
Line 1: Line 1:
 
{| class="ts" 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 {{lee_PP}}
 
|-
 
|-
 
| Kill Background Text (multiple options) || Definition || AFRLme
 
| Kill Background Text (multiple options) || Definition || AFRLme
Line 65: Line 65:
 
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
 
registerHookFunction("setTextPosition", "hText") -- event handler for displayed text
 
registerEventHandler("textStopped", "eText") -- event handler for finished text
 
registerEventHandler("textStopped", "eText") -- event handler for finished text
</syntaxhighlight>
+
</syntaxhighlight>{{toc}}

Revision as of 17:54, 6 January 2015

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)

Main Script

--[[
Kill background text (multiple options) [v3] (30/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

-- * function which kills active background text (1 = all, 2 =  all characters, 3 = current character) * --
function killText(val)
 for i = table.maxn(txt), 1, -1 do 
  if val == 1 and txt[i]:getBool(VTextActive) then txt[i]:setValue(VTextActive, false) -- all background text
  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 == 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
  end
 end
end

-- * on text display function * --
function hText(text)
 if text:getBool(VTextBackground) then table.insert(txt, text) end
 -- * --
 return false -- prevent text from being repositioned
end

-- * function for text finished * --
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
end

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