PF2E Playlist
  1. #1

    Duplicate tokens being created onDrop by player

    So a little background of the issue:
    When a GM does a token drop and the size/name/other properties are adjusted, everything works fine, as the token ID is accessible.

    When a player does a token drop, the token proto and position is transferred to the GM to edit the size/name/other properties. When this happens, on most maps (not all for some reason, however fully repeatable with vault maps) a duplicate token is created.

    Findings:
    I hunted down the reason for this, my script adds another token if the original token cannot be found and adjusts that one. On the surface it doesnít seam like a big issue.

    To resolve, I had snap to grid turned on, and converted the position coordinates passed along to the imageControlís snap to grid function to adjust the coordinates.

    Issue description:
    What I uncovered was that the x coordinates were correct, but the y coordinates were slightly off. To verify this I also put a known existing token x,y position (already snapped to grid) through the function.

    What I found is, although the already snapped token was present, itís adjusted coordinates had a different Y value as well.

    I do not know why an already positioned token position would change when position coordinates are placed through the imageControlís snap to grid function.

    I adjusted my script to compensate correctly, but it does not seam like this is expected behavior.

  2. #2
    It sounds like the duplicate token is created by your script, because it can't find the token at the exact location being returned. Is this correct?

    Could you create a small extension that recreates the issue specifically without any extra functionality?

    If I can get specifically at the y-axis discrepancy you are mentioning, it should be fairly straight-forward to dig into the code. However, right now, I'm not very clear where the issue is at exactly.

    Thanks,
    JPG

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    It sounds like the duplicate token is created by your script, because it can't find the token at the exact location being returned. Is this correct?

    Could you create a small extension that recreates the issue specifically without any extra functionality?

    If I can get specifically at the y-axis discrepancy you are mentioning, it should be fairly straight-forward to dig into the code. However, right now, I'm not very clear where the issue is at exactly.

    Thanks,
    JPG

    I will be making the quick extension to show what Iím talking about tomorrow... sorry for the delay, life has been hectic

  4. #4

    Example Extension

    Sorry for the crazy delay. Life has been hectic to say the least. So I made the example extension to show what I was talking about.

    Activate the extension, open a map with tokens on it, left click on a token, and the chat debug messages output the token info, token x,y position info, and the token x,y snapToGrid info.

    The Y coordinate for the snapToGrid is always 2 off from the token info and the token getPosition value.

    I know this seam minor, but I have seen in many cases that the snapToGrid is used VERY commonly in script calculations.

    the entire script file is as such:

    Code:
    function onInit()
    	Token.onClickDown = onClickDown;
    end
    
    function onClickDown(token, button, image)
    	Debug.chat("token = ", token);
    		
    	local xtPosi, ytPosi = token.getPosition();
    	Debug.chat("token x = ", xtPosi);
    	Debug.chat("token y = ", ytPosi);	
    		
    	local ImageCrtl, ImageWnd, BWindowOpened = ImageManager.getImageControl(token, false);
    	local x,y = ImageCrtl.snapToGrid(xtPosi, ytPosi);
    	Debug.chat("snap to grid x = ", x);
    	Debug.chat("snap to grid y = ", y);
    end
    Attached Files Attached Files
    Last edited by Diablobob; May 8th, 2021 at 04:48.

  5. #5
    Thanks for the extension. By helping pinpoint the issue, I was able to focus my efforts on the culprit API (snapToGrid). The API and internal structures use different axes, and this API function was not translating the point before snapping which was causing the issue. I'll submit a fix for the next build.

    Regards,
    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in