Script for cursor position

  • #1, by markus-creativeWednesday, 01. September 2021, 17:30 2 years ago
    Hello!

    I would like to set the cursor to a specific position before each dialog. In my case to the position 640/400. I know that this can be done with setCursorPos({x=640, y=400}).

    However, I don't want to do it every time before each dialog, but write a definition script once, which sets the cursor automatically to this position before each dialog.

    How should the definition script look like? Can anyone help me?

    Any help would be great.



    Newbie

    47 Posts


  • #2, by PanSFriday, 03. September 2021, 16:46 2 years ago
    As far as I know there is no dialog start event. So you have check in a main loop if there is a dialogbox. For Example:

    local dialogstarted = false
    
    function MainLoop()
      
      if game.Dialog:isEmpty() then --no dialog running
    
        if dialogstarted == true then
          dialogstarted = false
        end
    
      else
    
        if dialogstarted == false then --pretend to set cursor every frame to the position
          setCursorPos({x=640, y=400})
          dialogstarted = true
        end
    
      end
    
    end
    
    registerEventHandler("mainLoop", "MainLoop")
    

    Newbie

    73 Posts

  • #3, by markus-creativeSunday, 05. September 2021, 14:14 2 years ago
    As far as I know there is no dialog start event. So you have check in a main loop if there is a dialogbox. For Example:



    Thank you very much. I will try it.

    Newbie

    47 Posts