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

[Script Conflict] RecursiveTable conflicting with ChangeTokenImage

1561000289

Edited 1561000379
Hello,     As the title suggests, when I try to use the RecursiveTable(version 0.2.4 copied straight from GitHub) script in any of my games, it doesn't work properly.  After much trial and error, disabling scripts one at a time, I found out that if I disable ChangeTokenImage, Recursive Tables works the way it is intended.  Once I found this out, it seems to make sense as both of these scripts are dealing with rollable tables.  As I love both of these amazing scripts, is there a way to make them play together in the sandbox??  Below are two example screenshots as a picture is worth a thousand words: With both scripts enabled and running a macro/rollable table with !rt[Delimiter%%BR] With ChangeTokenImage disabled running the same macro/rollable table
If it helps(more info is always better in my book), here is the test code I am using and the test table(only one entry for easier testing) Macro: !rt[Delimiter%%BR] &{template:npcaction} {{rname= Treasure Hoard }} {{name= You have found: }} {{description= [[1t[Test]]] }} Table Entry: [[12d6*1000]] gp, [[8d6*1000]] pp, [[[[1d4]]t[1000GP-Gemstones]]], [[[[1d4]]t[Magic-Item-Table-C]]]
1561010172
The Aaron
Roll20 Production Team
API Scripter
Weird. I'll try and take a look tomorrow. I just got home from a 9 hour drive and it's 2:00am!
1561010471
The Aaron
Roll20 Production Team
API Scripter
Actually, I took a quick look at the code for ChangeTokenImage. It issue is line 103: var msg = (msg_orig), Change it to: var msg = _.clone(msg_orig),
As always, The Aaron to the rescue :)  You are the scriptomancer supreme and I thank you very much!!!!!  Worked perfectly!
1561224002
The Aaron
Roll20 Production Team
API Scripter
No problem.  The reason this was an issue (and why the above fixed it) is that the same message object is passed to each chat:message  handler, not a copy, but literally the same object.  That means any changes made to the object are seen by later scripts.  The way around that is to make a clone of the message object if you intend to change it.  The ChangeTokenImage script was copied from another of my scripts that was originally doing the clone, but at some point it was removed because the person writing the script either didn't understand why it was important, or removed it by mistake (you can tell because I always take the argument as msg_orig if I'm going to clone it, and the parenthesis are still around the variable in the assignment to msg).