Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Created Token not Visible

1731966474

Edited 1732025753
Overdriven Pub
Pro
API Scripter
I have an API script that is working perfectly fine on another table (an LC); however, it encountered an issue that needed to be fixed on a home game table.  The issue that needed to be fixed  (I'm doubtful it's important) was that when a GM placed a token on the map and enacted the script, the token would report back that the controlledby field was empty.  After fixing this, the token that was created (on another page) is nowhere to be found. I can see that the token was created, and I've checked to ensure that the page, location, and layer are appropriate.  The console log shows that the token was created and lists the fields for that object. The API I've created is a portal API that, when the player enters a portal based on its dimensions and location, the token the player moved there is deleted, the player is moved to another page, and an identical token (with the exception of modifying the imgsrc to align with imgsrc restrictions) is placed on the destination portal. Here's the code block that I'm working through: on('change:graphic',function(obj){ if(obj.get('layer') === "objects"&&obj.get('bar3_value')!=='portal'&&findObjs({id:obj.get('represents')})[0].get('controlledby')!==''){ log('Obj: '+obj.get('name') + ': ' + obj.get('imgsrc')) var portals = findObjs({type: 'graphic',bar3_value: 'portal', pageid: obj.get('pageid')}) for (var i = 0; i < portals.length; i++){ if(distance(obj,portals[i])<portals[i].get('bar1_value')/2){ var dest = findObjs({id: portals[i].get('bar2_value')})[0] roster = Campaign().get('playerspecificpages') if(!roster){ roster = {} } log(roster) var obj2 = findObjs({id: obj.get('represents'), type: 'character'})[0] log(obj2) log("Obj ID: "+obj2.get('controlledby')) log(Campaign().get('playerspecificpages')) log("Control: "+obj2.get('controlledby')) if(dest.get('pageid')===Campaign().get('playerpageid')){ delete roster[obj2.get('controlledby')] if (Object.keys(roster).length==0){ roster = false } Campaign().set('playerspecificpages',false) Campaign().set('playerspecificpages',roster) } if(dest.get('pageid')!==obj.get('pageid')){ delete roster[obj2.get('controlledby')] if(dest.get('pageid')!==Campaign().get('playerpageid')){ roster[obj2.get('controlledby')] = dest.get('pageid') } if (Object.keys(roster).length==0){ roster = false } log("New Roster:") log(roster) Campaign().set('playerspecificpages',false) Campaign().set('playerspecificpages',roster) var imgsrc = obj.get('imgsrc').split('med') if(imgsrc.length>1){ imgsrc = imgsrc[0]+'thumb'+imgsrc[1] }else{ imgsrc = imgsrc[0] } imgsrc = imgsrc.split('max') if(imgsrc.length>1){ imgsrc = imgsrc[0]+'thumb'+imgsrc[1] }else{ imgsrc = imgsrc[0] } log(imgsrc) newobj = createObj('graphic', { pageid: dest.get('pageid'), left: dest.get('left'), top: dest.get('top'), width: obj.get('width'), height: obj.get('height'), rotation: obj.get('rotation'), layer: obj.get('layer'), isdrawing: obj.get('isdrawing'), flipv: obj.get('flipv'), fliph: obj.get('fliph'), imgsrc: imgsrc, name: obj.get('name'), gmnotes: obj.get('gmnotes'), controlledby: obj2.get('controlledby'), bar1_value: obj.get('bar1_value'), bar1_max: obj.get('bar1_max'), bar1_link: obj.get('bar1_link'), bar2_value: obj.get('bar2_value'), bar2_max: obj.get('bar2_max'), bar2_link: obj.get('bar2_link'), bar3_value: obj.get('bar3_value'), bar3_max: obj.get('bar3_max'), bar3_link: obj.get('bar3_link'), represents: obj.get('represents'), aura1_radius: obj.get('aura1_radius'), aura1_color: obj.get('aura1_color'), aura1_square: obj.get('aura1_square'), aura2_radius: obj.get('aura2_radius'), aura2_color: obj.get('aura2_color'), aura2_square: obj.get('aura2_square'), tint_color: obj.get('tint_color'), statusmarkers: obj.get('statusmarkers'), showname: obj.get('showname'), showplayers_name: obj.get('showplayers_name'), showplayers_bar1: obj.get('showplayers_bar1'), showplayers_bar2: obj.get('showplayers_bar2'), showplayers_bar3: obj.get('showplayers_bar3'), showplayers_aura1: obj.get('showplayers_aura1'), showplayers_aura2: obj.get('showplayers_aura2'), playersedit_name: obj.get('playersedit_name'), playersedit_bar1: obj.get('playersedit_bar1'), playersedit_bar2: obj.get('playersedit_bar2'), playersedit_bar3: obj.get('playersedit_bar3'), playersedit_aura1: obj.get('playersedit_aura1'), playersedit_aura2: obj.get('playersedit_aura2'), light_radius: obj.get('light_radius'), light_dimradius: obj.get('light_dimradius'), light_otherplayers: obj.get('light_otherplayers'), light_hassight: obj.get('light_hassight'), light_angle: obj.get('light_angle'), light_losangle: obj.get('light_losangle'), light_multiplier: obj.get('light_multiplier'), adv_fow_view_distance: obj.get('adv_fow_view_distance'), side: obj.get('sides'), currentSide: obj.get('currentSide'), subtype: obj.get('subtype'), has_bright_light_vision: obj.get('has_bright_light_vision'), has_night_vision: obj.get('has_night_vision'), night_vision_tint: obj.get('night_vision_tint'), emits_bright_light: obj.get('emits_bright_light'), bright_light_distance: obj.get('bright_light_distance'), emits_low_light: obj.get('emits_low_light'), low_light_distance: obj.get('low_light_distance'), has_limit_field_of_vision: obj.get('has_limit_field_of_vision'), limit_field_of_vision_center: obj.get('limit_field_of_vision_center'), limit_field_of_vision_total: obj.get('limit_field_of_vision_total'), has_limit_field_of_night_vision: obj.get('has_limit_field_of_night_vision'), limit_field_of_night_vision_center: obj.get('limit_field_of_night_vision_center'), limit_field_of_night_vision_total: obj.get('limit_field_of_night_vision_total'), has_directional_bright_light: obj.get('has_directional_bright_light'), directional_bright_light_total: obj.get('directional_bright_light_total'), directional_bright_light_center: obj.get('directional_bright_light_center'), has_directional_dim_light: obj.get('has_directional_dim_light'), directional_dim_light_total: obj.get('directional_dim_light_total'), directional_dim_light_center: obj.get('directional_dim_light_center'), light_sensitivity_multiplier: obj.get('light_sensitivity_multiplier'), tooltip: obj.get('tooltip'), show_tooltip: obj.get('show_tooltip'), night_vision_effect: obj.get('night_vision_effect'), dim_light_opacity: obj.get('dim_light_opacity'), bar_location: obj.get('bar_location'), compact_bar: obj.get('compact_bar'), lightColor: obj.get('lightColor'), lockMovement: obj.get('lockMovement') }) log(newobj) sendPing(obj.get('left'),obj.get('top'), Campaign().get('playerpageid'), null, true) newobj.set('top',dest.get('top')) newobj.set('left',dest.get('left')) obj.remove() toFront(newobj) break }else{ obj.set('top',dest.get('top')) obj.set('left',dest.get('left')) break } } } } }) Seems simple enough, but the results are unexpectedly not aligned with the expected behavior.
This is what's reported in the console log for the new token:&nbsp; {"_id":"-OC3mK-Ln6KwxrqJOwja","_pageid":"-NcBb39a0rc8UPfyl706","left":1020.6769123556675,"top":677.3547148597893,"width":70,"height":70,"rotation":0,"layer":"objects","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"<a href="https://s3.amazonaws.com/files.d20.io/images/350767407/mcT3xcZuBvh5rFJjhb5eHA/thumb.png?1689613101&quot;,&quot;name&quot;:&quot;Scarlett&quot;,&quot;gmnotes&quot;:&quot;&quot;,&quot;controlledby&quot;:&quot;-LXgIwyHa4kSoGcFgnKf&quot;,&quot;bar1_value&quot;:&quot;0&quot;,&quot;bar1_max&quot;:&quot;24&quot;,&quot;bar1_link&quot;:&quot;-NgiOhxihex_rkJExJcT&quot;,&quot;bar2_value&quot;:&quot;0&quot;,&quot;bar2_max&quot;:&quot;8&quot;,&quot;bar2_link&quot;:&quot;-NgiOiccl33TA0X2Ebhj&quot;,&quot;bar3_value&quot;:&quot;14&quot;,&quot;bar3_max&quot;:&quot;78&quot;,&quot;bar3_link&quot;:&quot;-NgiOhu4QJpPZ67OVbXs&quot;,&quot;represents&quot;:&quot;-NgiOhOE1iuJ1a4DU-c9&quot;,&quot;aura1_radius&quot;:&quot;0&quot;,&quot;aura1_color&quot;:&quot;rgb(255" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/350767407/mcT3xcZuBvh5rFJjhb5eHA/thumb.png?1689613101","name":"Scarlett","gmnotes":"","controlledby":"-LXgIwyHa4kSoGcFgnKf","bar1_value":"0","bar1_max":"24","bar1_link":"-NgiOhxihex_rkJExJcT","bar2_value":"0","bar2_max":"8","bar2_link":"-NgiOiccl33TA0X2Ebhj","bar3_value":"14","bar3_max":"78","bar3_link":"-NgiOhu4QJpPZ67OVbXs","represents":"-NgiOhOE1iuJ1a4DU-c9","aura1_radius":"0","aura1_color":"rgb(255</a>, 255, 153)","aura1_square":false,"aura2_radius":"0","aura2_color":"rgb(89, 229, 148)","aura2_square":false,"tint_color":"transparent","statusmarkers":"002-Karma-Ask::4711419,416-PA-Buff::4711472@6","showname":true,"showplayers_name":true,"showplayers_bar1":false,"showplayers_bar2":true,"showplayers_bar3":false,"showplayers_aura1":true,"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":"","_type":"graphic","_subtype":"token","_cardid":"","has_bright_light_vision":true,"has_night_vision":false,"night_vision_tint":null,"night_vision_distance":0,"emits_bright_light":false,"bright_light_distance":0,"emits_low_light":true,"low_light_distance":5,"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":false,"directional_bright_light_total":0,"directional_bright_light_center":0,"has_directional_dim_light":false,"directional_dim_light_total":0,"directional_dim_light_center":0,"light_sensitivity_multiplier":100,"tooltip":"","show_tooltip":false,"night_vision_effect":null,"dim_light_opacity":"0.75","bar_location":"overlap_bottom","compact_bar":"compact","lightColor":"transparent","lockMovement":false} and this is what's reported for the destination portal's location and page ID: "1020.6769123556675, 677.3547148597893" "-NcBb39a0rc8UPfyl706"