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

Objects that I can't delete?!

So... I have an API script with a message handler. It has this code in it: var handleChatMessage = function(msg) {   log("debug-selected");   for (let selected of msg.selected) {     log(selected);   }; }; In the game there are text objects that I can select on the map. When I execute trigger the above code, it logs this: "debug-selected" {"_id":"-LwM5p8EqyZ-hk1qcu-b","_type":"text"} {"_id":"-LwM5p8EqyZ-hk1qcu-a","_type":"text"} {"_id":"-LwM5p8EqyZ-hk1qcu-_","_type":"text"} {"_id":"-LwM5p8DKRvoMdqrsdgN","_type":"text"} {"_id":"-LwM5p8Brqj1qSrw_ndf","_type":"text"} I can delete these objects from the map... and they will look to disappear. But if I reload the browser, the objects return. Any idea what's going on here? Also, if I try to delete these objects from the API code using the "remove()" function, I get this error: TypeError: selected.remove is not a function
1576675922
The Aaron
Roll20 Production Team
API Scripter
Selected does not contain Roll20 objects, it has objects containing the type and id of a Roll20 object. To delete them, you'd need to get the Roll20 object with getObj() and call remove on it.
1576680543

Edited 1576680769
Thank you for that, I had forgotten. I'm still seeing weirdness though. Here's the new code:   case '--debug-selected': {     if (!playerIsGM(playerID)) { return; };     log("debug-selected");     for (let selected of msg.selected) {       log("######");       log(selected)       let o = getObj(selected["_type"],selected["_id"]);       log(o);     };   }; break; So! I select a bunch of items on the map, and trigger this command from the chat, and here's the output on the API Output Console: "debug-selected" "######" {"_id":"-LwORSA-ctxajugeAk6s","_type":"text"} undefined "######" {"_id":"-LwORSA-ctxajugeAk6r","_type":"text"} undefined "######" {"_id":"-LwORS9z_URempxTfWwL","_type":"text"} undefined "######" {"_id":"-LwORS9xFdjFjHrqRekO","_type":"text"} undefined "######" {"_id":"-LwORS9tgorPn6HmieXG","_type":"text"} undefined This makes me think there's something screwy in the game... Am I crazy? Let's bypass this entire API script business.... If I completely disable all my scripts, and go onto the game map interface... I have no tokens on the objects layers, but there are these weird empty text objects that are selectable. If I select them, and press the "delete" key they go away. Awesome! Now if I refresh my browser tab (or exit-game and re-enter) the weird empty-text objects come back. That is why I created a simple script to debug the selected objects... and I've noticed that when they come back, the values of selected["_id"] change! It's always the same number of objects, but their IDs change. Again, this happens even when all my scripts are disabled.
1576684685
The Aaron
Roll20 Production Team
API Scripter
Hmm..  I modified your code so I could run it: on('ready',()=>{ on('chat:message',(msg)=>{ if('api'===msg.type && /^!skepickle/i.test(msg.content) && playerIsGM(msg.playerid)) { log("debug-selected"); for (let selected of msg.selected) { log("######"); log(selected) let o = getObj(selected["_type"],selected["_id"]); log(o); }; } }); }); and got these results: "debug-selected" "######" {"_id":"-LGDM-Hrclu7jsJS0T8Y","_type":"text"} {"top":169.99999999999997,"left":1287.3017578125,"width":149.087890625,"height":51.2,"text":"This is a test","font_size":32,"rotation":0,"color":"rgb(255, 153, 0)","font_family":"Patrick Hand","controlledby":"-JS3qKxIUPHLzSbK24ve","layer":"objects","_id":"-LGDM-Hrclu7jsJS0T8Y","_pageid":"-Jov_sJgYwFupeSJoIXF","_type":"text"} "######" {"_id":"-LGDM7sVcUX7MpEt8S6q","_type":"text"} {"top":240,"left":1290.8203125,"width":156.125,"height":51.2,"text":"This is a test","font_size":32,"rotation":0,"color":"rgb(255, 153, 0)","font_family":"Contrail One","controlledby":"-JS3qKxIUPHLzSbK24ve","layer":"objects","_id":"-LGDM7sVcUX7MpEt8S6q","_pageid":"-Jov_sJgYwFupeSJoIXF","_type":"text"} "######" {"_id":"-LGDM81EkGyvkAhZ4tNZ","_type":"text"} {"top":310,"left":1295.0390625,"width":164.5625,"height":51.2,"text":"This is a test","font_size":32,"rotation":0,"color":"rgb(255, 153, 0)","font_family":"Shadows Into Light","controlledby":"-JS3qKxIUPHLzSbK24ve","layer":"objects","_id":"-LGDM81EkGyvkAhZ4tNZ","_pageid":"-Jov_sJgYwFupeSJoIXF","_type":"text"} "######" {"_id":"-LGDM8AX0CIaiTGt3bu9","_type":"text"} {"top":380,"left":1326,"width":226.484375,"height":51.2,"text":"This is a test","font_size":32,"rotation":0,"color":"rgb(255, 153, 0)","font_family":"Candal","controlledby":"-JS3qKxIUPHLzSbK24ve","layer":"objects","_id":"-LGDM8AX0CIaiTGt3bu9","_pageid":"-Jov_sJgYwFupeSJoIXF","_type":"text"} "######" {"_id":"-LGDM8TBMC2zFs30yXxY","_type":"text"} {"top":100,"left":1302.5625,"width":179.609375,"height":51.2,"text":"This is a test","font_size":32,"rotation":0,"color":"rgb(255, 153, 0)","font_family":"Arial","controlledby":"-JS3qKxIUPHLzSbK24ve","layer":"objects","_id":"-LGDM8TBMC2zFs30yXxY","_pageid":"-Jov_sJgYwFupeSJoIXF","_type":"text"} I'd say if you disable all scripts, put my version in as the only active one and run !skepickle and you still get undefined, then you can say with certainty that something in your game is borked.  If my version in those conditions works, then there is some other API script that is breaking things.
I've pasted the above code directly into a new script on my game. All other scripts are disabled. I ran "!skepickle" from the game chat window while selecting the weird objects. I get the following output: Spinning up new sandbox... "Starting webworker script..." "Loading 376 translation strings to worker..." "%c���.����.���*����`*���.����.���*����`*���.��  The Aaron Sheet  v0.2.3  ��.���*����`*���.����.���*����`*���.����.���" "%c���.����.���*����`*���.����.���*����`*���.��  Last update: Thu Mar 03 2016 14:18:48 GMT+0000 (UTC)  ��.���*����`*���.����.���*����`*���.����.���" "debug-selected" "######" {"_id":"-LwOfx6Tj017VSveD2OE","_type":"text"} undefined "######" {"_id":"-LwOfx6Tj017VSveD2OD","_type":"text"} undefined "######" {"_id":"-LwOfx6SJkztjJGMuEJ1","_type":"text"} undefined "######" {"_id":"-LwOfx6RpQotX2-YCUiG","_type":"text"} undefined "######" {"_id":"-LwOfx6OzzSdPCIaR7OO","_type":"text"} undefined So borked it is. Now the question is... what can I do about it?
Well. I've resolved this issue by deleting the entire page that had the weirdness on it. But I'm curious as what was going on. :-\
1576686213
The Aaron
Roll20 Production Team
API Scripter
Very strange.  Something corrupted in the FireBase for that game I guess.  That wasn't a page you had copied out with Transmogrifier, renamed, then copied back, was it?  That can lead to strange behavior (duplicate object IDs and such)
Nope. Luckily it was actually a game that I was just doing API experiments in. The page was just a scratchpad page, so not transmogrified. I have been writing scripts that manipulate text objects on the page. The function I've been working on is adding condition markers to tokens, but not using the roll20 condition markers. Instead I've been putting text that rotates around the token. It is all working now, but I wouldn't be surprised if the code was in a state at some point where it borked things up. But I would be curious as to how I could have done that. :) Basically there are objects that show up on the map, but don't actually represent any defined objects. weird. Anyways. If I see anything like this again, I might delve further into debugging it. :shrug:
Thank you for the guidance, Aaron!
1576694846
The Aaron
Roll20 Production Team
API Scripter
No problem!  Sounds like a neat script, I'm looking forward to seeing it if you post it.