refresh background-text | Hintergrund-Text erneuern

  • #10, z sebastianSaturday, 15. April 2017, 12:28 hodinky 8 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

    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


    its untested and out of my head^^

    Kapitán

    2346 Posts


  • #11, z afrlmeSaturday, 15. April 2017, 12:35 hodinky 8 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.

    Imperátor

    7285 Posts

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

    Fanoušek fóra

    167 Posts

  • #13, z afrlmeSaturday, 15. April 2017, 14:07 hodinky 8 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

    Imperátor

    7285 Posts

  • #14, z constantinSaturday, 15. April 2017, 15:55 hodinky 8 years ago
    thank you! 

    Fanoušek fóra

    167 Posts

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

    Fanoušek fóra

    167 Posts

  • #16, z sebastianMonday, 17. April 2017, 12:23 hodinky 8 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

    Kapitán

    2346 Posts

  • #17, z constantinMonday, 17. April 2017, 13:02 hodinky 8 years ago
    oh :-) thank you. 

    Fanoušek fóra

    167 Posts

  • #18, z afrlmeMonday, 17. April 2017, 13:56 hodinky 8 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)

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

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

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

    Imperátor

    7285 Posts

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

    Fanoušek fóra

    167 Posts