How can I disable functions of a definition script in MenuScenes? [SOLVED via Discord]

  • #1, by retinaMonday, 14. September, 16:22 2 months ago
    SOLUTION:
    It must be "If not game.CurrentScene.IsMenu" added to function b). The Code below is already adapted.

    PROBLEM:
    I want to disable functions of a definition script in MenuScenes. How can I do that?
    I already tried to include an "If not Scenes.IsMenu…" and "If Scenes.IsMenu == false…" to the functions. But then the script would not work in normal Scenes either. Since I am not a programmer, maybe I didn't code it correctly. So I ask for your help.

    Alternative Question: How can I end an execution scripts later on in the game e.g. in a MenuScene?
    As I use MenuScenes at the beginning of the game, I also tried to call the script as an execution script in the first Scene. But I don't know how to end/stop this execution script when I have a MenuScene later in the game.

    Details about the script:

    I use a definition Script with EventHandlers for "textStarted" and "textStopped" which includes following functions:
    function a) for displaying speechbubbles when characters are speaking
    and
    function b) for hiding the cursor & allowing to skip text while text is displayed (this includes object text, narration text and character text).

    In regular Scenes this script works fine and is exactly what I want.
    But I don't want this script, especially function b) to be enabled in MenuScenes with displayed object or narration text.

    Happy for any help!

    Here comes the script without the "If not Scenes.IsMenu…"-Experiment.
    -- * event handlers * --
    registerEventHandler("textStarted", "onTextStarted")
    registerEventHandler("textStopped", "onTextStopped")

    -- * lokal: handle cutscene * --
    local handle_cutscene_txt = false


    -- * function for text started * --
    function onTextStarted(text)
      -- * function part for speechbubbles * --
      local currentCharacter = game.CurrentCharacter
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters then
        local isLeft = owner:getName() == currentCharacter:getName()
        showTextBalloon(isLeft)
      end
      -- * function part for Hide Cursor while Display Text * --
      if not game.CurrentScene.IsMenu and
        not 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 onTextStopped(text)
      -- * function part for speechbubbles * --
      local currentCharacter = game.CurrentCharacter
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters then
        local isLeft = owner:getName() == currentCharacter:getName()
        hideTextBalloon(isLeft)
      end
      -- * function part for Hide Cursor while Display Text * --
      if handle_cutscene_txt then
          game.HideCursor = false
          handle_cutscene_txt = false
      end
      -- + --
      game.AlwaysAllowSkipText = false
    end



    function getBaloon(isLeft)
      if isLeft then
    -- when Hero(currentCharacter) talks --- show no speechbubble ------
        return getObject("")
      end
    --- when other characters talk ---- show speechbubble ---LuaPath --Interfaces.Sprechblase---
      return getObject("Interfaces[Sprechblase]")
    end


    function showTextBalloon(isLeft)
      local baloon = getBaloon(isLeft)
      baloon.InterfaceVisible = true
      baloon.InterfaceVisibility = 100
    end

    function hideTextBalloon(isLeft)
      local baloon = getBaloon(isLeft)
      baloon.InterfaceVisible = false
      baloon.InterfaceVisibility = 0
    end

    --[[https://www.visionaire-studio.net/forum/thread/dialog-interface-mit-abbild-der-personen-add-character-images-to-dialogs/#49215]]--
    --https://www.visionaire-studio.net/forum/thread/skip-protection-of-displayed-text/#52563--
    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
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76

    Newbie

    4 Posts


Write post