maptool icon indicating copy to clipboard operation
maptool copied to clipboard

[Bug 1.11.5]: movedOverPoints(points,path) class error

Open aliasmask opened this issue 3 years ago • 1 comments

Describe the Bug

When I pass an array of points and a path I get an exception error

java.lang.ClassCastException: class com.google.gson.JsonArray cannot be cast to class java.lang.String (com.google.gson.JsonArray is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') error executing expression movedOverPoints(points,path).

To Reproduce

This is a bit complicated, but within the onTokenMove process I run this code to test

[h: id = findDrawings(getCurrentMapName(),"Whitecap Inn Street")]
[H: info = getDrawingInfo(getCurrentMapName(),id)]
[H: points = json.get(info,"path")]
[H: p.pause("path","points")]

[dialog("D"): {
[r: movedOverDrawing(getCurrentMapName(),id,path)]<br>
[r: movedOverPoints(points,path)]
}]

This is example info from p.pause function

path
--
[{"x":450,"y":350},{"x":500,"y":350},{"x":550,"y":350}]
points
[{"x":350.0,"y":400.0},{"x":850.0,"y":400.0},{"x":850.0,"y":500.0},{"x":950.0,"y":500.0},{"x":950.0,"y":650.0},{"x":1050.0,"y":650.0},{"x":1050.0,"y":1050.0},{"x":350.0,"y":1050.0},{"x":350.0,"y":400.0}]

In the above example, there should be no crossover.

Expected Behaviour

No exception error when given valid path and points.

Screenshots

No response

MapTool Info

1.11.5

Desktop

Window 10

Additional Context

I pass "path" instead using getLastPath() or leaving it blank to go to default because that info is cleared as soon as I put tokens.denyMove = 1 and then defer all my token movements. When the deferred macro runs, lastPath has already been cleared.

aliasmask avatar Mar 05 '22 14:03 aliasmask

If you need more info you could open a campaign with the BoT and within lib:OnTokenMove on the BASE map it has the macro moveVBLToken. I put the above code at the bottom of that. Depending on FW, p.pause() can be written as pause(). You will have to activate vbl movement blocking in the BoT settings.

aliasmask avatar Mar 05 '22 14:03 aliasmask

+1 Also on 1.11.5 Win 10

[h: pts1 = '[{"x":920,"y":148},{"x":1011,"y":106},{"x":1039,"y":167},{"x":949,"y":210}]']
[h: pts2 = '[{"x":288,"y":244},{"x":388,"y":244},{"x":388,"y":344},{"x":288,"y":344}]']
[r: x=movedOverPoints(pts1, pts2)]

The roll options R and H produce the java.lang.ClassCastException: removing them or changing to E or T and it works. e.g. [x=movedOverPoints(pts1, pts2)]

bubblobill avatar Jan 20 '23 10:01 bubblobill