How to start a dialog only when scrolling environment stop?

  • #1, by nerdMonday, 12. November, 12:36 3 weeks ago
    How to start a dialog only when scrolling  environment stop?

    Newbie

    73 Posts


  • #2, by AFRLmeMonday, 12. November, 13:13 3 weeks ago
    You could do something along the lines of this...


    Start off by creating an if lua result action part, in which you should query if both horizontal and vertical scrolling is false, if both are false then it should return true; else it should return false.

    if game.ScrollDirectionHorizontal == 0 and game.ScrollDirectionVertical == 0 then
      return true
    else
      return false
    end
    1
    2
    3
    4
    5


    After that you should insert the action parts you want to execute, then add an else statement after your action parts, followed by a jump to x action action part, make sure it's set to absolute & that you are jumping back to whatever action part number the if lua result action part is. Finally add an end if action part to close off the if query.

    Quick note: what we have created here is a self contained loop that will prevent any action parts after the block from being executed until it's allowed to end the if query block.

    P.S: I have not tested this out, so it may or may not work.

    Imperator

    6366 Posts

  • #3, by nerdMonday, 12. November, 18:21 3 weeks ago
    You could do something along the lines of this...


    Start off by creating an if lua result action part, in which you should query if both horizontal and vertical scrolling is false, if both are false then it should return true; else it should return false.

    if game.ScrollDirectionHorizontal == 0 and game.ScrollDirectionVertical == 0 then
      return true
    else
      return false
    end
    1
    2
    3
    4
    5


    After that you should insert the action parts you want to execute, then add an else statement after your action parts, followed by a jump to x action action part, make sure it's set to absolute & that you are jumping back to whatever action part number the if lua result action part is. Finally add an end if action part to close off the if query.

    Quick note: what we have created here is a self contained loop that will prevent any action parts after the block from being executed until it's allowed to end the if query block.

    P.S: I have not tested this out, so it may or may not work.

    The dialog won't start unless I click another time on the npc once the camera stops. Is there a way to make the dialog start automatically once the camera stops?
    And btw thank you for the code

    Newbie

    73 Posts

  • #4, by nerdMonday, 12. November, 18:27 3 weeks ago
    You could do something along the lines of this...


    Start off by creating an if lua result action part, in which you should query if both horizontal and vertical scrolling is false, if both are false then it should return true; else it should return false.

    if game.ScrollDirectionHorizontal == 0 and game.ScrollDirectionVertical == 0 then
      return true
    else
      return false
    end
    1
    2
    3
    4
    5


    After that you should insert the action parts you want to execute, then add an else statement after your action parts, followed by a jump to x action action part, make sure it's set to absolute & that you are jumping back to whatever action part number the if lua result action part is. Finally add an end if action part to close off the if query.

    Quick note: what we have created here is a self contained loop that will prevent any action parts after the block from being executed until it's allowed to end the if query block.

    P.S: I have not tested this out, so it may or may not work.
    I was thinking since I m using this code to center the text
    -- let's create the function which sets the position of displayed text
    function setTextPosHook(text)
     -- if text owner is a character then...
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      text:setValue(VTextPosition, {x=2325, y=100})
      return true
     end
    end

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    Is there a way to make automatically calculate the center of the screen while the text is showing? So the text will be always centered when the environment is scrolling?

    Newbie

    73 Posts

  • #5, by AFRLmeMonday, 12. November, 18:33 3 weeks ago
    function txtPos(text)
      if text.Owner:getId().tableId == eCharacters then -- if character text
        text:setValue(VTextPosition, {x = game.ScrollPosition.x + (game.WindowResolution.x / 2), y = game.ScrollPosition.y + (game.WindowResolution.y - 85)}) -- define the new text position
        return true -- update text position
     end
     return false -- else don't update text position
    end

    registerHookFunction("setTextPosition", "txtPos") -- define the hook function for handling text position
    1
    2
    3
    4
    5
    6
    7
    8
    9

    offset y as needed or / 2 instead to center text on both x & y axis.

    P.S: please could you stop quoting every message. It's making it hard to read. Cheers.

    Imperator

    6366 Posts

  • #6, by nerdMonday, 12. November, 20:39 3 weeks ago
    Solved. Thank you.

    Newbie

    73 Posts

  • #7, by AFRLmeMonday, 12. November, 21:35 3 weeks ago
    no worries. both issues?

    Imperator

    6366 Posts

  • #8, by nerdFriday, 16. November, 09:05 3 weeks ago
    no worries. both issues?

    I solved using the code that centers the text without waiting for the camera to stop scrolling, it works great.

    Newbie

    73 Posts

Write post