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] It's A Trap! v2.3

1461306405

Edited 1540922465
Ada L.
Marketplace Creator
Sheet Author
API Scripter
It's A Trap! (old thread) Follow this link to the new support thread:&nbsp; <a href="https://app.roll20.net/forum/post/6927186/script-its-a-trap-thread-2/?pageforid=6927192#post-6927192" rel="nofollow">https://app.roll20.net/forum/post/6927186/script-its-a-trap-thread-2/?pageforid=6927192#post-6927192</a>
1461319679
Ziechael
Forum Champion
Sheet Author
API Scripter
Oh boy oh boy oh boy, I've been using a 'hacked' version for months which allowed inline rolls in GM notes for custom trap outputs (thanks The Aaron!) but to have it officially supported is immense... and now for my full list of ideal additions ;) have it so that the bars can be used to set some trap values (maybe DC, save type and jukebox sound to play?) For example bar1value of 15, bar 2 value of Reflex and bar3value of springloaded would tell the script to output as part of the text [[bar2value]] Save DC [[bar1value]] and trigger the jukebox to play the sound called 'springloaded' :) Some way in which 'passive' searching could be enabled to detect traps, maybe even with a way to have active searching increase that chance of success (maybe auras and collision, although that would raise the issue of it passing through walls unless you could find a way to restrict that via your coding magic??) This is the code snippet Aaron put together for me for my general sound support which allows me to have general akbar announce "it's a trap!" for hilarity when a trap is triggered at present... you prob don't need it but i'm all about sharing :) var PlaySound = function(trackname, time) { var track = findObjs({type: 'jukeboxtrack', title: trackname})[0]; track.set('playing',false); track.set('softstop',false); if(track) { track.set('playing',true); } else { log("No track found"); } };
I'm thrilled to see an update to this great script! Thank you, Stephen L. !
Thank you! Just in time too, my players are facing an ancient Vampire Castle and the traps inside this weekend. :)
1461334664

Edited 1461334774
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: Oh boy oh boy oh boy, I've been using a 'hacked' version for months which allowed inline rolls in GM notes for custom trap outputs (thanks The Aaron!) but to have it officially supported is immense... and now for my full list of ideal additions ;) have it so that the bars can be used to set some trap values (maybe DC, save type and jukebox sound to play?) For example bar1value of 15, bar 2 value of Reflex and bar3value of springloaded would tell the script to output as part of the text [[bar2value]] Save DC [[bar1value]] and trigger the jukebox to play the sound called 'springloaded' :) Those are some great suggestions. This script has always been intended to be system-agnostic, so no direct support is planned for automating D&D style trap mechanics. Some way in which 'passive' searching could be enabled to detect traps, maybe even with a way to have active searching increase that chance of success (maybe auras and collision, although that would raise the issue of it passing through walls unless you could find a way to restrict that via your coding magic??) Again, how active/passive searching is handled is very much system-specific. However, I could do some fancy mathemagics with my PathMath utility script create a function to get all the traps that a character would be able to search for within some search radius, with support for walls blocking the way. This could be tied into some sort of D&D 5 or [Insert your system here] trap searching script.&nbsp; A couple enhancements I have planned for the near future are support for API chat commands in the trap messages, and being able to specify trap parameters in the GM Notes as JSON. The JSON enhancement would tie in well with the trap interpreters enhancement since it would allow users to specify parameters in addition to whatever is in the Bar 1,2,3 values. Properties in the JSON would include support for trap message templates, names of sounds to play, and special FX definitions (once that rolls out onto Production).
1461536836

Edited 1461547164
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Update v2.2 now available! See the updated original post. Please let me know if you guys want to see TrapThemes to support specific character sheets.
1461573477
Ziechael
Forum Champion
Sheet Author
API Scripter
Awesome, I love how this is growing! Would love to see support for 3.5e DnD for those of us who love pointlessly complex mathematics and contradictory/vague rules :)
1461698634
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: Awesome, I love how this is growing! Would love to see support for 3.5e DnD for those of us who love pointlessly complex mathematics and contradictory/vague rules :) I've got D&D 3.5 on the roadmap for sheets to implement TrapThemes for. Which D&D 3.5 character sheet is your game using?
1461710711
Ziechael
Forum Champion
Sheet Author
API Scripter
A custom one derived from Diana's awesome community one. My customisations revolve around the inventory so shouldn't have any impact on any TrapThemes implementation :)
1461868212

Edited 1461868226
Miranda
Sheet Author
Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects.
1461869743
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Christopher (Obi) said: Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects. Done. The OP has been edited to include a couple examples.
Stephen L. said: Christopher (Obi) said: Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects. Done. The OP has been edited to include a couple examples. Bless you sir. Love this script.
I seem to be getting an "Infinite loop crash" but I can't determine the circumstances causing it....
1461882147

Edited 1461885177
Miranda
Sheet Author
Okay, so what's happening: I have a player who, for some reason, can't see traps...then, sometimes, he causes a crash (infinite loop). I can't seem to figure out why. Edit: It seems to be if the character has a First and Last name when the token is first edited and saved, for some odd reason...I don't know if that's it, but the two characters having trouble have first and last names.
1461886446
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I've been testing with characters that have anywhere from 1-3 words in their names with no problem. Have you made sure that ItsATrap is the cause of it by disabling all other scripts except ItsATrap and its dependencies?
Stephen L. said: I've been testing with characters that have anywhere from 1-3 words in their names with no problem. Have you made sure that ItsATrap is the cause of it by disabling all other scripts except ItsATrap and its dependencies? I'll do that today and get back to you.
1461912214

Edited 1461919303
Miranda
Sheet Author
&nbsp;Just to list whats running now in case it raises any flags already: Torch 5eOGL companion and sheet Mystars Calendar And the It's a trap stuff. I'll get in and test it later. Seems to just be bugging for the two characters.
Okay, so I disabled everything but Its a Trap and its dependencies. Still no luck with the bugged character (even with new tokens and changing the name). I made them new character cards, and those new ones work just fine, though, but that doesn't help find the cause of the bug, eh? Just to confirm what runs with Its a Trap: Vector Math Token Collsions Matrix Math Path Math and the Its a Trap 5thE OGL Theme
1461936623
Ada L.
Marketplace Creator
Sheet Author
API Scripter
yes, those are all the scripts needed to run ItsATrap with 5E-OGL. I have so far been unable to replicate your issue. The only way for me to get an idea of what could be wrong would be to mess around in your game with the API scripts and the two characters.
I'll see what I can do to allow that. Thanks, sorry I couldn't be more clear about the circumstances.
1461956257

Edited 1461956723
Miranda
Sheet Author
Well, I've figured out what's causing it...just not how its causing it (I'm not a scipter) If I check the Proficiency in Wisdom, no matter the character, that character sheet will no longer work with the script...at all. I've unchecked it and it still does not spot. I've tested it 5 times so far and it replicates each time. EDIT: I've got a fix for it....uncheck the checkbox, then just use the options to mod it up to the right number, then go into your character's abilities (the roll20 ones) and delete the entry for&nbsp;perception_prof and then it'll work. I hope this helps to find the real culprit!
1461959783
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ok, I might have an idea of where it might be goofing up in the 5E-OGL theme. I'll see about getting that patched up soon.
Stephen L. said: Ok, I might have an idea of where it might be goofing up in the 5E-OGL theme. I'll see about getting that patched up soon. Rock on!
1462126028

Edited 1462126468
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Got those fixes in for the 5E-OGL theme. You can get the new version here until the pull request is processed:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/tree/TrapTheme5EOGL/ItsATrap_theme_5E_OGL" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/TrapTheme5EOGL/ItsATrap_theme_5E_OGL</a> On an unrelated note: Due to issues with compatibility between attributes in the character sheet and API systems, I am discontinuing the theme for the 5E Community sheet. I might pick it back up if better support is added to the API for getting calculated attributes from a character sheet.
Fantastic Script!!! I am trying to work on a 4e hack to work with 4e character sheet and power cards but it gives an error when using the&nbsp;character.get('id') both on the passive perception and the trigger: "ERROR: Did not specify an attribute name when referencing attribute using @{-Jy4Dslhq6dZkU3ebs3k}" The lines of code are: var TrapMsg = {}; TrapMsg.who = character.get('name') ; TrapMsg.content = "!power --charid|@{" + character.get('id') + "} --emote|" + character.get('name') + " has found a trap --format|trap --name|IT'S A TRAP!!"; PowerCard.Process(TrapMsg); i am sure it is somethign simple i am missing!
1462128227
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Characters do not have an "id" property. They do have an "_id" property though. ;) Hope that solves your issue.
1462129114

Edited 1462130965
Hi Stephen, thanks for the reply its finding the character id&nbsp;-Jy4Dslhq6dZkU3ebs3k in this case, and using it to create the avatar etc, but it looks lie it is also looking for attributes that i cant see why. it may be more of a powercards issue than this? Edit: - ignore all that, was me being an idiot!! @{ } was not needed around character.get('id') Thank you for your help still though.
1462132326

Edited 1462132699
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Update: A trap theme for Diana P.'s D&D 3.5 Edition character sheet is now available.The theme name is "DnD-3.5".&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/tree/T" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/T</a>... Please note that at this time, AC for this theme has limited support. This is due to how calculated attributes are resolved in the API vs on character sheets. If this API bug is fixed, the AC feature of the script should begin working again automatically though.
1462133554
Ziechael
Forum Champion
Sheet Author
API Scripter
Sweeeeet, will have to find time to test this soon :) Thanks for the great work Stephen!
1462218906
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Update: v2.3 is now available. This version expands the trap JSON to allow special FX. This property is currently supported by the 'default' and 'test' themes, but I'll make it available soon in the other official themes.
1462485148
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Update: Token Collisions 1.3 is now unofficially available, with support for rectangular collisions (including rotated rectangles).&nbsp; This will allow collisions with rectangular traps. It's not merged yet, but if you guys want to play with it, you can replace whichever version of Token Collisions you have with the one on my 1.3 branch here:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/tree/T" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/T</a>... To set a trap as rectangular using Token Collisions 1.3, just set the trap's Aura1 to be a square.
1462729146

Edited 1462729283
Hi there, I've just installed this script and have manually added the 5th Edition Shaped script to run alongside. Added in the theme to the script all right, and tested it using the two examples you give in the documentation, and it seems to work great except for one thing - any characters that have armour on, it adds 10 to their AC. If the character has no armour in-putted on their sheet at all it calculates correctly. Any ideas on what I could be doing wrong? Edit: I also seem to be getting errors in the log stating "ERROR: You tried to use the repeating section row at index 28 for repeating_skill, but there doesn't seem to be a row at that index." The index number basically errors out for anything past 18. Although it doesn't seem to cause a problem in the actual running of the script.
1462750633

Edited 1462768802
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Xiavn said: Hi there, I've just installed this script and have manually added the 5th Edition Shaped script to run alongside. Added in the theme to the script all right, and tested it using the two examples you give in the documentation, and it seems to work great except for one thing - any characters that have armour on, it adds 10 to their AC. If the character has no armour in-putted on their sheet at all it calculates correctly. Any ideas on what I could be doing wrong? I must have made a mistake while making the theme for the sheet. Anytime I tried to give a character armor, their AC would become just the bonus from their armor, and not have the usual base 10 to their AC. So it seemed weird that a character in fullplate had only AC 8 whereas an unarmored character with a Dex modifier of 10 had AC 10... On the other hand, I've never touched any of the 5E character sheets before creating the trap themes, so I'm not familiar with some of their peculiarities. &nbsp;This is a result of me derping because there was a lot of pressure for the 5E trap theme to be made, and me still being sort of a noob about 5E. &gt;_&lt; When I created the sheet, I was thinking armor gave a bonus to AC like in DnD 3.5, instead of it being just the character's base AC. I'll get that fix in so it'll be correct next merge-day. Edit: I also seem to be getting errors in the log stating "ERROR: You tried to use the repeating section row at index 28 for repeating_skill, but there doesn't seem to be a row at that index." The index number basically errors out for anything past 18. Although it doesn't seem to cause a problem in the actual running of the script. It does that when it trying to find the passive perception for a character. Because there is currently no way from the API to tell how many rows are in a repeating section, it tries to find the perception skill within the first 30 (just in case someone decides they REALLY need to have a bunch of additional homebrew skills) skills in the repeating skills list. When it goes beyond the actual number of items in the list, it starts displaying those error message, but it doesn't appear to actually throw an Error about it, so it's not like I can just catch it in a try-block. I'm still looking for a work-around on this. Sorry that there are still some bugs to work out for the theme. :( Edit: I discovered Aaron's technique for getting repeated section attributes using filterObjs and getAttrByName. So now I've refactored the theme so that it should have better performance and not have those index errors. That will hopefully be available to everyone (along with the armored AC fix) on the next merge day.
That seems to be working great now! Both the AC and the the errors are all working correctly now. However, I have another query regarding the spot DC. Does it actually check the spotDC against Perception or Wisdom? I ask because it seems to be working correctly on a character without proficiency in perception (i.e, their wisdom modifier = their perception), but not for someone who has proficiency in perception (i.e. their perception is two points higher than their wisdom). Sorry! I feel like all I'm doing is picking holes, but it's honestly a superb script. I just probably spend way too long prepping stuff down into way too precise details for my game (my players seem to think so at least).
1462801257
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I actually haven't put these changes in my master branch yet, but proficient passive perception is working fine for me in my coding sandbox with the new fixes. If you'd like to try out the fixes early, here's the branch for it here:&nbsp;<a href="https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped</a>
1462802166
The Aaron
Pro
API Scripter
Stephen L. said: Edit: I discovered Aaron's technique for getting repeated section attributes using filterObjs and getAttrByName. So now I've refactored the theme so that it should have better performance and not have those index errors. That will hopefully be available to everyone (along with the armored AC fix) on the next merge day. Cool! &nbsp;I didn't even realize I had a technique for that. =D &nbsp;Happy to (passively) help!
1462803129

Edited 1462803396
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes, while searching for ways to extract repeated items from character sheets, I stumbled across your response here:&nbsp; <a href="https://app.roll20.net/forum/post/2107785/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/2107785/slug%7D</a>
1462803753
The Aaron
Pro
API Scripter
Ah, interesting. &nbsp;That code won't work in the post-reorderable-repeating-sections era, but I assume you adjusted the regex to account for that. &nbsp;Something like: var char = /* got from somewhere */; var conditions = filterObjs( function(o){ return o.get('type') === 'attribute' && o.get('characterid') === char.id && /repeating_moves_ [^_]+ _condition/.test(o.get('name')) ; }); getAttrByName() is an annoying beast. &nbsp;I have lots of code that expects it to return a formula instead of a value. &nbsp;I'll have to do some testing...
1462805389
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yeah, I modified the regex to get the row IDs instead of the row indexes. It would be nice to have a version of getAttrByName that returns the resolved value of a calculated field instead of the formula.&nbsp;For now, I've just been expanding out the formulas and processing the end result with an inline roll in sendChat.
1462806542
The Aaron
Pro
API Scripter
Oh, I think the confusion is that getAttrByName() resolves autocalc fields that aren't backed by actual attribute objects, but will return formulas if they are there.
Stephen L. said: I actually haven't put these changes in my master branch yet, but proficient passive perception is working fine for me in my coding sandbox with the new fixes. If you'd like to try out the fixes early, here's the branch for it here:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped</a> Yeah that's the one I tested I with earlier I believe, the AC was working perfectly. I've also just retested, and yeah the proficiency in perception is working (I tested with another character), apparently the issue I had earlier is the original character I tested with (who had the proficiency bonus) just doesn't spot traps whatsoever, however low they are. I shall have to investigate further.
Okay, after a bit of testing (after figuring out how to log to the api console), I've figured out that this section of the passive perception check: &nbsp; &nbsp; var skills = filterObjs(function(o) { &nbsp; &nbsp; &nbsp; return o.get('type') === 'attribute' && &nbsp; &nbsp; &nbsp; &nbsp; o.get('characterid') === character.get('_id') && &nbsp; &nbsp; &nbsp; &nbsp; /repeating_skill_-?([a-zA-Z]|\d)+_name/.test(o.get('name')); &nbsp; &nbsp; }); Is basically returning an empty array for my one character that isn't working. Whereas for everyone else it's obviously returning an array of what looks like all the passive skills? Any ideas what might be up with her character? I tried duplicating the sheet, changing the name, etc, and it still doesn't work. Tried regenerating the skills. I assume the next step is going to be to just remake the character entirely.
1462817673
Ada L.
Marketplace Creator
Sheet Author
API Scripter
If that character has been around for a while, it's possible that their skills are still using row indexes instead of row IDs. Try replacing&nbsp; /repeating_skill_-?([a-zA-Z]|\d)+_name/ with /repeating_skill_(-|\$)([a-zA-Z]|\d)+_name/
Stephen L. said: If that character has been around for a while, it's possible that their skills are still using row indexes instead of row IDs. Try replacing&nbsp; /repeating_skill_-?([a-zA-Z]|\d)+_name/ with /repeating_skill_(-|\$)([a-zA-Z]|\d)+_name/ No luck with this fix I'm afraid - the character was made at roughly the same time as others, so I think it has the correct row ID's. However after a bit more delving, and playing around I have pinned it down - the issue seems to be that this particular character has a hyphen in the id field for the skills (-KDi-B4dTSzpBqHOoX2K to be exact for perception). I also noticed that this characters character id had a double underscore in it, which seemed to be unique amongst all my characters; not sure if this is why it generated the skills with a hyphen. Anyway this regex seems to be working at the moment:&nbsp; /repeating_skill_(-|\$)([a-zA-Z-]|\d)+_name/ But I'm not sure if there would be a more elegant solution. As much as I love looking at code and playing with regex, I will admit I'm very much a learner.
1462836904

Edited 1462837338
The Aaron
Pro
API Scripter
I'd suggest: /repeating_skill_(\$\d+|-[a-zA-Z0-9\-]+)_name/ The function that generates row ids can generate a dash inside the id. &nbsp; Here is a regex101 workarea for it:&nbsp; <a href="https://regex101.com/r/vH3zT2/1" rel="nofollow">https://regex101.com/r/vH3zT2/1</a> Edit: I should read more deeply, I see you ran into the same thing. =D The code that generates the ids is this: var generateUUID = (function() { &nbsp; &nbsp; "use strict"; &nbsp; &nbsp; var a = 0, b = []; &nbsp; &nbsp; return function() { &nbsp; &nbsp; &nbsp; &nbsp; var c = (new Date()).getTime() + 0, d = c === a; &nbsp; &nbsp; &nbsp; &nbsp; a = c; &nbsp; &nbsp; &nbsp; &nbsp; for (var e = new Array(8), f = 7; 0 &lt;= f; f--) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e[f] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c % 64); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = Math.floor(c / 64); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; c = e.join(""); &nbsp; &nbsp; &nbsp; &nbsp; if (d) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (f = 11; 0 &lt;= f && 63 === b[f]; f--) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b[f] = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b[f]++; &nbsp; &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (f = 0; 12 &gt; f; f++) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b[f] = Math.floor(64 * Math.random()); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; for (f = 0; 12 &gt; f; f++){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c += "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; return c; &nbsp; &nbsp; }; }()), generateRowID = function () { &nbsp; &nbsp; "use strict"; &nbsp; &nbsp; return generateUUID().replace(/_/g, "Z"); }; It's basically base64 encoding a block of data which is highly unlikely to be repeated in order to generate a unique ID. &nbsp;_ is a valid character in that id, so technically, a character ID of -______________ would be completely valid (all IDs from this function begin with a - because of what I can only assume is an off by one error). &nbsp;In the case of RowIDs, the _ is necessarily replaced by another character (Z) as _ is something of a delimiter in attribute names. &nbsp;(Subbing in a Z increases the likelihood of a collision (1.5625% overlap in keyspace), though not by nearly as much as lowercasing the whole thing (40.625% overlap in keyspace).)
1462887317

Edited 1462887737
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ah yes, regex101 is my favorite site for testing out regular expressions. It also saves me a lot of time converting the README files for my scripts into description strings for the script.json files. From the example IDs on the wiki, I was under the impression that row indexes start with '$' and rowIDs start with '-', followed by an alpha-numeric string. Where did you find the code for generating row IDs? I'm not finding anything about it on the wiki.
1462888762
The Aaron
Pro
API Scripter
I dug it out of the site. =D
1462890230
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The regex should be fixed to work with those characters now.&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/blob/T" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/T</a>... The regular expression I went with is: repeating_skill_(-([0-9a-zA-Z\-_](?!_storage))+?|\$\d+?)_name
1463014746
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey Stephen, I was wondering, what are the limits on what can be done with the trap themes? is it limited to attacks/AC/Damage? Thanks, Scott
1463016330
Ada L.
Marketplace Creator
Sheet Author
API Scripter
There aren't any limits to what can be done with traps in your own trap themes.&nbsp;ItsATrap provides some functions for playing a sound defined in the trap's JSON, spawning FX defined in the trap's JSON, and circling traps that a character passively spots, which can be called in your activateTrap and passiveSearch implementations. Other than that, you can code your trap theme to do whatever you want with the API. The trap JSON object always includes the ID of the token that triggered the trap and the ID of the trap token so you can do things specifically with that trap and victim.&nbsp;
1463044392
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Stephen L. said: Update: Token Collisions 1.3 is now unofficially available, with support for rectangular collisions (including rotated rectangles).&nbsp; This will allow collisions with rectangular traps. It's not merged yet, but if you guys want to play with it, you can replace whichever version of Token Collisions you have with the one on my 1.3 branch here:&nbsp; <a href="https://github.com/Cazra/roll20-api-scripts/tree/T" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/T</a>... To set a trap as rectangular using Token Collisions 1.3, just set the trap's Aura1 to be a square. Hi Stephen, I'm getting an error using the new Token Collisions 1.3.&nbsp; TypeError: other.get is not a function TypeError: other.get is not a function at apiscript.js:175:24 at /home/node/d20-api-server/node_modules/underscore/underscore.js:380:19 at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24) at Function._.sortBy (/home/node/d20-api-server/node_modules/underscore/underscore.js:376:22) at _.(anonymous function) [as sortBy] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at _getCollisionsInWaypoint (apiscript.js:167:11) at apiscript.js:141:20 at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24) at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at Object.getCollisions (apiscript.js:140:12) I think it's from this codes segment (lines 55-87): function _getCollisionsInWaypoint(token, others, waypoint) { &nbsp; &nbsp; &nbsp; &nbsp;var startPt = waypoint[0]; &nbsp; &nbsp; &nbsp; &nbsp;var endPt = waypoint[1]; &nbsp; &nbsp; &nbsp; &nbsp;var numCollisions = 0; &nbsp; &nbsp; &nbsp; &nbsp;return _.chain(others) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Get the list of tokens that actually collide, sorted by the distance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// from the starting point at which they occur. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.sortBy(function(other) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var dist; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token.get('aura1_square')) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(other.get('aura1_square')) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dist = _testRectsCollision(token, other, waypoint); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dist = _testRectCircleCollision(token, other, waypoint); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(other.get('aura1_square')) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dist = _testCircleRectCollision(token, other, waypoint); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dist = _testCirclesCollision(token, other, waypoint); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(dist !== undefined) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;numCollisions++; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return dist; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Other tokens with undefined collision distance will be sorted to the high &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// end of the list. So, we'll just drop them. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.first(numCollisions) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.value(); &nbsp; &nbsp; &nbsp;} But other than that I'm stymied. I'm trying to call Token Collisions with the following code: &nbsp; &nbsp;getDestinationCollisions = function(token) { &nbsp; &nbsp; &nbsp; &nbsp; var pageId, &nbsp; &nbsp; &nbsp; &nbsp; destinations, &nbsp; &nbsp; &nbsp; &nbsp; collisions, &nbsp; &nbsp; &nbsp; &nbsp; lastCollision; &nbsp; &nbsp; &nbsp; &nbsp; pageId = token.get('_pageid'); &nbsp; &nbsp; &nbsp; &nbsp; destinations = getDestinations(pageId); &nbsp; &nbsp; &nbsp; &nbsp; collisions = TokenCollisions.getCollisions(token, destinations); &nbsp; &nbsp; &nbsp; &nbsp; lastCollision = _.last(collisions); &nbsp; &nbsp;}, &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; getDestinations = function(pageId){ &nbsp; &nbsp; &nbsp; &nbsp; return findObjs({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageid: pageId, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: 'graphic', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layer: /*'map' ||*/ 'gmlayer', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusmarkers: 'aura' &nbsp; &nbsp; &nbsp; &nbsp; })[0]; &nbsp; &nbsp; }, If I comment out the "collisions =" and "lastCollisions =" lines and log all the variables I get: "pageId" "-Jo6Dd7nZqSelv3fMvdG" "token" {"_id":"-Jp2cpJ5LRb6rewwjAJg","_pageid":"-Jo6Dd7nZqSelv3fMvdG","left":3395,"top":1085,"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/7039467/f7qYLQ3M1plP_Fg1wFQkcg/thumb.png?1420690169&quot;,&quot;name&quot;:&quot;&quot;,&quot;gmnotes&quot;:&quot;&quot;,&quot;controlledby&quot;:&quot;&quot;,&quot;bar1_value&quot;:&quot;&quot;,&quot;bar1_max&quot;:&quot;&quot;,&quot;bar1_link&quot;:&quot;&quot;,&quot;bar2_value&quot;:&quot;&quot;,&quot;bar2_max&quot;:&quot;&quot;,&quot;bar2_link&quot;:&quot;&quot;,&quot;bar3_value&quot;:&quot;&quot;,&quot;bar3_max&quot;:&quot;&quot;,&quot;bar3_link&quot;:&quot;&quot;,&quot;represents&quot;:&quot;&quot;,&quot;aura1_radius&quot;:&quot;&quot;,&quot;aura1_color&quot;:&quot;#FFFF99&quot;,&quot;aura1_square&quot;:false,&quot;aura2_radius&quot;:&quot;&quot;,&quot;aura2_color&quot;:&quot;#59E594&quot;,&quot;aura2_square&quot;:false,&quot;tint_color&quot;:&quot;transparent&quot;,&quot;statusmarkers&quot;:&quot;&quot;,&quot;showname&quot;:false,&quot;showplayers_name&quot;:false,&quot;showplayers_bar1&quot;:false,&quot;showplayers_bar2&quot;:false,&quot;showplayers_bar3&quot;:false,&quot;showplayers_aura1&quot;:false,&quot;showplayers_aura2&quot;:false,&quot;playersedit_name&quot;:true,&quot;playersedit_bar1&quot;:true,&quot;playersedit_bar2&quot;:true,&quot;playersedit_bar3&quot;:true,&quot;playersedit_aura1&quot;:true,&quot;playersedit_aura2&quot;:true,&quot;light_radius&quot;:&quot;&quot;,&quot;light_dimradius&quot;:&quot;&quot;,&quot;light_otherplayers&quot;:false,&quot;light_hassight&quot;:false,&quot;light_angle&quot;:&quot;&quot;,&quot;light_losangle&quot;:&quot;&quot;,&quot;light_multiplier&quot;:1,&quot;sides&quot;:&quot;&quot;,&quot;currentSide&quot;:0,&quot;lastmove&quot;:&quot;3395,1155&quot;,&quot;_type&quot;:&quot;graphic&quot;,&quot;_subtype&quot;:&quot;token&quot;,&quot;_cardid" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/7039467/f7qYLQ3M1plP_Fg1wFQkcg/thumb.png?1420690169","name":"","gmnotes":"","controlledby":"","bar1_value":"","bar1_max":"","bar1_link":"","bar2_value":"","bar2_max":"","bar2_link":"","bar3_value":"","bar3_max":"","bar3_link":"","represents":"","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,"sides":"","currentSide":0,"lastmove":"3395,1155","_type":"graphic","_subtype":"token","_cardid</a>":""} "destinations" {"_id":"-KHXcUKIYyHbJGZIf8do","_pageid":"-Jo6Dd7nZqSelv3fMvdG","left":3395,"top":1050,"width":210,"height":140,"rotation":0,"layer":"gmlayer","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"<a href="https://s3.amazonaws.com/files.d20.io/images/17909715/MSbM_vNTea-EnPc74F_DFA/thumb.png?1459987051&quot;,&quot;name&quot;:&quot;Scrapwall&quot;,&quot;gmnotes&quot;:&quot;&quot;,&quot;controlledby&quot;:&quot;&quot;,&quot;bar1_value&quot;:&quot;&quot;,&quot;bar1_max&quot;:&quot;&quot;,&quot;bar1_link&quot;:&quot;&quot;,&quot;bar2_value&quot;:&quot;&quot;,&quot;bar2_max&quot;:&quot;&quot;,&quot;bar2_link&quot;:&quot;&quot;,&quot;bar3_value&quot;:&quot;&quot;,&quot;bar3_max&quot;:&quot;&quot;,&quot;bar3_link&quot;:&quot;&quot;,&quot;represents&quot;:&quot;&quot;,&quot;aura1_radius&quot;:&quot;&quot;,&quot;aura1_color&quot;:&quot;#FFFF99&quot;,&quot;aura1_square&quot;:true,&quot;aura2_radius&quot;:&quot;&quot;,&quot;aura2_color&quot;:&quot;#59E594&quot;,&quot;aura2_square&quot;:false,&quot;tint_color&quot;:&quot;transparent&quot;,&quot;statusmarkers&quot;:&quot;aura&quot;,&quot;showname&quot;:false,&quot;showplayers_name&quot;:false,&quot;showplayers_bar1&quot;:false,&quot;showplayers_bar2&quot;:false,&quot;showplayers_bar3&quot;:false,&quot;showplayers_aura1&quot;:false,&quot;showplayers_aura2&quot;:false,&quot;playersedit_name&quot;:true,&quot;playersedit_bar1&quot;:true,&quot;playersedit_bar2&quot;:true,&quot;playersedit_bar3&quot;:true,&quot;playersedit_aura1&quot;:true,&quot;playersedit_aura2&quot;:true,&quot;light_radius&quot;:&quot;&quot;,&quot;light_dimradius&quot;:&quot;&quot;,&quot;light_otherplayers&quot;:false,&quot;light_hassight&quot;:false,&quot;light_angle&quot;:&quot;&quot;,&quot;light_losangle&quot;:&quot;&quot;,&quot;light_multiplier&quot;:1,&quot;sides&quot;:&quot;&quot;,&quot;currentSide&quot;:0,&quot;lastmove&quot;:&quot;3325,1085&quot;,&quot;_type&quot;:&quot;graphic&quot;,&quot;_subtype&quot;:&quot;token&quot;,&quot;_cardid" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/17909715/MSbM_vNTea-EnPc74F_DFA/thumb.png?1459987051","name":"Scrapwall","gmnotes":"","controlledby":"","bar1_value":"","bar1_max":"","bar1_link":"","bar2_value":"","bar2_max":"","bar2_link":"","bar3_value":"","bar3_max":"","bar3_link":"","represents":"","aura1_radius":"","aura1_color":"#FFFF99","aura1_square":true,"aura2_radius":"","aura2_color":"#59E594","aura2_square":false,"tint_color":"transparent","statusmarkers":"aura","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,"sides":"","currentSide":0,"lastmove":"3325,1085","_type":"graphic","_subtype":"token","_cardid</a>":""} So I'm reasonably sure I'm passing valid objects to TokenCollisions. Any ideas? Thanks, Scott