Player hangs up on "Kill Background Text" script

  • #1, by thomas-fringsMonday, 27. June 2022, 10:17 A year ago
    Is the "Kill Background Text (CMS)" script still up to date? For unknown reasons, the player hangs on.

    In the debug the following line is highlighted:
    for i = #txt, 1, -1 do if not txt.TextActive then table.remove(txt, i) end end -- if text is inactive, remove from txt table

    And the log says:
    Failed to execute hook function 'eText':

    No script action is executed in the game and I did not change anything in the script.

    If I disable the main script, then the problem does not occur.

    Newbie

    21 Posts


  • #2, by afrlmeMonday, 27. June 2022, 12:05 A year ago
    Do any other text event handlers already exist in your project?

    In regards to the script, it's not as updated as it could be, but it should still work fine. Anyway, I'll give the script a try later in a test ved & see if it works or needs updating. To be honest I've not used it since I wrote it years ago. Also I fixed the deprecated maxn table function the other year or so.

    Imperator

    7278 Posts

  • #3, by thomas-fringsMonday, 27. June 2022, 13:16 A year ago
    Yes, I still use a text event handler to change the text position. But this is already disabled.

    Above all, the error is reproducible:

    - create new game with minimal configuration
    - add the main script and set the script as a definition script
    - add the action part "Display text" to the object "rock" [First scene] and write a sample text
    - set "Show as background text"
    - in the game, hastily click on the rock (for example with a double click), then the error appears in the log

    Newbie

    21 Posts

  • #4, by afrlmeMonday, 27. June 2022, 15:35 A year ago
    Hmm, I think I have fixed it. At least I'm not getting any more errors & I tested it with the print function to see if the txt table was getting emptied correctly & it wasn't printing anything to the log. I also tested the killText() function as well & it seems to be working correctly too.

    I have no idea why it stopped working. Just kept reporting that I was trying to access an empty object, which means that I was trying to access something that doesn't exist or no longer exists. I've updated it to modern shorthand & I've added in some additional if queries.

    --[[
    
    Kill background text (multiple options) [v5] (27/06/2022)
    
    Written by AFRLme [Lee Clarke]
    
    -- + --
    
    https://afrl.me | afrlme@outlook.com
    
    -- + --
    
    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; table.remove(txt, i) -- 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; table.remove(txt, i) -- all character background text
    
      elseif val == 3 and txt[i].Active and txt[i].Owner == game.CurrentCharacter then txt[i].Active = false; table.remove(txt, i) -- current character background text
    
      elseif val == 4 and txt[i].Active and txt[i].Owner:isEmpty() then txt[i].Active = false; table.remove(txt, i) -- 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)
    
     if text.Background and #txt > 0 then
    
       for i = #txt, 1, -1 do if text == txt[i] then table.remove(txt, i) end end
    
     end
    
    end
    
     
    
    -- * event handlers * --
    
    registerEventHandler("textStarted", "sText") -- event handler for begin text
    
    registerEventHandler("textStopped", "eText") -- event handler for end text

    Imperator

    7278 Posts

  • #5, by thomas-fringsThursday, 30. June 2022, 10:44 A year ago
    This is great what you have done. Thank you very much for your effort.

    Since a few days I have also tested it and there were no problems. 

    Newbie

    21 Posts