Skip Protection of Displayed Text

  • #1, by marchardWednesday, 08. May, 13:12 3 months ago
    Hello everybody!

    I'm struggling with the displayed text and skipping. I know, that the following tags are available, and they work as described.

     
    Wait until left mouse button is clicked to continue <p>

    Continue after 2500 milliseconds (ms) <p2500ms>

    Wait until linked speech file has finished playing <pa>


    But none of them is what I want in my game. I want, what many other commercial games do, which is the following...

    Once a text is displayed by the playable character or a NPC the text should be visible for a certain amount of time and then disappear automatically. It should also be possible to skip the text by pressing the left mouse button. This can be done, by simply using no tag at all and selecting "Always allow to skip active text" in the game properties. The text stays there automatically based on the text length and you can skip it any time. So far so good.

    BUT the problem is, when you want to skip the text and press the left mouse button incidentally exactly when a new text appears, this new text is immediately skipped, before you were able to read it.

    I would like to have a kind of "click protection" meaning, that you can't skip the text during e.g. the first second of its appearing. Many commercial point and click adventures do it this way, but I can't do it with VS. How can I achieve this?

    Any help would be great.

    Newbie

    35 Posts


  • #2, by AFRLmeWednesday, 08. May, 15:13 3 months ago
    use the pause action part to insert a small pause before each text is shown, that way it doesn't immediately show the text as soon as the last one ends, thus preventing you from accidentally skipping it. around 100-250ms should be ok.

    alteratively, what you could do is use the text start/end event handlers to set a delay before text can be skipped with left mouse button - less work than the other solution I just mentioned.

    -- * function for text started * --
    function sText(text)
    setDelay(250, function()
    game.AlwaysAllowSkipText = true
    end)
    end

    -- * function for text finished * --
    function eText(text)
    game.AlwaysAllowSkipText = false
    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

    add as a definition script. uncheck always allow skip text in the main game settings. also if you already have textStarted/textStopped event handlers, then you will need to take the code I wrote inside of the functions I just shared & add them into your existing functions or just call the functions I've created inside of yours & delete/comment out the registerEventHandler lines in my example - because only one instance of textStarted/textStopped can exist per project.

    * edit: just tested it & it seems to work. change 250 to whatever delay value you want - in ms (milliseconds).

    Imperator

    6587 Posts

  • #3, by marchardWednesday, 08. May, 15:52 3 months ago
    Hello AFRLme!

    Thank you very much, but this isn't exactly what I meant. The pause was the first thing I came up with myself of course, but it didn't solve my problem.

    I want every text to stay for exactly 1000ms second, before you can skip it. The pause doesn't prevent one from clicking away the new text once it appears.  It only delays the game. E.g. if the pause is 1000ms and then the new text appears and you click the left mouse button after 1001ms the text will be immediately clicked away again.

    Maybe in other words. If you hammer on the left mouse button rapidly, I want a solution, that the text will always be shown, no matter how quick you press the left mouse button until 1000ms are over then it can be skipped. If you don't press the left mouse button at all, the text should be automatically disappear after a certain amount of time (depending on the text length of course) and the next one shown.

    I don't know if your script will handle this, I'll try it later. Thank you.

    Edit:
    Another issue with a pause is, that during the pause you can steer the character, which I don't want. I could hide the cursor, but then no keys are available which I need for entering e.g. the main menu.

    Newbie

    35 Posts

  • #4, by AFRLmeWednesday, 08. May, 18:11 3 months ago
    The script I wrote works. it prevents you from skipping text, but you need to wrap the first text in a begin cutscene/hide cursor action part & then after the final display text add an end cutscene/show cursor action part. always allow skip text is to determine if texts can be skipped during cutscenes. you really should be wrapping your display texts in cutscene wrappers anyway - would have also solved your issue with the player being able to control the character during the pauses...

    actually, you could hide/show cursor in the begin & end text event handlers, which will make the display texts behave like cutscene display texts & thus the script I gave you will work.

    try this script... it's the same as before, but I modified it to hide/show the cursor on text start/end, but only if cursor isn't already hidden or a cutscene is active. not tested, but it should work.

    local handle_cutscene_txt = false

    -- * function for text started * --
    function sText(text)
    if not game.HideCursor and game.CutsceneAction:isEmpty() and not handle_cutscene_txt then
    game.HideCursor = true
    handle_cutscene_txt = true
    end
    -- + --
    setDelay(250, function()
    game.AlwaysAllowSkipText = true
    end)
    end

    -- * function for text finished * --
    function eText(text)
    if handle_cutscene_txt then
    game.HideCursor = false
    handle_cutscene_txt = false
    end
    -- + --
    game.AlwaysAllowSkipText = false
    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

    Imperator

    6587 Posts

  • #5, by marchardThursday, 09. May, 12:30 3 months ago
    Yes, I usually work with hide cursor and hide interfaces, because of this. I don't use begin/end cutscene, because I don't want an important scene to be skipped with escape by the user.

    Thank you very much for the script.

    Newbie

    35 Posts

Write post