Any way to assign sprite location to Galv Screen Buttons?

I'm playing with Galv Screen Buttons to be able to make a clickable item that pops up next to the pc sprite. As far as I can tell the plugin only allow you a fixed x,y location on the screen for the button img, wondering if anyone has figured out a workaround to be able to call on the sprite's location and then place the img slightly to the side of it?

Plugin here: https://galvs-scripts.com/2016/11/29/mv-screen-buttons/
Do you want the button to move continuously with the sprite? If so, you'd have to keep checking for the sprite's location and updating the button position (probably in a parallel process), and that's more complicated and not something I can help with.

However, if the button will be displayed while the sprite is standing still and will be removed after the player clicks on it, that's probably doable though I haven't tried it myself. You can get the player character's or an event sprite's Screen X and Screen Y under Control Variables > Character > Player > Screen X or Screen Y, and then just modify the x and y of the button position accordingly when using Galv's addButton script call.

E.g., let's say you set Variable 1 to the screen X and variable 2 to the screen Y. if you want the button's x-position to be to the left of the sprite, use $gameVariables.value(1) - 48 as the x and $gameVariables.value(2) as the y. You can modify 48 to a bigger or smaller number depending on how far left you want it to be.

Note that you may want to account for cases when the sprite is at the edge of the map (i.e., if it's on the left edge, a button that's added to the left of the sprite won't be visible).
Do you want the button to move continuously with the sprite? If so, you'd have to keep checking for the sprite's location and updating the button position (probably in a parallel process), and that's more complicated and not something I can help with.

However, if the button will be displayed while the sprite is standing still and will be removed after the player clicks on it, that's probably doable though I haven't tried it myself. You can get the player character's or an event sprite's Screen X and Screen Y under Control Variables > Character > Player > Screen X or Screen Y, and then just modify the x and y of the button position accordingly when using Galv's addButton script call.

E.g., let's say you set Variable 1 to the screen X and variable 2 to the screen Y. if you want the button's x-position to be to the left of the sprite, use $gameVariables.value(1) - 48 as the x and $gameVariables.value(2) as the y. You can modify 48 to a bigger or smaller number depending on how far left you want it to be.

Note that you may want to account for cases when the sprite is at the edge of the map (i.e., if it's on the left edge, a button that's added to the left of the sprite won't be visible).

Thanks, this 'sort of' works. It's weird actually, I've just been testing it as $gameVariables.value(x) to get it working, and for some reason the button does not locate exactly on the event location, it's offset to the right and down a fair bit. And I can't for the life of me figure out why. I'm attempting to get it to appear next to an NPC event, that I will eventually have on a movement route. At the moment it's just static while I figure out how to get this to work.

Screen Shot 2020-03-21 at 12.46.35 am.png

The NPC event (event 001) is the purple haired sprite. Super weird that the image is so offset.

This is what I have in the event (couldn't get the whole script call in one screen grab, sorry!)

Screen Shot 2020-03-21 at 12.37.52 am.png

Screen Shot 2020-03-21 at 12.38.07 am.png


I mean, logically the button should appear right over the NPC right? I'm not sure why it's offset...
Based on this post, Screen X and Y "point at the middle of the bottom of your character's sprite". So it's not surprising that the image appears below the sprite (since the x and y in Galv's script call refer to the upper left position of the image). If your "Event!" image has a small transparent border, that's probably the reason why it's looks offset to the right. If not, you might want to show us just the "Event!" image.
Based on this post, Screen X and Y "point at the middle of the bottom of your character's sprite". So it's not surprising that the image appears below the sprite (since the x and y in Galv's script call refer to the upper left position of the image). If your "Event!" image has a small transparent border, that's probably the reason why it's looks offset to the right. If not, you might want to show us just the "Event!" image.
Ah gotcha, ok, I'll just manually shift it to the right spot, just wanted to make sure I was doing it right. Thanks for your help!

Original thread: https://forums.rpgmakerweb.com/threads/any-way-to-assign-sprite-location-to-galv-screen-buttons.119246/