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

Remove not removing... code below

1616947588
Ernest P.
Pro
API Scripter
So I am pretty sure this is me doing something wrong in the code. Here it is: for (var c=0; c < cssklist.length; c++) // Loop character sheet skill list and find repeating skill, skill names. { var csskil = cssklist[c].get("name"); logDebug("Skill: " + c + " " + csskil); if (csskil.indexOf("repeating_skills") === 0) //&& csskil.indexOf("_skill_name") > 0 { cssklist[c].remove(); logDebug("Removed Skill: " + c + " " + csskil + " - " + cssklist[c]); } } logDebug is just a wrapper function that writes to log if a debug flag is set when the API is called. A snippet of the output is: "Skill: 308 repeating_skills_-MWtSwCLLycuwzt9ttQb_skill_roll_show" "Removed Skill: 308 repeating_skills_-MWtSwCLLycuwzt9ttQb_skill_roll_show - [object Object]" "Skill: 309 repeating_skills_-MWtSwCLLycuwzt9ttQb_skill_roll_target" "Removed Skill: 309 repeating_skills_-MWtSwCLLycuwzt9ttQb_skill_roll_target - [object Object]" "Skill: 310 repeating_skills_-MWtSwCLLycuwzt9ttQb_skill_char" I am pretty sure that [object Object] should say undefined . But in any case, when I dump getAllObjs() to the log, all the repeating skills are still there in spite of the remove.  Help? - E
1616962438
The Aaron
Roll20 Production Team
API Scripter
.remove() removes the object from Firebase, which is the (near) realtime database that stores the game.  That .remove() event is then propagated out to all the clients to update their local game.  In the API, the object you have is a proxy to the Firebase object.  It will follow the normal rules for a javascript object, which is to say it will continue to exists until references to it go away.  That is why you still get "[object Object]" there.  That's all normal behavior. What doesn't seem normal is still being able to find it with getAllObjs().   If you take the ID and do a getObj('attribute',ID), do you still retrieve it?  Also, is it gone from the repeating row on the character sheet?  Try changing the value stored in it before removing it and see if the change persists and appears on the character sheet.
1616964970

Edited 1617040529
Ernest P.
Pro
API Scripter
Curiouser and curiouser. I still had the API console and game open from 4 hours ago. When I opened the character sheet, the skills were indeed gone. But when I ran the API with a show objects, they are still there (320 skills). How is that even possible? Sample: {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_name","current":"Perception","max":"","_id":"-MWide43jvW0Ebt4hU9z","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_roll_formula","current":"&{template:hero6template} {{charname=@{character_name}}} {{action=@{skill_name}}} {{roll=[[3d6]]}} {{target=13}} {{base=9}} {{stat=3}} {{lvls=1}}","max":"","_id":"-MWide45gYSAMju5E2qh","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_has_increase","current":1,"max":"","_id":"-MWide46Tf9EyNwHVw_K","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_has_roll","current":1,"max":"","_id":"-MWide48tp8fKDIsTOcN","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_roll_show","current":"13-","max":"","_id":"-MWide49n0LiBZz_zxqR","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_roll_target","current":13,"max":"","_id":"-MWide4Ava1qKEVbGw-5","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_char","current":"INT","max":"","_id":"-MWide4BEtg0TqhNtrrd","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide3ybGblU31qCRn4_skill_increase","current":"0","max":"","_id":"-MWide4CiAWx-MnjrqOS","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_name","current":"Acting","max":"","_id":"-MWide4DuRbzZh5PVxuh","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_roll_formula","current":"NaN}} {{lvls=0}}","max":"","_id":"-MWide4EOds9w46s6lzd","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_has_increase","current":0,"max":"","_id":"-MWide4G47h1AfbjmI6S","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_has_roll","current":0,"max":"","_id":"-MWide4HjthzyYNAUVbd","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_roll_show","current":" ","max":"","_id":"-MWide4IeG_fs2cw9N3W","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_roll_target","current":0,"max":"","_id":"-MWide4J27lwVgqWFDRL","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_char","current":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_roll_show","max":"","_id":"-MWide4KluSayASyXRqJ","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, {"name":"repeating_skills_-MWide48PPwOpNZL1bx-_skill_increase","current":"8-","max":"","_id":"-MWide4L2MAZ65IWJeNa","_type":"attribute","_characterid":"-MWKbE-g9iyRtI8TN9_J"}, I'll try changing a value and removing again and see what shows in the objects. Changing the value of Current does persist in the show object. I am done with this for the moment, but I'll come back later tonight or in the morning and start with a fresh blank character sheet and see if the problem sticks around. Some days the code just needs a good nights rest (or I do). New day. Unable to replicate problem after starting fresh with new windows for game and API console. I'll keep an eye out as I continue testing and let folks know if I see it again. And I will keep better logs so I can post all of that as well. - E