Hey! Sorry for the stupid question, but I'm trying to display a tooltip at the position of the virtual cursor but I can't figure out how to access its position.
Viewing post in Need Support? Post here!
No worries! Simplest way will be to add this function somewhere:
def get_vc_position(id):
"""Get the position of the virtual cursor with the provided ID."""
d = renpy.get_widget(None, id)
return d.get_cursor_coords()And then you can give your virtual cursor an ID and pass it into that function to get the current coordinates.
Thanks so much! I've just tried this and am getting the error:
AttributeError: 'NoneType' object has no attribute 'get_cursor_coords'
I called the function with:
vc = VirtualCursor()
renpy.show_screen("locked_tooltip", data.title, vc.get_vc_position(id), data.unlocked)
Sorry if i'm missing something super obvious!
To be clear - the point is to give an existing virtual cursor an id like id "whatever" and you pass in "whatever" to the function I wrote. Do not create a random virtual cursor and try to get coordinates from it - the one you made in your example code isn't shown anywhere and thus any information it had would be entirely useless, even discounting the fact that the function I made wants an ID and not a VirtualCursor object. If you already have a Python VirtualCursor object defaulted instead of declared via virtual_cursor in a screen, then just call get_cursor_coords() on your VirtualCursor object. Again, do not just create a random VirtualCursor object - this must be the virtual cursor you are already using.