refresh background-text | Hintergrund-Text erneuern

  • #10, by sebastianSaturday, 15. April 2017, 12:28 3 years ago
    Narration text doesn't have an owner.... But because these texts are the only one which doesn't have an owner you could check it:

    This is the base script for killing several background texts from th wiki / AFRLme :

    --[[
    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
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40

    you could then add an elseif val == 4 which checks if there is no owner of a current active text:

    elseif val == 4 and txt[i]:getBool(VTextActive)  and txt[i]:getLink(VTextOwner) == nil then txt[i]:setValue(VTextActive, false) -- kill texts with no owner/narration
    1


    its untested and out of my head^^

    Thread Captain

    2336 Posts


  • #11, by afrlmeSaturday, 15. April 2017, 12:35 3 years ago
    Um... you have to store texts in a table. killText(1) will remove/kill all texts currently displayed that have background option enabled. They will also be removed from the table automatically too when a text is killed / ends normally as it checks the table & removes them if they are no longer active.

    Imperator

    6817 Posts

  • #12, by constantinSaturday, 15. April 2017, 13:18 3 years ago
    Thank you for the answers. i will try this.
    Constantin

    Forum Fan

    167 Posts

  • #13, by afrlmeSaturday, 15. April 2017, 14:07 3 years ago
    I think that script could actually do with updating a little bit. The hook function for adjusting text position works like a loop, so it's actually adding the text into a table multiple times which isn't all that great. Not sure why I used that to be honest.

    Anyway, here's an updated script. Now includes kill narration text only option & rewritten with Lua shorthand.

    --[[
    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
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39

    Imperator

    6817 Posts

  • #14, by constantinSaturday, 15. April 2017, 15:55 3 years ago
    thank you! 

    Forum Fan

    167 Posts

  • #15, by constantinMonday, 17. April 2017, 11:50 3 years ago
    unfortunately the skript doesnt work. maybe i have to change the action for the left mouse button as well? 
    constantin

    Forum Fan

    167 Posts

  • #16, by sebastianMonday, 17. April 2017, 12:23 3 years ago
    whenever you want to kill narration text you need to execute a script with "killText(4)" in it. So when it should do this with left click add it also to your left click function smile

    Thread Captain

    2336 Posts

  • #17, by constantinMonday, 17. April 2017, 13:02 3 years ago
    oh :-) thank you. 

    Forum Fan

    167 Posts

  • #18, by afrlmeMonday, 17. April 2017, 13:56 3 years ago
    oh :-) thank you. 
    haha, yeah... I should have probably mentioned that it's not automatic. Any definition scripts that contain functions usually require you to the execute a function from another script or from an execute a script action part, so in the case of this script...

    kill all background texts
    killText(1)
    1

    kill all background texts that belong to characters
    killText(2)
    1

    kill all background texts that belong to the current character
    killText(3)
    1

    kill all background texts that are narration texts
    killText(4)
    1

    Imperator

    6817 Posts

  • #19, by constantinMonday, 17. April 2017, 18:38 3 years ago
    works - thank you! :-)

    Forum Fan

    167 Posts

Write post