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

[Help] It'satrap! Only works occasionally?

Hello, As a heads up I am beyond noob at scripting anything so any advice will have to be dumbed down quite a bit for me to understand. I really want to incorporate traps into my campaigns and when I saw the script for "Its a trap!" I thought this would be great! I know it relies on Vector Math and Token Collision so I made sure to copy and paste those into separate scripts but now when a token passes over my traps it won't do anything the first few times. At first I thought maybe I did something wrong but then suddenly it worked out no where. I tried finding a pattern as to what would make it work (refreshing, restarting scripts, etc.) but so far nothing. The only scripts i'm using currently are the 3 mentioned before and the "Blood and Honor" script. Could those scripts be interfering? I'm open any advice anyone can think of!
1434939434
The Aaron
Pro
API Scripter
I wouldn't think Blood and Honor would interfere with the other scripts. You can disable Blood and Honor and test it. I don't know much about It's a Trap, You might try it in a fresh campaign and see if it works.
Well apparently it does because I deactivated it and sure enough the traps work. But soon as its activated I get nothing again. Huh that is really weird. Blood and Honor is probably not meshing with Vector or Collison since all Trap really does is move tokens right? At least that is what it appears to me.
1434943855
The Aaron
Pro
API Scripter
All the scripts exist in a global namespace. If more than one script use the same name, they will break the other. I'll try and take a look at B&H tomorrow to see if anything stands out.
Alright thanks buddy. Sorry I cant be of more help
Make sure that whatever page you are working on for the trap in question is the page with the player ribbon on it. If you test a trap not on the ribbon page. It will seem as if the trap isn't working. In fact, I have had it trigger traps on the ribbon page when moving a token on a totally different page. So beware, the API focuses on the ribbon (player) page. Hopes this helps with your problem or maybe helps avoid future problems. Ryeaa
1434961403
Ziechael
Forum Champion
Sheet Author
API Scripter
I use both blood and honour and It's a Trap (slightly modded to output the traps GM notes to chat). But they both play nicely together. The only thing i can think of that would cause conflict is if you are trying to use the same status markers for your players that are used by the scripts for default actions (the bleeding eye and web are used by GM layered tokens for IAT and the resurrection skull/skull/red X are used by blood and honour). I've never had any problems with either and i run them along side many, many other scripts ;) That all aside, if there is a problem Aaron will find it...
@Ziechael I was actually wondering if there was a version to change the message in chat based on what was in the GM notes since Blood and Honor can tell when noblood is in the GM notes. Any chance I can use your modded version? I didn't know about using the same markers causing problems but for the sake of testing it was just a fresh campaign with random tokens chosen and a very bare-bones character made. No status markers or anything yet it still only worked occasionally. On a side note what scripts should I check out? I'm running 3.5 and really new to this scripting thing so it's a bit intimidating. @Ryeaa I read that on one of the threads looking for an answer but when I tested the API it was on a blank campaign with only one page. I did notice that sometimes the blood and honor script will sometimes drop blood splatter on other pages for PC's though when they take damage. I assume thats because the token's hp drops for all pages when its linked to a character and honestly it's not that big of a deal to just clean up really quick. Thanks for the advice though!
1434981530

Edited 1434981582
Ziechael
Forum Champion
Sheet Author
API Scripter
I don't think the notes would be a conflict as they are looking for specific messages in there. Again, i'm not sure using the status markers would cause problems as the trap script is looking for them on the gm layer only and the blood and honour script only applies its markers under certain circumstances... and removes erroneously applied ones if the conditions aren't met. Ignore that, blood and honour just applies the blood to the map, i was getting it confused with a script that automatically marks your units as dead, really dead or recently resurrected. Here is the code for the modded version i use: /** * A script that checks the interpolation of a token's movement to detect * whether they have passed through a square containing a trap. * * A trap can be any token on the GM layer for which the cobweb status is * active. Flying tokens (ones with the fluffy-wing status or angel-outfit * status active) will not set off traps unless the traps are also flying. * * This script works best for square traps equal or less than 2x2 squares or * circular traps of any size. * * Requires: * Token Collisions * Vector Math * */ var itsATrap = (function() { /** * Returns the first trap a token collided with during its last movement. * If it didn't collide with any traps, return false. * @param {Graphic} token * @return {Graphic || false} */ var getTrapCollision = function(token) { var traps = getTrapTokens(); traps = filterList(traps, function(trap) { return !isTokenFlying(token) || isTokenFlying(trap); }); return TokenCollisions.getFirstCollision(token, traps); }; /** * Determines whether a token is currently flying. * @param {Graphic} token * @return {Boolean} */ var isTokenFlying = function(token) { return (token.get("status_fluffy-wing") || token.get("status_angel-outfit")); }; /** * Moves the specified token to the same position as the trap. * @param {Graphic} token * @param {Graphic} trap */ var moveTokenToTrap = function(token, trap) { var x = trap.get("left"); var y = trap.get("top"); token.set("lastmove",""); token.set("left", x); token.set("top", y); }; /** * Returns all trap tokens on the players' page. */ var getTrapTokens = function() { var currentPageId = Campaign().get("playerpageid"); return findObjs({_pageid: currentPageId, _type: "graphic", status_cobweb: true, layer: "gmlayer"}); }; /** * Filters items out from a list using some filtering function. * Only items for which the filtering function returns true are kept in the * filtered list. * @param {Object[]} list * @param {Function} filterFunc Accepts an Object from list as a parameter. * Returns true to keep the item, or false to * discard. * @return {Object[]} */ var filterList = function(list, filterFunc) { var results = []; for(var i=0; i<list.length; i++) { var item = list[i]; if(filterFunc(item)) { results.push(item); } } return results; } /** * When a graphic on the objects layer moves, run the script to see if it * passed through any traps. */ on("change:graphic", function(obj, prev) { // Objects on the GM layer don't set off traps. if(obj.get("layer") === "objects") { var trap = getTrapCollision(obj); if(trap) { var gmnotes = trap.get('gmnotes'); gmnotes = decodeURIComponent(gmnotes); sendChat("Admiral Ackbar", "IT'S A TRAP!!! " + obj.get("name") + " should have been more careful; " + gmnotes); moveTokenToTrap(obj, trap); if(trap.get("status_bleeding-eye")) { trap.set("layer","map"); toBack(trap); } } } }); })(); I left Admiral Ackbar in there as my players love the reference... but that being said it tended to fail with it removed for some reason lol. Don't forget to have vectormath and tokencollision installed too. In terms of other scripts (i run a long term 3.5 campaign) i use a whole bunch for different reasons: Blood and honour - for extra fun blood drenched map times The script to mark units as dead automatically (modded to also remove them from the turn order) Powercards (the mother of all macro outputters (i have literally 300+ powercards prepared, everything from spells to attacks to saves etc) A script that allows the automation of doors (allowing players to interact with the map for opening doors, chests etc as well as picking locks, searching for traps. TokenMod, for all those times when doing things manually is just too much work! Ammo, a script for managing ammunition Teleporter for quickly moving tokens around large maps (between floors, random portal puzzles etc) art asset locker, for locking annoying art assets in place notelog to make notes on the fly in campaign tokennumbering for automatically numbering mooks A script to randomly rotate graphics for the quick randomisation of graphics (instead of having all those trees look identical) A script that allows me to set tokens as carrying one another, i use a slightly modded version of this for mounting/unmounting GroupInitiative for quickly adding mook initiatives in large encounters and TurnMarker for automatically tracking turns There are probably more i'll add over time as well... as soon as Aaron finishes CharacterMod for example!
1434986130

Edited 1434986218
Well thankfully your script works just fine. Maybe I was using an outdated version or something? Either way thank you very much for helping solve my problem! As much as i'd love to get into Powercards I don't really understand how to set up the macros and everything. Is there like a video for that? Thank you for all your help and quick responses! Edit: Also link to the automatic doors? That could be interesting. Does it work with dynamic lighting too?
1434986841

Edited 1435007546
Ziechael
Forum Champion
Sheet Author
API Scripter
Cool, glad it worked :) I use Matt's door script which i've found to be really versatile, it does require a little bit of set up work but once everything is good to go it's pretty intuitive. It works with DL yes. I can help with Powercards too if you need since mine are 3.5?
1435002376

Edited 1435005121
Thank you so much! This is going to make my campaign a lot better. Sure I can use the help with Powercards if it's not too much trouble. Edit: The link to Matt's door script takes me to some users page?
1435007519
Ziechael
Forum Champion
Sheet Author
API Scripter
Ha sorry, that was a spammer i was banning at the time... the link is fixed now!
1435009176

Edited 1435013366
Oh, didn't realize I was speaking to a moderator nice to meet you lolz! No worries about the link though I wasn't in any particular hurry. Thanks a ton! Edit: Can I just message you about further questions about these scripts? I feel it isn't appropriate to keep posting here when my issue is resolved.
1435031176
The Aaron
Roll20 Production Team
API Scripter
Those sneaky moderators are all over the place. =D Posting questions in the API forum is completely fine provided it's (somewhat) related to the API. The community loves to jump in and help people, so don't feel like you're bothering anyone with your questions. You can of course PM me or Z questions, but you're likely to get a faster response by posting the the API forum. I read every message daily (sometimes hourly!), and Z probably isn't much different. =D
Oh boy a second one. Lolz well that makes me feel a little better at least. Right now i'm having issues with Matt's Door Script. I've linked a switch to a door and had another player open it sucessfully but now i'm having trouble making them unlock it. It says they don't have the skill required to unlock the door and, while there is a clear place to edit that near the top. It doesn't seem to play nice with my 3.5 charactersheet skills. Any suggestions?
1435032049
The Aaron
Pro
API Scripter
Probably have to wait for Z to get up in a few hours and see your post. I've not used Matt's Door script (this is the first time I've actually looked at it!). I'll have to check it out at some point more thuroughly.
Alright could you tell me how to post the part of the script im talking about? So I can show him what ive got (when he does get up). Super duper new to this...
1435033758
The Aaron
Pro
API Scripter
Like this? Formatting a Post When posting on the Forums, you have several formatting options at your disposal. Generally, you can get away with just posting raw text as you write it, but there are some times when formatting can help get your point across more clearly. When posting Macros, Dice Expressions, or API Code Snippets, consider using the Code format option, available by clicking the paragraph symbol ( ¶ ) and selecting it from the list. From: <a href="https://wiki.roll20.net/Forum_Posting" rel="nofollow">https://wiki.roll20.net/Forum_Posting</a>
1435051155
Ziechael
Forum Champion
Sheet Author
API Scripter
I believe there was an issue with Matt's script accepting calculated fields for the attributes used for picking locks etc. I did speak to him about it and he was planning to revisit the script but i'm guessing just never had time... if only there was another friendly neighbourhood scriptomancer out there who might take a look...?! At is was I had to create a number of attributes manually and use those to interact with the script: //========== user customization ========== statusDoors.interactRange = 20; //max range in map units statusDoors.detectionRange = 2; //max range in map units statusDoors.DoorPathColor = "#FFFF00"; statusDoors.attribFindHidden = "FindHiddenDoors"; statusDoors.attribOpenLocks = "PickLocks"; statusDoors.attribFindTraps = "FindTraps"; statusDoors.attribRemoveTraps = "RemoveTraps"; statusDoors.hFlipOnOpen = true; // flip switch control horizontally when opened statusDoors.vFlipOnOpen = true; // flip switch control vetically when opened // usePercentageChecks determines how checks against skills are rolled // when true: attribute score + door modifier &gt;= d100 equals success // when false: d20 + attribute score &gt;= door modifier equals success statusDoors.usePercentageChecks = true; statusDoors.detectHiddenDC = 10; Then once created i had to remember to update them each time the players levelled up which is annoying but workable for now. The party rogue has all of the attributes while the rest only have FindHiddenDoors on their sheets which makes the whole thing a bit easier to manage. Please note that i've set the door interaction range to a high number to allow me to place switches in other rooms, on statues, at the end of puzzles etc. The script seems to look for the players proximity to the door rather than the switch when allowing them to interact with it. Extra bonus tips: I've also used this script to create chests that can be opened and closed (and locked and trapped ;) ) just place the DL line somewhere out of the way and the rest functions as normal. It is worth setting up a journal entry for the door and switch token with the default tokens set up accordingly to your preferred defaults (ie. the door token is a rollable table token scaled to your preferred default size and side with the name of Door and the switch is scaled to the right size and named Switch). You can also set up the Switch token to have token actions that use the commands to search for traps, pick locks etc which allows your players to simply approach a switch, select it and use the token actions to do all that they need to.
@The Aaron ok now I feel dumb lolz. Thanks for pointing that out. @Ziechael I like the idea about the token actions! That is a pretty neat idea I think I will use. So I just create an additional attribute on the third tab under the character sheet page? Sounds simple enough, as long as it matches whats inside the quotations. The door token being a rollable table token is throwing me off a little bit though. I don't mean to be a pain but can you explain how to set something like that up? From what I understand it has to be a table with images corresponding to the desired look of the door (open, or closed) and by changing the values of Bar3 and Max_Bar3 you can effectively change the image to change places with the other image on the table but it doesnt seem to work for me. Maybe I havn't set up my table right or something
1435054005
Ziechael
Forum Champion
Sheet Author
API Scripter
Joe C. said: So I just create an additional attribute on the third tab under the character sheet page? Sounds simple enough, as long as it matches whats inside the quotations. That's right, your players will need to have attributes that the script can recognise, hopefully calculated fields might be possible at some point at which time you'd be able to delete your manual attributes and change the script defaults to match the 3.5 sheet values. Joe C. said: The door token being a rollable table token is throwing me off a little bit though. I don't mean to be a pain but can you explain how to set something like that up? Your best bet here is to refer to the Roll20 oracle (or the wiki pages to be exact). This section relating to creating a rollable table token and how to use it would be of most benefit here. If you are following Matt's setup guide you are no doubt already building up the table with your desired graphics? The beauty of this is that you can add to it on the fly, adding more door types, toggle-able objects and the like. Another tip at this stage is to record your door positions as you go to save time when setting the values: 0 - Wooden Single Closed 1 - Wooden Single Open 2 - Wooden Double Closed 3 - Wooden Double Open ... 16 - Secret Closed 17 - Secret Open 18 - Portcullis Closed 19 - Portcullis Open 20 - Secret Cave Closed 21 - Secret Cave Open 22 - Chest Closed 23 - Chest Open And so on. Joe C. said: From what I understand it has to be a table with images corresponding to the desired look of the door (open, or closed) and by changing the values of Bar3 and Max_Bar3 you can effectively change the image to change places with the other image on the table but it doesnt seem to work for me. Maybe I havn't set up my table right or something It is also worth noting that i think Matt's setup guide has the values the wrong way around, the script is a better guide on which denotes open and which denotes closed... if in doubt put the numbers in and open and close the door a few times, if it ends up looking closed when it is open you've got the numbers back to front ;) statusDoors.sideDoorOpen = "bar3_value"; statusDoors.sideDoorClosed = "bar3_max";
1435072458
The Aaron
Pro
API Scripter
Joe C. said: @The Aaron ok now I feel dumb lolz. Thanks for pointing that out. No worries, it took me about 4 months to figure out that &para; was there, that's part of why I added that part to the wiki. =D
1435072713
The Aaron
Pro
API Scripter
Ziechael said: if only there was another friendly neighbourhood scriptomancer out there who might take a look...?! That actually sounds like a pretty straight forward change... but I'm trying to limit my extraneous API crafting to a minimum until I finish the master CharMod ritual... =D If only there was another friendly neighborhood scriptomancer apprentice out there who might take a look...?! (Serve returned!)
Alright now i've got doors working perfectly thanks to Both you guys' help! My party loves the new interactions and so far its smooth sailing! I think the next API script i'm gunna tackle will be powercards. Ziechael I think you said you had some made for 3.5 right? Mind helping me out a bit more?
1435139237
Ziechael
Forum Champion
Sheet Author
API Scripter
Awesome, you'll soon have a super easy to manage campaign that will blow your players minds! I'm going to do some testing for the doors script soon to see if i can get auto-calc'd attributes to play nice, if i succeed (or more appropriately, when i give in and ask Aaron exactly what to write and where to put it) i'll be sure to pass the information along for you to use. As for powercards, I would highly-HIGHLY recommend printing out the opening post in the powercards 3 - part 2 thread. HB's notes there are a great reference sheet. I would then take a look through the thread itself, see what people have done and how they are using the script to best effect. THEN, i would head over to the power cards examples thread in the mentors forum, there are a couple of my more advanced ones in there (weapon selected for sneak attack and alternate secondary weapon selection option for dual wield). NEXT, i would play around a little bit, try making some basic save based ones: !power {{ --format|save --name|Fortitude Check --!save|~C [[ [$save] 1d20 + @{selected|fortitude} + ?{Other Bonus|0}]] v DC ?{DC Target:|0}. ~C --?? $save.total &gt;= ?{DC Target:|0} OR $save.base == 20 ?? !output|~C **Success!** ~C --?? $save.total &lt; ?{DC Target:|0} OR $save.base == 1 ?? !output2|~C **$$#400|Fail!$$** ~C }} these will give you a feel for the layout options (note the {{ and }} to allow line breaks, so much easier than one long line of code!) as well as starting to toy with the conditional outputting (best thing since... well, ever...) And by then i'll have hopefully added mine to my online repository of 3.5 powercards which i'd be happy to share with you (they are all in a single text document at present and it is very cluttered and unordered and hard to navigate lol). I simply can't stress enough how important it is to learn to build your own though as they occasionally require adjusting on the fly (if, like me, you don't take the time to test each and every one!) and understanding how they work is a must! Feel free to continue this via PM with me as I fear this thread has strayed too far from it's original topic already (we should consider renaming it really!)
Gha! Away with the secrecy! Better to have it in the wrong thread than not at all. :P This way it might help others that randomly read threads... Anyway - back to traps - before stealing the version mentioned earlier here I was getting nothing. Now I'm getting this: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: vec is not defined at _checkCollisionInWaypoint (evalmachine. :784:33) at _getCollisionsInWaypoint (evalmachine. :759:16) at _getFirstCollisionInWaypoint (evalmachine. :734:26) at Object.getFirstCollision (evalmachine. :664:33) at getTrapCollision (evalmachine. :30:36) at Sandbox. (evalmachine. :90:28) at eval ( It's something I guess. Since this only happens when I move the token on the trap I guess it means something is working. -- But given that it doesn't say anything in the chat about a trap resaving it all the time still wouldn't work, since the error happens before the script does anything good.
1435393479
Ziechael
Forum Champion
Sheet Author
API Scripter
New threads with specific thread titles help casual browsers more in my opinion ;) (to that end i'm happy to jump on any thread discussing the above off-thread topics at any time). As for your trap issue, ensure you have both vector math and token collision installed as well first and foremost and let us know if that helps.
Gods that's embarassing... I started a brand new campaign to test this - and it still failed with the original code: I copied it from the change log not the actual file, so in front of every line it had a + causing a "unexpected token" error. Bhahaha. So I got the proper one and it worked, and the one from above also worked. Then I went back to my original campaign and? - Nada! Still doesn't work with either of the codes from "Unexpected token :" to a firebase error, to a blank one! that one was at least cool... it just had a white square where the error should have been. That is with all other scripts disabled. I'm confused, what else influences the scripts besides other scripts? How is my very large campaign with disabled scripts and a few active ones different from a blank slate with only a few active ones?
One thing I noticed is if your players are not playing "AS" their token/character then it caused a few problems. Make your players check the drop down under chat is set to their respective characters name. They can test this by typing something in chat and it should say the message is from the character not the player themselves. Also I would have them move via waypoints as that seems to be less uh... bipolar? I'll go with that. Here's hoping it works!