Need help grabbing a token
So... I am having another issue... suprise suprise... lol
I am trying to add a functionality to move a specific token when you press the mouseclick down on a token...
The problem I am having is, I can select the token using
Code:
image.selectToken(token, true);
but when I move the mouse with the button still held... it still moves the originally pressed on token...
code thus far... I kept it simple to try to isolate the function at this time...
Code:
function onInit()
Token.onClickDown = onClickDown;
end
function onClickDown(token, button, image)
if not Input.isControlPressed() and (button == 1) then
image.clearSelectedTokens();
local imgTokens = image.getTokens();
for _, v in pairs(imgTokens) do
local nodeChar = CombatManager.getCTFromToken(v);
local sClass, sRecord = DB.getValue(nodeChar, "link", "", "");
if sClass == "charsheet" and sRecord ~= "" then
local sOwner = DB.getOwner(sRecord);
if sOwner == "Players" then
Debug.console("Players Owned Token = ", v);
image.selectToken(v, true);
end
end
end
end
end
so in this example, when the left mouse button is pressed onto a token, I want the token owned by "Players" to be selected (grabed by mouse) and then that token moved when the mouse moves...
I do not want the token originally pressed onto to move... I want that token to not be grabbed...
The correct token in the Debug.console in the script is coming up as "selected"... but it is not being dragged by the mouse movement...
I am at a bit of a loss... I have tried to Debug.console(dragdata); and put that in a onDrag, onDragStart, onDrop, and onDragEnd... and dragdata always comes up nil... so I am kind of at a loss...
Any help would be appreciated!
~Diablobob