Cursorposition abfragen

  • #1, by constantinFriday, 22. December 2017, 18:10 2 years ago
    Ich weiß, dass es dazu bereits Infos gibt, aber auch die Beispiele, die hier (https://wiki.visionaire-tracker.net/wiki/GetCursorPos) angegeben sind, scheinen nicht zu funktionieren. 
    Bitte: Wie kann ich die Cursorposition abfragen? 

    Forum Fan

    167 Posts


  • #2, by afrlmeFriday, 22. December 2017, 18:12 2 years ago
    Cursor position of the current viewport or cursor position in the entire scene?

    Imperator

    6805 Posts

  • #3, by constantinFriday, 22. December 2017, 18:14 2 years ago
    of the entire screen.

    Forum Fan

    167 Posts

  • #4, by afrlmeFriday, 22. December 2017, 18:23 2 years ago
    getCursorPos() contains an X & a Y table, so you have to return those, it also only returns the position on the current viewport (scrollposition), which means if you want to check if the cursor is in a certain position in the entire scene that you need to include the current scrollposition value too.

    local pos = { x = (game.ScrollPosition.x + getCursorPos().x), y = (game.ScrollPosition.y + getCursorPos().y) }

    if pos.x == 500 and pos.y == 700 then
     -- do something
    end
    1
    2
    3
    4
    5

    Maybe something along the lines of that.

    Imperator

    6805 Posts

  • #5, by constantinFriday, 22. December 2017, 18:29 2 years ago
    thank you so far. is there a way to store the positions in a variable?
    i tried 

    Values["cursorx"] = pos.x 

    but it doesnt work.

    Forum Fan

    167 Posts

  • #6, by sebastianFriday, 22. December 2017, 19:27 2 years ago
    thank you so far. is there a way to store the positions in a variable?
    i tried 

    Values["cursorx"] = pos.x 

    but it doesnt work.
    A Value has more fields than you might see at first place: https://www.visionaire-studio.com/luadocs/#values-20

    Use Values["cursorx"].Int = pos.x 

    Thread Captain

    2336 Posts

  • #7, by constantinFriday, 22. December 2017, 19:59 2 years ago
    Oh no. Sorry. I am still new to lua. Thanks for the help.

    Forum Fan

    167 Posts

Write post