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

December 19 (8 years ago)
Thought that was the case. The trigger feature is awesome, btw. It opens up tons of possibilities. Used it as a means of dropping increasingly more difficult waves of mobs around the party. The only thing was that occasionally the mobs would seem to trigger independently.  Was checking to see if I could trick it by lowering the proximity to a negative number or something like that.
December 19 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I can see the use for that. I'll keep it in mind for future enhancements.
December 27 (8 years ago)
I'm stuck on this part...

"activate its 'ItsATrap_trapCreationWizard' token macro."

How do I activate the macro?

Thanks
December 27 (8 years ago)
NM. It creates a macro. 

Maybe include that in the instructions? "You should have a new Macro called..."
December 27 (8 years ago)
quick question, what would i have to change exactly to get this to work fine for DnD 4e? 
December 27 (8 years ago)

Edited December 27 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Ryan T. said:

quick question, what would i have to change exactly to get this to work fine for DnD 4e? 

You would need to implement a trap theme for whatever D&D 4E sheet you are using. 
See https://github.com/Roll20/roll20-api-scripts/blob/master/Its%20A%20Trap/3.1/ItsATrap.js#L1379 for the TrapTheme base class and use the 5E-OGL TrapTheme (https://github.com/Roll20/roll20-api-scripts/blob/master/ItsATrap_theme_5E_OGL/3.0/TrapTheme.js) implementation as a reference for implementing your trap theme.
December 30 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

News!

I've got a big update for It's A Trap planned for the near future. I've come up with some new math and rewrote the Token Collisions script to handle collisions with even better pixel-perfect accuracy. This will affect It's A Trap in allowing users to specify trigger areas for traps defined by arbitrary polygon paths! 

The new version of It's A Trap isn't ready yet, but you can try out the new pixel-perfect collisions by grabbing the newest Path Math and Token Collisions scripts:
Path Math v1.4
Token Collisions v1.5

Since It's A Trap v3.3 is soon going to support triggers defined by paths, there's going to be a bit of a paradigm shift on how triggers for traps are set up. Specifically, I'm going to be getting rid of the Triggers property. The reasons are as follows:
  • If mishandled, the Triggers property could lead to infinite loops.
  • In v3.3, it will be cleaner to create a path, and then set one or more trap-like objects to be triggered by that path.
  • Traps activated by the Triggers property could still be activated by bumping into them. For some types of trap-like objects such as secret doors, this might be undesirable.
  • The code support needed for the Triggers property produces a lot of clutter in the script, and I'm trying to make it cleaner.
I'd like to present the opportunity for you, the script users, to provide some input on this matter. Is the Triggers property useful to you? Useful enough to keep, even when the path-based triggers feature is rolled out? Are there other new features you'd like to see in this script?

December 30 (8 years ago)
I like the fact that triggers can be used to set off something that the players never even come near to. The path based trigger is exiting, but my guess is that both will continue to be useful.
December 30 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Stephen, will I need to change how my script is interacting with Token Collisions or will it still function as normal?
December 30 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Scott C. said:

Stephen, will I need to change how my script is interacting with Token Collisions or will it still function as normal?

The interface for Token Collisions isn't changing. It will just automagically support the pixel-perfect collisions and polygon/path collisions.
New classes have been added to the PathMath namespace, but none of the existing interfaces for that have changed either.
December 30 (8 years ago)

Edited December 30 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Awesome.

And Thank you for the quick response.
January 01 (8 years ago)
How do I remove the 'ItsATrap_trapCreationWizard' token macro from all my tokens? I tried disabling the API script and all of its dependencies, and it still keeps appearing.
January 01 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Carlo said:

How do I remove the 'ItsATrap_trapCreationWizard' token macro from all my tokens? I tried disabling the API script and all of its dependencies, and it still keeps appearing.

Just uninstall the script and remove the macro from your macros list.
You could also just uncheck the "Show as Token Action" box on the macro.
January 02 (8 years ago)
Got it, thanks!
January 05 (8 years ago)

Edited January 06 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Update v3.3 Beta

This version includes:
  • Made the Trap Creation Wizard a bit more organized.
  • There is now a new Set Triggers option in the wizard which allows you to set one or more arbitrary paths on the GM layer as the trigger for the trap. By default, the trap's own token is used as its trigger.
  • Trap types have been changed from a drop-down list to a text input.
Thanks for the input on the usefulness of the Triggers option. Since many of you would still find it useful with this update, I've left it in. Here's an animation demonstrating how to set paths as triggers for your traps:



Get it here: https://github.com/Cazra/roll20-api-scripts/blob/t...
You'll also need Path Math v1.4 and Token Collisions v1.5 from the same branch.

Pull request/One-Click pending.
January 05 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
Awesome update, addresses the exact problem I had with triggers in my mage's tower of doom... can't wait to set up my next trap filled dungeon!! =D
January 17 (8 years ago)
This is a fantastic resource now, but a couple of questions:

is there a way to copy the details from one trap to another, for example if i have 2 pit traps, instead of reentering all the details?
Is there a way to link this to the powercards format?
January 17 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Jon M. said:

is there a way to copy the details from one trap to another, for example if i have 2 pit traps, instead of reentering all the details?

Right now the only way to copy the details from one trap to another is to copy the contents of the trap token's GM Notes to the other trap token.
Jon M. said:
Is there a way to link this to the powercards format?

I am not familiar with this powercards format. Could you elaborate?
January 17 (8 years ago)
I tried copying the gm notes but got this error next to the message link :ERROR: invalid TrapEffect JSON.

for powercards, the format is proably best explained in the first post of its thread: 
https://app.roll20.net/forum/post/4285059/script-powercards-3-thread-4/?pagenum=1 
January 17 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Hmm.. Copying the GM Notes contents normally works.

For the Powercards stuff, you may be able to link it up by putting a !power command into a trap's API command property. 
January 18 (8 years ago)

Edited January 18 (8 years ago)
This looks so amazing! Thank you very much for the hard work but I'm having trouble getting it working, a little help?

My problem: I've set a token to the GM layer, set the cobweb icon onto the trap, but when I click the "ItsATrap_trapCreationWizard_showMenu" macro (that was pre-made when I installed the script) I don't get the trap menu appearing in my chat. I don't have any errors appear in my API output console (in fact, nothing happens there at all when I click the macro). When I don't have the token selected and run the macro, it gives the normal "you need to select a token" error in the API output so at least I know the script is running. I have the 5E-OGL theme running and set up and all my other scripts are working fine (I have disabled all of them except for this one to test for the error). Thoughts?

Edit: When I move a PC token on top of the trap, it triggers the token with the cobweb and gave me a generic trigger message (copied:)
IT'S A TRAP!!!
Target:Rob
MISS!
January 18 (8 years ago)

Edited January 18 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I cannot reproduce this issue.

Are you running v3.3? If so, could you add this:

log('/w "' + _fixWho(who) + '" ' + msg);

below line 1456 in the It's A Trap v3.3 script and tell me what you get printed in the console?
a few questions and notes if you will. i'm using D5e shaped sheet campaign and a blank map page with nothing at all modified from default options and a 1 unit (1 square) trap item. target tokens are 1 unit in size.

a) if installing via github (3.3 br), what else do i need to install for d5e shaped? i've installed the four packages needed for default function, i'm referring to just files needed for additional d5e shaped ops.
b) i understand that you need to be themed before your pc's passive works, correct?
c) my trap fires when a pc comes in trigger range but there's no target(s) and no hit/miss for the targets in blast range
d) my pc that triggered the trap gets pushed 1/2 a square back diagonally so my pc is sitting precisely in the middle of four squares
January 18 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

FirefighterBlu3 said:

a few questions and notes if you will. i'm using D5e shaped sheet campaign and a blank map page with nothing at all modified from default options and a 1 unit (1 square) trap item. target tokens are 1 unit in size.

a) if installing via github (3.3 br), what else do i need to install for d5e shaped? i've installed the four packages needed for default function, i'm referring to just files needed for additional d5e shaped ops.
b) i understand that you need to be themed before your pc's passive works, correct?
c) my trap fires when a pc comes in trigger range but there's no target(s) and no hit/miss for the targets in blast range
d) my pc that triggered the trap gets pushed 1/2 a square back diagonally so my pc is sitting precisely in the middle of four squares

a) If you've got all the dependencies for It's A Trap also installed (including Path Math 1.4 and Token Collisions 1.5, which are new), then you just need to install the 5E Shaped trap theme from One-Click.
b) Yes, passive perception only works with a theme installed.

I'm not sure what your points are about notes c and d. Could you elaborate on what you've got your traps' properties set to and what you're trying to do with them?
January 18 (8 years ago)

Edited January 18 (8 years ago)
(Edit: I was initially using the one-click installed version (3.1?) and have since updated to 3.3 because I could not edit the other version)
Thanks for the help! Using 3.3 and putting the log line after 1456 like you said:

"/w \"Blake\" <div style=\"background: #fff; border: solid 1px #000; border-radius: 5px; font-weight: bold; margin-bottom: 1em; overflow: hidden;\"><div style=\"background: #000; color: #fff; text-align: center;\">Trap Configuration</div><div style=\"padding: 5px; text-align: center;\"><div style=\"\"><h4 style=\"\">Core properties</h4><table style=\"\"><tr title=\"The name of the trap\" style=\"\"><td style=\"font-size: 0.8em;\">[Name](!ItsATrap_trapCreationWizard_modifyTrapCore name&&?{Name The name of the trap })</td><td style=\"font-size: 0.8em;\">trap</td></tr><tr title=\"Is this a trap, or some other hidden secret?\" style=\"\"><td style=\"font-size: 0.8em;\">[Type](!ItsATrap_trapCreationWizard_modifyTrapCore type&&?{Type Is this a trap, or some other hidden secret? })</td><td style=\"font-size: 0.8em;\">trap</td></tr><tr title=\"The message displayed when the trap is activated.\" style=\"\"><td style=\"font-size: 0.8em;\">[Message](!ItsATrap_trapCreationWizard_modifyTrapCore message&&?{Message The message displayed when the trap is activated. })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"A disabled trap will not activate when triggered, but can still be spotted with passive perception.\" style=\"\"><td style=\"font-size: 0.8em;\">[Disabled](!ItsATrap_trapCreationWizard_modifyTrapCore disabled&&?{Disabled A disabled trap will not activate when triggered, but can still be spotted with passive perception. |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"When the trap is activated, should its results only be displayed to the GM?\" style=\"\"><td style=\"font-size: 0.8em;\">[GM Only](!ItsATrap_trapCreationWizard_modifyTrapCore gmOnly&&?{GM Only When the trap is activated, should its results only be displayed to the GM? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"Additional secret notes shown only to the GM when the trap is activated.\" style=\"\"><td style=\"font-size: 0.8em;\">[GM Notes](!ItsATrap_trapCreationWizard_modifyTrapCore notes&&?{GM Notes Additional secret notes shown only to the GM when the trap is activated. })</td><td style=\"font-size: 0.8em;\"></td></tr></table><h4 style=\"margin-top: 2em;\">Shape properties</h4><table style=\"\"><tr title=\"Should this trap affect flying tokens (fluffy-wing status )?\" style=\"\"><td style=\"font-size: 0.8em;\">[Affects Flying Tokens](!ItsATrap_trapCreationWizard_modifyTrapCore flying&&?{Affects Flying Tokens Should this trap affect flying tokens (fluffy-wing status )? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"How far away can the trap affect other tokens?\" style=\"\"><td style=\"font-size: 0.8em;\">[Blast distance](!ItsATrap_trapCreationWizard_modifyTrapCore effectDistance&&?{Blast distance How far away can the trap affect other tokens? })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"Does this trap stop tokens that pass through its trigger area?\" style=\"\"><td style=\"font-size: 0.8em;\">[Stops Tokens At](!ItsATrap_trapCreationWizard_modifyTrapCore stopAt&&?{Stops Tokens At Does this trap stop tokens that pass through its trigger area? |center|edge|none})</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"Is the shape of the trap's effect circular or square?\" style=\"\"><td style=\"font-size: 0.8em;\">[Trap shape](!ItsATrap_trapCreationWizard_modifyTrapCore effectShape&&?{Trap shape Is the shape of the trap's effect circular or square? |circle|square})</td><td style=\"font-size: 0.8em;\">circle</td></tr></table><h4 style=\"margin-top: 2em;\">Trigger properties</h4><table style=\"\"><tr title=\"To set paths, you must also select the paths that trigger the trap.\" style=\"\"><td style=\"font-size: 0.8em;\">[Set Trigger](!ItsATrap_trapCreationWizard_modifyTrapCore triggerPaths&&?{Set Trigger To set paths, you must also select the paths that trigger the trap. |self|paths})</td><td style=\"font-size: 0.8em;\">self</td></tr><tr title=\"A list of the names or token IDs for other traps that are triggered when this trap is activated.\" style=\"\"><td style=\"font-size: 0.8em;\">[Other Traps Triggered](!ItsATrap_trapCreationWizard_modifyTrapCore triggers&&?{Other Traps Triggered A list of the names or token IDs for other traps that are triggered when this trap is activated. })</td><td style=\"font-size: 0.8em;\"></td></tr></table><h4 style=\"margin-top: 2em;\">Reveal properties</h4><table style=\"\"><tr title=\"How far away can characters passively search for this trap?\" style=\"\"><td style=\"font-size: 0.8em;\">[Max Search Distance](!ItsATrap_trapCreationWizard_modifyTrapCore searchDist&&?{Max Search Distance How far away can characters passively search for this trap? })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"Should this trap be revealed to the players when it is activated?\" style=\"\"><td style=\"font-size: 0.8em;\">[When Activated](!ItsATrap_trapCreationWizard_modifyTrapCore revealToPlayers&&?{When Activated Should this trap be revealed to the players when it is activated? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"Should this trap be revealed to the players when a character notices it by passive searching?\" style=\"\"><td style=\"font-size: 0.8em;\">[When Spotted](!ItsATrap_trapCreationWizard_modifyTrapCore revealWhenSpotted&&?{When Spotted Should this trap be revealed to the players when a character notices it by passive searching? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"When this trap is revealed, which layer is it revealed on?\" style=\"\"><td style=\"font-size: 0.8em;\">[Layer](!ItsATrap_trapCreationWizard_modifyTrapCore revealLayer&&?{Layer When this trap is revealed, which layer is it revealed on? |map|objects})</td><td style=\"font-size: 0.8em;\">map</td></tr></table><h4 style=\"margin-top: 2em;\">Special properties</h4><table style=\"\"><tr title=\"An API command which the trap runs when it is activated. The constants TRAP_ID and VICTIM_ID will be replaced by the object IDs for the trap and victim.\" style=\"\"><td style=\"font-size: 0.8em;\">[API Command](!ItsATrap_trapCreationWizard_modifyTrapCore api&&?{API Command An API command which the trap runs when it is activated. The constants TRAP_ID and VICTIM_ID will be replaced by the object IDs for the trap and victim. })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"What special FX are displayed when the trap is activated?\" style=\"\"><td style=\"font-size: 0.8em;\">[Special FX](!ItsATrap_trapCreationWizard_modifyTrapCore fx&&?{FX Name The name of the special FX. }&&?{FX Offset The offset (in units) of the special FX from the trap's center. Format: [X,Y] }&&?{FX Direction The directional vector for the special FX (Leave blank to direct it towards characters). Format: [X,Y] })</td><td style=\"font-size: 0.8em;\">None</td></tr><tr title=\"A sound from your jukebox that will play when the trap is activated.\" style=\"\"><td style=\"font-size: 0.8em;\">[Sound](!ItsATrap_trapCreationWizard_modifyTrapCore sound&&?{Sound A sound from your jukebox that will play when the trap is activated. })</td><td style=\"font-size: 0.8em;\"></td></tr></table><h4 style=\"margin-top: 2em;\">Theme-specific properties</h4><table style=\"\"><tr title=\"The trap's attack roll bonus vs AC.\" style=\"\"><td style=\"font-size: 0.8em;\">[Attack Bonus](!ItsATrap_trapCreationWizard_modifyTrapTheme attack&&?{Attack Bonus The trap's attack roll bonus vs AC. })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"The dice roll expression for the trap's damage.\" style=\"\"><td style=\"font-size: 0.8em;\">[Damage](!ItsATrap_trapCreationWizard_modifyTrapTheme damage&&?{Damage The dice roll expression for the trap's damage. })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"Show the Saving Throw result only to the GM?\" style=\"\"><td style=\"font-size: 0.8em;\">[Hide Save Result](!ItsATrap_trapCreationWizard_modifyTrapTheme hideSave&&?{Hide Save Result Show the Saving Throw result only to the GM? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"Does the trap deal half damage on a miss?\" style=\"\"><td style=\"font-size: 0.8em;\">[Miss - Half Damage](!ItsATrap_trapCreationWizard_modifyTrapTheme missHalf&&?{Miss - Half Damage Does the trap deal half damage on a miss? |yes|no})</td><td style=\"font-size: 0.8em;\">no</td></tr><tr title=\"The type of saving throw used by the trap.\" style=\"\"><td style=\"font-size: 0.8em;\">[Saving Throw](!ItsATrap_trapCreationWizard_modifyTrapTheme save&&?{Saving Throw The type of saving throw used by the trap. |none|str|dex|con|int|wis|cha})</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"The DC for the trap's saving throw.\" style=\"\"><td style=\"font-size: 0.8em;\">[Saving Throw DC](!ItsATrap_trapCreationWizard_modifyTrapTheme saveDC&&?{Saving Throw DC The DC for the trap's saving throw. })</td><td style=\"font-size: 0.8em;\"></td></tr><tr title=\"The skill check DC to spot the trap.\" style=\"\"><td style=\"font-size: 0.8em;\">[Spot DC](!ItsATrap_trapCreationWizard_modifyTrapTheme spotDC&&?{Spot DC The skill check DC to spot the trap. })</td><td style=\"font-size: 0.8em;\"></td></tr></table><div style=\"margin-top: 2em;\">[Activate Trap](!itsATrapRemoteActivate)</div></div></div></div>"
January 18 (8 years ago)

Edited January 18 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Ok, so it should be whispering a message with the menu to the player named "Blake". If you try something like 

/w "Blake" This is a test.

in the chat and that works, then the menu should also work for you. If that doesn't work, then my best guess is that some other script might be overriding sendChat to cause problems here, because I can't reproduce the issue in my clean environment. 
Yeah "/w "Blake" This is a test." Is working just fine, also other scripts are sending me messages (whispers) just fine. I'll try turning off all other scripts again and see what happens. Thanks for the help though!

January 21 (8 years ago)

Edited January 21 (8 years ago)
How do I 'reset' a trap so that when a player moves over it again it trips again?  I have scythe blades that swing each time you step in their area, but my traps set off the first time and then won't trigger again.

Also, what's the syntax to get my audio file to play when the trap is triggered?  I'm not sure exactly what to write in that box.  I used the basic Several Swinging Scythes Trap   sound.
January 22 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
You can reset a trap by returning it to the GM layer.
January 24 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
Am i missing something obvious to get fx to work?
{"type":"natural occurrence","message":"A plume of acidic gas is discharged from a natural vent in the floor.","stopAt":"none","triggerPaths":["-KbGqpRadoHyYwQVNx7k"],"fx":{"name":"explode-acid"},"sound":"flames","damage":"4d8","missHalf":true,"save":"fort","saveDC":18}
January 24 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Ziechael said:

Am i missing something obvious to get fx to work?
{"type":"natural occurrence","message":"A plume of acidic gas is discharged from a natural vent in the floor.","stopAt":"none","triggerPaths":["-KbGqpRadoHyYwQVNx7k"],"fx":{"name":"explode-acid"},"sound":"flames","damage":"4d8","missHalf":true,"save":"fort","saveDC":18}

Your JSON is working fine for me after I remove the sound option (since I don't have a sound called "flames"). Are you sure that you are spelling the sound exactly how it appears in your jukebox?
January 24 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
ah, that might be it... in my test game i had no sound named that but didn't connect that 'failing' with the fx not working... just tested and works amazingly well can't wait for tonights game now!!
Will be more thorough before panic posting an hour before play in future sorry!
January 24 (8 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
No problem! I'll I'll see about fixing the next version so that if the sound doesn't exist, it'll still do the rest of the trap's output, but it will send the GM a message about it.
January 26 (8 years ago)

Edited January 26 (8 years ago)
Good day,

When attempting to use the creation wizard, I get the following error within the API:

"ItsATrapCreationWizard: HtmlBuilder is not defined"
"ReferenceError: HtmlBuilder is not defined\n at displayWizard (apiscript.js:4306:23)\n at apiscript.js:4789:9\n at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16)\n at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8)\n at /home/node/d20-api-server/api.js:1489: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"

The token is on the GM layer with the cobweb applied to it. Additionally, there is no feedback of any kind, whether in the form of a menu or chat, in the actual roll20 application when using the button. Simply nothing happens, and the API has the previously noted entry.

Thank you very much for letting me know what I might be doing wrong.
January 26 (7 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
It sounds like for some reason HTML Builder, which is a dependency for this script, was not installed when you installed this script. You can either try reinstalling It's A Trap through the One-Click installer and see if it picks it up this time, or you can manually add the HTML Builder script: https://github.com/Roll20/roll20-api-scripts/blob/master/HtmlBuilder/1.0/script.js
January 26 (7 years ago)

Edited January 26 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey Stephen,

Did you make changes to PathMath lately? My calls to it in Page Navigator are suddenly crashing the sandbox and I haven't made any changes to the script since it was last working.

Error:
TypeError: Cannot read property '1' of undefined TypeError: Cannot read property '1' of undefined at apiscript.js:1656:34 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at toSegments (apiscript.js:1638:11) at apiscript.js:1758:41 at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16) at Function. (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14) at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at _toSegmentsMany (apiscript.js:1757:12) at Object.toSegments (apiscript.js:1630:20) at _.each.mapSurrounding (apiscript.js:3653:33)

EDIT: Ok, this is really weird, moved it back to a v1.0 from v1.4 and it's still throwing the error. What the heck? This was working fine last week.

I apologize for hijacking your It's a Trap thread, but seemed the most appropriate place.
January 26 (7 years ago)

Edited January 26 (7 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Yes, Path Math is now v1.4. Although some new functions and classes were added in v1.4 to support the new features in Token Collisions 1.5 and It's A Trap 3.3, the existing interface for it hasn't changed. Neither of Path Math's dependencies, Vector Math or Matrix Math, have changed either.

Can you share the code you are using to call PathMath.toSegments()?
January 26 (7 years ago)

Edited January 26 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, here's a gist of a reasonably simple replication. Figured you didn't want to have to dig through all of PageNavigator to find the relevant code.

The part I can't figure out is that this worked perfectly fine last week when I did some updating to PageNavigator and I haven't changed anything since it was last working, and the problem seems to persist even if I go back a version on PathMath.
January 26 (7 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Thanks. I just tried to reproduce your issue using your test script. In my API sandbox campaign, I didn't have any issues, so to be sure I also started a brand new campaign and only installed It's A Trap and its dependencies (including Path Math 1.4) and your test script. 

I drew several walls onto the dynamic lighting layer using polygon lines, freehand lines, and even ellipses (newly supported in Path Math 1.4). All of these appear to be working fine, as I see the correct logging output for wallPaths from your script. I could not get it to produce an error.
January 26 (7 years ago)

Edited January 26 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmmm, ok, that's interesting, I'll keep digging then.

EDIT: Well looks like there's something bugged in my development game. Like you, it works fine for me in other games. Thanks for looking into it Stephen.
January 27 (7 years ago)

Edited January 27 (7 years ago)
The Aaron
Pro
API Scripter
Seeing that error in game right now:
For reference, the error message generated was: TypeError: Cannot read property 'get' of undefined
TypeError: Cannot read property 'get' of undefined
  at .each..each..chain.map..each.getDestinationCollisions (apiscript.js:12059:37)
  at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16)
  at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8)
  at TrackedObj.set (/home/node/d20-api-server/api.js:909:14)
  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)


??
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
"ERROR - It's A Trap!: Cannot read property '1' of undefined"
"TypeError: Cannot read property '1' of undefined
 at apiscript.js:9631:34
 at Function..each..forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)
 at toSegments (apiscript.js:9620:11)
 at apiscript.js:9740:41
 at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16)
 at Function.<anonymous> (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14)
 at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)
 at _toSegmentsMany (apiscript.js:9739:12)
 at Object.toSegments (apiscript.js:9612:20)
 at Function.filterTokens (apiscript.js:15452:35)"
"ERROR - It's A Trap!: Cannot read property '1' of undefined"

January 27 (7 years ago)

Edited January 27 (7 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I don't recognize the function getDestinationCollisions(). What script is that from?

Edit: Okay, I'm seeing the error too now. I'll try to get it fixed as soon as possible.
January 27 (7 years ago)
The Aaron
Pro
API Scripter
My GM dropped back to PathMath 1.4 and it hasn't crashed since.

January 27 (7 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I've got a patch for toSegments(). Try this and let me know if you have any more trouble.

    /**
     * Converts a path into a list of line segments.
     * This supports freehand paths, but not elliptical paths.
     * @param {(Path|Path[])} path
     * @return {Segment[]}
     */
    function toSegments(path) {
        if(_.isArray(path))
            return _toSegmentsMany(path);


        var _path = JSON.parse(path.get('_path'));
        var transformInfo = getTransformInfo(path);


        var segments = [];
        var prevPt;


        _.each(_path, tuple => {
            let type = tuple[0];


            // Convert the previous point and tuple into segments.
            let newSegs = [];
            if(type === 'C') { // Cubic Bezier
              newSegs = _toSegmentsC(prevPt, tuple, transformInfo);
              prevPt = newSegs[newSegs.length - 1][1];
            }
            if(type === 'L') { // Line
              newSegs = _toSegmentsL(prevPt, tuple, transformInfo);
              if(newSegs.length > 0)
                prevPt = newSegs[0][1];
            }
            if(type === 'M') { // Move
              prevPt = tupleToPoint(tuple, transformInfo);
            }
            if(type === 'Q') { // Freehand (tiny Quadratic Bezier)
              newSegs = _toSegmentsQ(prevPt, tuple, transformInfo);
              if(newSegs.length > 0)
                prevPt = newSegs[0][1];
            }


            _.each(newSegs, s => {
              segments.push(s);
            });
        });


        return segments;
    }
January 27 (7 years ago)

Edited January 27 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Getdestinationcollisions is from page navigator, but pathmath isn't called from there, really hate the way the new sandbox describes where the error is.

ill try that patch come morning, thanks for the help Stephen.
January 27 (7 years ago)
The Aaron
Pro
API Scripter
Yeah, there seems to be something fouled up in the way errors are reported lately.  I was having the same issue yesterday trying out KABOOM.