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 .
×
D&D 2024 has arrived! Pre-Order the new core rulebooks now.
Create a free account

[Script] It's A Trap! v2.3

1485528196
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Fix seems to work; get the error when the old code is in, no error with the new code. Thanks for the quick correction Stephen.
I was so excited to reveal the traps I built into our adventure last night, but they failed.  Not sure what happened, but here is the error I am getting: TypeError: Cannot read property 'get' of undefined at handleToken (apiscript.js:8920:39) at eval (eval at (/home/node/d20-api-server/api.js:1:0), :65:16) at Object.publish (eval at (/home/node/d20-api-server/api.js:1:0), :70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:911:16) at updateLocalCache (/home/node/d20-api-server/api.js:1178:18) at /home/node/d20-api-server/api.js:1357:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
1485705149

Edited 1485705226
Ada L.
Marketplace Creator
Sheet Author
API Scripter
It's A Trap and its dependencies don't have a function called handleToken. This is more likely a conflict with another script. What other scripts are you running?
GroupInitiative, SplitArgs, CustomFX, 5th Edition OGL by Roll20 Companion, Vector Math, MatrixMath, Path Math, Token Collisions, HTML Builder, It's a Trap!, Marching Order, Mark, Status FX, Aura Health, LightCrumb, Turn Marker 1, It's a Trap! - D&D 5E OGL Theme
It might be the Aura Health script.
I've disabled the Aura script ... I'm seeing this error in the API Output Console: "ERROR - It's A Trap!: Cannot read property '1' of undefined" "TypeError: Cannot read property '1' of undefined\n at apiscript.js:4001:34\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n at toSegments (apiscript.js:3990:11)\n at apiscript.js:4110:41\n at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)\n at Function.<anonymous> (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)\n at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n at _toSegmentsMany (apiscript.js:4109:12)\n at Object.toSegments (apiscript.js:3982:20)\n at Function.filterTokens (apiscript.js:6243:35)" "ERROR - It's A Trap!: Cannot read property '1' of undefined" "TypeError: Cannot read property '1' of undefined\n at apiscript.js:4001:34\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n at toSegments (apiscript.js:3990:11)\n at apiscript.js:4110:41\n at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)\n at Function.<anonymous> (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)\n at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n at _toSegmentsMany (apiscript.js:4109:12)\n at Object.toSegments (apiscript.js:3982:20)\n at Function.filterTokens (apiscript.js:6243:35)" "ERROR - It's A Trap!: Cannot read property '1' of undefined" "TypeError: Cannot read property '1' of undefined\n at apiscript.js:4001:34\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n at toSegments (apiscript.js:3990:11)\n at apiscript.js:4110:41\n at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)\n at Function.<anonymous> (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)\n at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n at _toSegmentsMany (apiscript.js:4109:12)\n at Object.toSegments (apiscript.js:3982:20)\n at Function.filterTokens (apiscript.js:6243:35)"
1485713252

Edited 1485713353
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
See the posts between me, Stephen, and Aaron on the previous page (and ending at the top of this page) for the problem causing this error. Long story short, there's an error in pathmath that is causing an error under some as yet to be determined conditions, but will be fixed when the new patch gets merged on the next merge day.
1485738116

Edited 1485739168
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes, here is the link again for the Path Math patch:&nbsp; <a href="https://raw.githubusercontent.com/Cazra/roll20-api-scripts/PathMath1.4.1/PathMath/1.4/PathMath.js" rel="nofollow">https://raw.githubusercontent.com/Cazra/roll20-api-scripts/PathMath1.4.1/PathMath/1.4/PathMath.js</a> I can't seem to find the Aura Health script in the Roll 20 API repository. Can you provide a link to the script's source so that I can take a closer look at it?
1485772321
Ziechael
Forum Champion
Sheet Author
API Scripter
This one possibly:&nbsp;<a href="https://app.roll20.net/forum/post/2139713/script-aura-slash-tint-healthcolor/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/2139713/script-aura-slash-tint-healthcolor/?pagenum=1</a>
1485787038
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ah, yep that would be it. It has the handleToken function that is causing the error. Unfortunately, it looks like the original author hasn't updated it in over a year. Also looks like Aaron put in a pull request to fix some issues back in May last year, but the author hasn't responded to the pull request... It seems abandoned. :/
Thank you all for your replies. I got hit with the flu and wasn't at the computer for the last few days. &nbsp;Yes, that was the Aura Health script I was using, I do believe. &nbsp;I will reread those previous posts and attempt that fix. &nbsp;You are all too kind and helpful, thank you thank you thank you. &nbsp;It seems that the Aura script was still functioning despite that causing the conflict with the Trap script. &nbsp;Is there a better script out there that produces that visual my players like as the NPC/monsters decline in hit points?
1485882366
Ziechael
Forum Champion
Sheet Author
API Scripter
If it helps, I use both It's A Trap! and the AuraHealth script (in 'tint' form) with no conflict. If you don't use tints for anything else it could be worth using that option to see if it avoids the error for you?
1485883195
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ziechael said: If it helps, I use both It's A Trap! and the AuraHealth script (in 'tint' form) with no conflict. If you don't use tints for anything else it could be worth using that option to see if it avoids the error for you? +1 for this as well.
1485885837

Edited 1485886378
"In tint form" ... could you elaborate on this? &nbsp;I'm not sure I'm grasping that meaning. &nbsp; (I think I figured out what this means!). &nbsp;We really only use it to see the health aura decline from green to red. &nbsp;I've not tweaked any settings, nor am familiar enough with the script to have done so yet. &nbsp;And if this is a highjack of the Trap thread, I sincerely apologize. Also, am I just to roll back the Path Math script until updates are through the system? &nbsp;Or do I copy and paste the above script into a New Script and just name it Path Math? Do we know when the next merge day is?
1485886433
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The aura health script allows you to track health via the auras around the token and/or via tint changes of the token (&lt;50% yellow, &lt;20% red, etc). As for the pathMath issue, you can either rollback or copy that corrected function that Stephen posted a few replies back and replace the version in PathMath with it.
1485887359
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I would recommend copying the patched version of PathMath, as that contains new functionality supporting path-based triggers in the newest version of It's A Trap.
1485888605

Edited 1485888767
I have turned on the "tint" for AuraHealth (though if I am to turn off the aura, I am unsure what to do there ... I'm not getting that handleToken error now however)&gt; I have removed PathMath and then created a New Script I called PathMath and copied the code over from the link above. This is the error I am receiving: "ERROR - It's A Trap!: Cannot read property '1' of undefined" "TypeError: Cannot read property '1' of undefined\n at apiscript.js:8264:34\n at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n at toSegments (apiscript.js:8253:11)\n at apiscript.js:8373:41\n at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)\n at Function.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)\n at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n at _toSegmentsMany (apiscript.js:8372:12)\n at Object.toSegments (apiscript.js:8245:20)\n at Function.filterTokens (apiscript.js:5534:35)"
1485889952
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Oops... wrong link. Here's the correct one for the patch:&nbsp;<a href="https://github.com/Cazra/roll20-api-scripts/blob/PathMath1.4.1/PathMath/1.4.1/PathMath.js" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/PathMath1.4.1/PathMath/1.4.1/PathMath.js</a>
Aha! &nbsp;My traps now work again. &nbsp;Thankyouahthankyouverymucha!!
1486005439

Edited 1486005483
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
[Moved to the Path Math Thread]
I'm&nbsp;not sure if or what&nbsp;I'm doing wrong. But I was getting errors because of the Path Math error. I patched and Now I do not receive any script errors but here is what I have happening.&nbsp; I set the Chest token on the GM Overlay screen, set cobweb icon, set up trap. Players cannot see the chest. If they walk onto its square it is set off and then shows up on whatever layer it was set to. That happens 80% of the time. The other 20% of the time they can set it off but it will not appear on the map or token layer( whichever the reveal is set to) but can be set off EVERY time they walk over the square. No Script errors so I'm not sure what I'm doing wrong. No other scripts running besides the dependents. Also a side note if I disable Its a trap the macro still shows up but does nothing( its permnantly at the top left). When I tried to delete the script and all dependent scripts the macro still shows up at the top left of my screen anytime I click on any icon.
1486113453
Ziechael
Forum Champion
Sheet Author
API Scripter
The macro is created by the script and added to your macro list in the collections tab. You can simply uncheck the 'in bar' button next to the Trap macros to stop them showing on EVERY token. As for the reveal feature, it sounds as though sometimes you are adding the bleeding eye status marker and sometimes you are not. This is the trigger to reveal the trap when triggered, if it isn't there then the trap remains active (because of the cobweb icon).
1486132845
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ziechael's answers are correct.&nbsp; The script has become more complex with many more options than the original version. I've been trying to decide whether it would help at all if I created a tutorial video or an in-depth document explaining how to use it. The problem with the first is that I'm not too familiar with the art of video editing and the problem with the second is that probably no one will read it anyways.
So if I put a chest token on the board how do I trap it? I used to just put it(token) on the DM layer and it would work and payers could see it. That stopped working a few days ago. They can only see the chest tile on the map or token layer and trying to set a trap on them fomr there does not work. As far at the macro button. Let me clarify. I can show or hide it as you are stating BUT I have a permanent Macro button showing up on the upper left that also seems to have the remnants of a gray box boarding it. It wont go away. I even disabled and then uninstalled ALL Macros and it is still there.&nbsp;If you click on anything that Macro button pops up.
1486177125

Edited 1486177729
Ada L.
Marketplace Creator
Sheet Author
API Scripter
That's a token macro. Whenever a macro is set to be a token macro, it shows up any time that you have any token selected. You trap your chest token by selecting the token, then pressing that token macro button. It will display a menu in your chat that will let you set up the trap properties. Could you provide the following information: What version of It's A Trap are you using? If you are using a trap theme, which theme are you using? What version is it? Is there an error that is printed in your API console? If so, please share the error here. What are the exact steps you take that can be done to reliably reproduce the issue?
Game set up to use Community 5e sheet Ver 3.3 I reloaded all Necessary API's and its a trap and patched as advised above. (Should I see all the dependent scripts listed as running as well?) Restarting sandbox due to script changes... Previous shutdown complete, starting up... Spinning up new sandbox... "It's A Trap!: Registered TrapTheme - default." "☒☠☒ Initialized It's A Trap! using theme 'default' ☒☠☒" I follow the quick trap guide and my issues above still persist. Players cannot see chests trapped per the instructions. I&nbsp;then disabled and erased ALL Macros and the Macro tab still shows up at the top left if any token is clicked on. Also no Macros are Clicked to run. Is there a way to flush/ reset the game cache without loosing everything to clean up the code?
1486179409

Edited 1486179473
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ah, ok... The 5E Community trap theme has been discontinued for some time, actually. Due to issues with it pulling the attributes from the 5E Community character sheet, I could not get it to work reliably for users. So, unfortunately I decided to remove it from the repository. Maybe I'll return to it and remake it some other time when I find a more reliable way to pull calculated attributes from the 5E Community sheet. As for the macro reappearing, the script is designed to always reinstall the script if it sees that it isn't there. You can make it stop appearing by unchecking the "token action" checkbox for the macro.
ahhh well your&nbsp;API is awesome! We may have to transition to a different sheet then.
1486180589
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Thanks, I hope one of the other sheets and its theme works out! Let me know if you're still having trouble with one of those.
Hi&nbsp;Stephen~ In the Pathfinder, there was a rogue ability called&nbsp;Trap Spotter. Trap Spotter (Ex) Benefit : Whenever a rogue with this talent comes within 10 feet of a trap, she receives an immediate Perception skill check to notice the trap. This check should be made in secret by the GM. Can you make additional options of passively search, which traps can only be passively&nbsp;discovered by specific character(by input character name)? I very like this API! Thank you!
1486226966
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Lin O. said: Hi&nbsp;Stephen~ In the Pathfinder, there was a rogue ability called&nbsp;Trap Spotter. Trap Spotter (Ex) Benefit : Whenever a rogue with this talent comes within 10 feet of a trap, she receives an immediate Perception skill check to notice the trap. This check should be made in secret by the GM. Can you make additional options of passively search, which traps can only be passively&nbsp;discovered by specific character(by input character name)? I very like this API! Thank you! Thanks for bringing this ability to my attention. It certainly sounds like something that I could add into the Pathfinder theme. I'll add it to the roadmap.
Hey Stephen, I found your API on the Roll20 GitHub, and immediately tried it out! &nbsp;Unfortunately, I'm having an issue with the API and themes. Can you please help? Background: 1) I manually copied all dependencies (VectorMath, MatrixMath, PathMath, TokenCollision, ItsATrap, HTMLBuilder, and ItsATrap PathfinderTheme) &lt;- In that order. 2) I'm trying to use the Pathfinder theme. 3) No matter which point of "ItsATrap" I tried to change from default -&gt; Pathfinder, all of the initialization would only use the default theme. Screenshot: Notes: &nbsp; 1) When I used the one-click API, everything worked smooth as butter. 2) I tried each of these changes individually. &nbsp;I did them all together this time to show you all the ones I tried changing. JSON off the token: {"message":"OOPS! You stepped in poop!","attack":12,"damage":"2d4576","save":"ref","saveDC":15,"spotDC":2999,"fx":{"name":"explosion"},"stopAt":"edge"} Any help you can give me would be very appreciated!
1486407328
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Wow, that's one epic lawn-mine trap there...&nbsp; The script is designed to get the configured trap theme from the One-Click user options. If it's not able to get the One-Click user options it will default to whatever's already in the ItsATrap state or the default trap theme if that isn't set either.&nbsp; Since you've manually copied It's A Trap in, here's what you can do to hack the code to use the Pathfinder trap theme. Assuming you're using It's A Trap v3.3, just replace line 220 with the following: return trapThemes['Pathfinder'];
Hey! Just started toying with API scripts today and I'm already loving your trap mod. I did, however, run into a problem where all my traps would be triggered even by flying creatures (creatures with the fluffy wings status symbol) no matter wether the traps were configured to trigger on fliers or not. Any idea what I might be doing wrong? Thanks for your patience in advance!
1486524629
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Looks like you've found a bug in my script. It will take a while before I can get the fix into the Roll20 repository and One-Click, but for now here's an easy way for anyone to patch it so that flying tokens will be properly affected (or unaffected). Replace line 236 in the getTrapCollisions function with this: return x.get("status_fluffy-wing");
Thanks for the quick reply!
1486587894

Edited 1486588091
Hey Stephen! &nbsp;I implemented your script today, and I too totally love it. &nbsp;I am however having trouble getting my players to discover traps (even when their passive perceptions are higher than the spot DC I have configured for the trap, and their token is within range of the 'maximum search distance' setting). &nbsp;I'm attaching a screenshot of the trap's configuration settings in case it helps. &nbsp;I should add that the trap triggers and applies damage perfectly when a player token passes over it. As a related question: does a player's active trap check (say with an intentional investigation check) automatically detect a trap as well? &nbsp;If so, I can't get that to work either. Thanks in advance!
1486589819
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The script does not currently support active search checks. I'll take a look at what's going on with the passive perception, but I need the following information: Which trap theme are you using? Is there any sort of error message in your API console?
1486590306
Ziechael
Forum Champion
Sheet Author
API Scripter
Would GM Only affect spot checks?
1486590831
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: Would GM Only affect spot checks? No, that would only affect the activated trap. It would make it so only the GM receives a message about the trap going off.&nbsp;
1486590892
The Aaron
Pro
API Scripter
1. 5e OGL 2.&nbsp;He's getting: "TypeError: Cannot read property '1' of undefined\n &nbsp; &nbsp;at apiscript.js:1649:34\n &nbsp; &nbsp;at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)\n &nbsp; &nbsp;at toSegments (apiscript.js:1638:11)\n &nbsp; &nbsp;at apiscript.js:1758:41\n &nbsp; &nbsp;at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)\n &nbsp; &nbsp;at Function.&lt;anonymous&gt; (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)\n &nbsp; &nbsp;at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)\n &nbsp; &nbsp;at _toSegmentsMany (apiscript.js:1757:12)\n &nbsp; &nbsp;at Object.toSegments (apiscript.js:1630:20)\n &nbsp; &nbsp;at Function.filterTokens (apiscript.js:10491:35)" Pretty sure it's that pathmath bug.
1486591057
The Aaron
Pro
API Scripter
Yup, that was it. &nbsp;1.4.1 sorted it out.
1486592193
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ah, thanks for helping to resolve the issue!
i keep getting the following error when I hit the creation macro button: "ItsATrapCreationWizard: Cannot read property 'getThemeProperties' of undefined" "TypeError: Cannot read property 'getThemeProperties' of undefined\n at displayWizard (apiscript.js:5433:13)\n at apiscript.js:5879:9\n at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:34), &lt;anonymous&gt;:65:16)\n at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:34), &lt;anonymous&gt;:70:8)\n at /home/node/d20-api-server/api.js:1494:12\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)\n at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)\n at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)\n at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400" I have all of the latest dependancies and setup a token following your instructions, but no joy. Any help, is this the PathMath issue?
1486601653
Ada L.
Marketplace Creator
Sheet Author
API Scripter
From the look of this error, it is likely that you've entered the wrong value in for the Trap Theme ID in the One-Click options. Which trap theme are you trying to use?
5e-Shaped, if I put 5e-OGL&nbsp; I get the same error (i have both 5e-Shaped and 5e-OGL scripts installed). If I change it to default I get nothing, no error but nothing comes up from the macro.
ok, finally got it working, just turned things off and on again and finally it came up.&nbsp; I think I was typing 5e-shaped instead of 5E-Shaped, looks like the caps are necessary
1486602326
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The E in 5E needs to be uppercase. Trap Theme IDs are case-sensitive.
Thanks to The Aaron for helping me out! &nbsp;And thanks Stephen for the response! &nbsp;Great script!
1486652505
John D.
Sheet Author
API Scripter
Hello, may I ask how to set up a trap to be activated by Aura like the Grinder pit in this gif? I'm trying to set it up using It's A Trap! D&D 5E OGL theme.