How to start a dialog only when scrolling environment stop?

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

    Forum Fan

    147 Posts


  • #2, by afrlmeMonday, 12. November 2018, 13:13 5 years 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 


    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

    7278 Posts

  • #3, by nerdMonday, 12. November 2018, 18:21 5 years 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 


    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

    Forum Fan

    147 Posts

  • #4, by nerdMonday, 12. November 2018, 18:27 5 years 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 


    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
    
    

    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?

    Forum Fan

    147 Posts

  • #5, by afrlmeMonday, 12. November 2018, 18:33 5 years 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

    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

    7278 Posts

  • #6, by nerdMonday, 12. November 2018, 20:39 5 years ago
    Solved. Thank you.

    Forum Fan

    147 Posts

  • #7, by afrlmeMonday, 12. November 2018, 21:35 5 years ago
    no worries. both issues?

    Imperator

    7278 Posts

  • #8, by nerdFriday, 16. November 2018, 09:05 5 years 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.

    Forum Fan

    147 Posts