shdwjk / Roll20API

A collection of all my production ready Roll20 API scripts.
83 stars 73 forks source link

TokenMod - Added missing directional low light fields #29

Closed Zierman closed 3 years ago

Zierman commented 3 years ago

This adds the following fields to TokenMod:

For whatever reason, changing these properties won't change how anything renders. Because of this, no changes are visible in the help message as it would likely confuse end users. There are commented out sections in the source that can be uncommitted to update the help message when the feature will work for the end user. These should be easy to find because they are tagged with //TODO: add when the Roll20 app renders directional low light properties correctly

fixes #28

Zierman commented 3 years ago

Simplistic Manual Testing

In this test I check turning on and setting the added properties.

Methodology

I ran the updated TokenMod script along with this observation script:

on("chat:message", function(msg) {
    if(typeof(msg.selected) != "undefined")
        msg.selected.forEach(function(t) {
            let tType = t._type
            if(tType != "graphic") {
                return;
            }
            let o = getObj("graphic", t._id);
            log(o);
        });
});

I made observations by sending a dummy API message to generate a log message displaying the selected object. Observations where made before and after issuing the command.

Before any commands:

Visual Observation: image

JSON Observation:

{
   "_id":"-MIwSKZ3QACaiSs0NH8O",
   "_pageid":"-LImQad4o69ghEym3_9e",
   "left":315,
   "top":805,
   "width":70,
   "height":70,
   "rotation":0,
   "layer":"objects",
   "isdrawing":false,
   "flipv":false,
   "fliph":false,
   "imgsrc":"/images/character.png",
   "name":"character",
   "gmnotes":"",
   "controlledby":"",
   "bar1_value":"",
   "bar1_max":"",
   "bar1_link":"",
   "bar2_value":"",
   "bar2_max":"",
   "bar2_link":"",
   "bar3_value":"",
   "bar3_max":"",
   "bar3_link":"",
   "represents":"-MI1Q0wJnuW-ZgJwTN6j",
   "aura1_radius":"",
   "aura1_color":"#FFFF99",
   "aura1_square":false,
   "aura2_radius":"",
   "aura2_color":"#59E594",
   "aura2_square":false,
   "tint_color":"transparent",
   "statusmarkers":"",
   "showname":false,
   "showplayers_name":false,
   "showplayers_bar1":false,
   "showplayers_bar2":false,
   "showplayers_bar3":false,
   "showplayers_aura1":false,
   "showplayers_aura2":false,
   "playersedit_name":true,
   "playersedit_bar1":true,
   "playersedit_bar2":true,
   "playersedit_bar3":true,
   "playersedit_aura1":true,
   "playersedit_aura2":true,
   "light_radius":"",
   "light_dimradius":"",
   "light_otherplayers":false,
   "light_hassight":false,
   "light_angle":"",
   "light_losangle":"",
   "light_multiplier":1,
   "adv_fow_view_distance":"",
   "sides":"",
   "currentSide":0,
   "lastmove":"175,805",
   "_type":"graphic",
   "_subtype":"token",
   "_cardid":"",
   "has_bright_light_vision":true,
   "has_night_vision":false,
   "night_vision_tint":"",
   "night_vision_distance":0,
   "emits_bright_light":true,
   "bright_light_distance":5,
   "emits_low_light":true,
   "low_light_distance":10,
   "has_limit_field_of_vision":false,
   "limit_field_of_vision_center":0,
   "limit_field_of_vision_total":0,
   "has_limit_field_of_night_vision":false,
   "limit_field_of_night_vision_center":0,
   "limit_field_of_night_vision_total":0,
   "has_directional_bright_light":true,
   "directional_bright_light_total":30,
   "directional_bright_light_center":0,
   "has_directional_low_light":false,
   "directional_low_light_total":0,
   "directional_low_light_center":0
}

After Compound Command

Command Used: !token-mod --on has_directional_low_light --set directional_low_light_total#10 directional_low_light_center#20:

Expected Visual Observation: The light out to 5ft should remain unchanged, the light beyond that radius should have decreased angle of light to 10 degrees and it should be rotated 20 degrees.

Actual Visual Observation: No change. image

Expected JSON Observation:

{
   "_id":"-MIwSKZ3QACaiSs0NH8O",
   "_pageid":"-LImQad4o69ghEym3_9e",
   "left":315,
   "top":805,
   "width":70,
   "height":70,
   "rotation":0,
   "layer":"objects",
   "isdrawing":false,
   "flipv":false,
   "fliph":false,
   "imgsrc":"/images/character.png",
   "name":"character",
   "gmnotes":"",
   "controlledby":"",
   "bar1_value":"",
   "bar1_max":"",
   "bar1_link":"",
   "bar2_value":"",
   "bar2_max":"",
   "bar2_link":"",
   "bar3_value":"",
   "bar3_max":"",
   "bar3_link":"",
   "represents":"-MI1Q0wJnuW-ZgJwTN6j",
   "aura1_radius":"",
   "aura1_color":"#FFFF99",
   "aura1_square":false,
   "aura2_radius":"",
   "aura2_color":"#59E594",
   "aura2_square":false,
   "tint_color":"transparent",
   "statusmarkers":"",
   "showname":false,
   "showplayers_name":false,
   "showplayers_bar1":false,
   "showplayers_bar2":false,
   "showplayers_bar3":false,
   "showplayers_aura1":false,
   "showplayers_aura2":false,
   "playersedit_name":true,
   "playersedit_bar1":true,
   "playersedit_bar2":true,
   "playersedit_bar3":true,
   "playersedit_aura1":true,
   "playersedit_aura2":true,
   "light_radius":"",
   "light_dimradius":"",
   "light_otherplayers":false,
   "light_hassight":false,
   "light_angle":"",
   "light_losangle":"",
   "light_multiplier":1,
   "adv_fow_view_distance":"",
   "sides":"",
   "currentSide":0,
   "lastmove":"175,805",
   "_type":"graphic",
   "_subtype":"token",
   "_cardid":"",
   "has_bright_light_vision":true,
   "has_night_vision":false,
   "night_vision_tint":"",
   "night_vision_distance":0,
   "emits_bright_light":true,
   "bright_light_distance":5,
   "emits_low_light":true,
   "low_light_distance":10,
   "has_limit_field_of_vision":false,
   "limit_field_of_vision_center":0,
   "limit_field_of_vision_total":0,
   "has_limit_field_of_night_vision":false,
   "limit_field_of_night_vision_center":0,
   "limit_field_of_night_vision_total":0,
   "has_directional_bright_light":true,
   "directional_bright_light_total":30,
   "directional_bright_light_center":0,
   "has_directional_low_light":true,
   "directional_low_light_total":10,
   "directional_low_light_center":20
}

Actual JSON Observation: As expected.

{
   "_id":"-MIwSKZ3QACaiSs0NH8O",
   "_pageid":"-LImQad4o69ghEym3_9e",
   "left":315,
   "top":805,
   "width":70,
   "height":70,
   "rotation":0,
   "layer":"objects",
   "isdrawing":false,
   "flipv":false,
   "fliph":false,
   "imgsrc":"/images/character.png",
   "name":"character",
   "gmnotes":"",
   "controlledby":"",
   "bar1_value":"",
   "bar1_max":"",
   "bar1_link":"",
   "bar2_value":"",
   "bar2_max":"",
   "bar2_link":"",
   "bar3_value":"",
   "bar3_max":"",
   "bar3_link":"",
   "represents":"-MI1Q0wJnuW-ZgJwTN6j",
   "aura1_radius":"",
   "aura1_color":"#FFFF99",
   "aura1_square":false,
   "aura2_radius":"",
   "aura2_color":"#59E594",
   "aura2_square":false,
   "tint_color":"transparent",
   "statusmarkers":"",
   "showname":false,
   "showplayers_name":false,
   "showplayers_bar1":false,
   "showplayers_bar2":false,
   "showplayers_bar3":false,
   "showplayers_aura1":false,
   "showplayers_aura2":false,
   "playersedit_name":true,
   "playersedit_bar1":true,
   "playersedit_bar2":true,
   "playersedit_bar3":true,
   "playersedit_aura1":true,
   "playersedit_aura2":true,
   "light_radius":"",
   "light_dimradius":"",
   "light_otherplayers":false,
   "light_hassight":false,
   "light_angle":"",
   "light_losangle":"",
   "light_multiplier":1,
   "adv_fow_view_distance":"",
   "sides":"",
   "currentSide":0,
   "lastmove":"175,805",
   "_type":"graphic",
   "_subtype":"token",
   "_cardid":"",
   "has_bright_light_vision":true,
   "has_night_vision":false,
   "night_vision_tint":"",
   "night_vision_distance":0,
   "emits_bright_light":true,
   "bright_light_distance":5,
   "emits_low_light":true,
   "low_light_distance":10,
   "has_limit_field_of_vision":false,
   "limit_field_of_vision_center":0,
   "limit_field_of_vision_total":0,
   "has_limit_field_of_night_vision":false,
   "limit_field_of_night_vision_center":0,
   "limit_field_of_night_vision_total":0,
   "has_directional_bright_light":true,
   "directional_bright_light_total":30,
   "directional_bright_light_center":0,
   "has_directional_low_light":true,
   "directional_low_light_total":10,
   "directional_low_light_center":20
}

Conclusion

Turning on has_directional_low_light and setting directional_low_light_center and directional_low_light_total make the expected changes to the token's properties but the change is not reflected in the graphically rendered representation in the app.

shdwjk commented 3 years ago

Hi @Zierman, thanks for submitting this. I don't actually develop in this repo, I just use it for deploying updated and completed versions of code from my development repo. I think I've addressed what you have here in my recent releases, let me know if I missed anything.

Zierman commented 3 years ago

Hi @Zierman, thanks for submitting this. I don't actually develop in this repo, I just use it for deploying updated and completed versions of code from my development repo. I think I've addressed what you have here in my recent releases, let me know if I missed anything.

I'm sorry for the delayed response. I'm glad to hear that you think that you've addressed this issue in your recent releases. I have not been running any Roll20 games for a while and don't have immediate plans to resume. As such, I'm unlikely to be testing TokenMod anytime soon. I'm sure I'll be looking to use TokenMod in future games (whenever I get back into running games on Roll20), and at that time I'll share any constructive feedback with you. 🙂

shdwjk commented 3 years ago

Sounds good!