p4535992 / foundryvtt-arms-reach

FoundryVTT Door little Utilities, Arms Reach for door
MIT License
3 stars 5 forks source link

Integration with drawings #30

Closed Mavendorn closed 2 years ago

Mavendorn commented 3 years ago

Hi I find myself using foundry's drawings with the "@Trigger[click]" feature of the module Trigger Happy to create buttons, levers and other interactive things on the scene. If its possible can you add a feature to prevent that clicking interaction with drawings if the token is not in range of the drawing? trigger happy may need a hook for arms reach to intercept the trigger

p4535992 commented 2 years ago

I was unable to automate this function, what I did was add an API for calling features from a macro. See the README for some examples. Some feedbak is welcome

Mavendorn commented 2 years ago

This looks like it will work, but i had some issues with it. The API for ReachableById works great, i was able to have the trigger happy trigger call an intercept macro like shown below, (i wasn't sure the best way to implement Token and userId so i just used what i thought it needed as seen below let me know if there are better ways of doing this.)

if (game.armsReach.isReachableByID(canvas.tokens.controlled[0],"lJaAThjw9LdjrOtE",game.user.id)){
    //run trigger macro here
    return "is reachable";
}else{
    //return without using macro
    return "not reachable";
}

I ran into an issue with the ReachableByTag feature. Tagger?.getByTag(tag) returns a promise and the result placeableObjects[0] can't be directly referenced as your code is written.

p4535992 commented 2 years ago

sorry for the delay , the getByTag method should be fixed now, i didn't notice was a async method, The userID is a optional value, for now is not used from the api, i hope to add in the future some filter so a specific actor for a specific user has some limitation.

Mavendorn commented 2 years ago

This feature feels good with my tests, nice implementation! I also saw today tagger was updated to change the getByTag function back to an array instead of a promise. I assume that will break this module again so i've not updated tagger yet.

p4535992 commented 2 years ago

Ty for notice that, should be fixed "again" with version 2.1.4