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

Roof removal script

Is there any sort of script that could work similarly to One-Way Dynamic Lighting except have it make a roof disappear when someone stands at the entrance or inside. This would make it so a roof could hide the contents of a building could be hidden by a roof until entered. I don't know if a script like this exists, but if it does: great! If it doesn't is there anyone who could make this script, assuming it's not overly difficult and unreasonable to request?
1507446273
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I would suggest using a rollable table token, and put the roof and each floor on a separate face. You can then switch faces with ChangeTokenImage on a macro. It might take some finesse to get the maps to line up, depending on how they are constructed and cropped.
1507474523

Edited 1507677920
Bast L.
API Scripter
While I really like the idea of this, there are some problems, especially with dynamic lighting. However, if it's just in a town or something, and you don't care about the lighting, it's not too tough to do. It kinda looks bad for the gm, but it should look ok for the players.&nbsp; Anyways, I'm sure I violated a dozen proper programming do's and don'ts, and it also kinda brute forces its way with nested loops, but here's what I have for it: Rooftops + dynamic lighting script: <a href="https://gist.github.com/Bastlifa/5a8eaa6f7259c2e9e" rel="nofollow">https://gist.github.com/Bastlifa/5a8eaa6f7259c2e9e</a>... Steps to use this script: Save the script in your APIs Have a token on your map which is either assigned to a player, or represents a character which is assigned to a player Have a roof token which has the name roof. No caps, because I really am that lazy. Have your players flag on the page you're trying to use it on. The flag is the red thing that moves players to a page. enter !RoofReady into the chat as a command. Making a macro would work. Also, if you move the player flag to the page, it should set RoofReady for you. If you change the player tokens, drag out a new one, make a new roof, whatever, you'll need to hit the !RoofReady command. It's easier to draw your dynamic lighting before placing the roof. It will move all paths, including object layer paths, to GM and DL layers, so, fair warning. The screenshots below are before it incorporated dynamic lighting. See another post further down for images of it interacting with DL. When you move the player page, or you enter !RoofReady into the chat, it updates the player tokens and roof tokens, making them ready. Any time you drag out new players, though, you'll need to use !RoofReady When you go inside the roof token with a player token, the roof token transfers to the gm layer, when you're outside it, it transfers back to the map layer. You have to name your roof tokens "roof", and my crappy script doesn't even allow for case-insensitivity :)&nbsp; Also, keep in mind, sometimes roof tokens extend out a bit, so make sure you're fully out when waiting for it to restore the roof. Also, it's pretty buggy atm, I'll try to update in a minute or two. Here's some screenshots: edit: oh, the bug has to do with the token's controller. Until I fix it (or someone else does), have the token not reference a character, then assign it to a player, then reassign to a character. I'll try to fix that though. Ok, that bug is fixed. I'm sure there are plenty more :) edit: Maybe I should move it to the DL layer to make it less ugly for the GM Here's a screenshot from a player perspective though:
1507480149
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ooh, I want to check this out. That sounds &nbsp;like a great idea!
Please let me know if you find any bugs Keith.
@Bast: I'm trying to test it out now. I've added a room with a roof token named "roof", used the "!RoofReady" command in chat, but nothing happens. I get no indicator in chat that the command worked, and walking under the roof doesn't seem to do anything.
1507482770

Edited 1507484116
Bast L.
API Scripter
@G: Are you walking under the roof with a token linked to a character which is assigned to someone (even yourself)? Or with a token which is not linked to a character, but which is assigned to someone? It should only change if the tokens are controlled by someone (assigned to someone, either via the linked character being assigned to someone, or the token being assigned directly). This way, you can have non-player tokens inside, which don't remove the roof. edit: also, there shouldn't be any indication that it works, though I could put one in. I'll see about doing that now. edit again: it now send the gm a message saying the rooftops are ready, how many player tokens there are, and how many roof tokens there are. If either of those values is 0, expect no interaction. edit further still: just to be sure, the roof token should be named: roof, rather than "roof". That is, don't include the quotes.
Also, just updated the script to look on all layers for tokens named "roof". There was a bug when reloading the game with roofs already on the GM layer.
1507484257

Edited 1507484344
Okay, I've got it working, except that when the token leaves the roof, it doesn't come back to the object layer. EDIT: Never mind, I don't know what I did, but it's working now.
You kinda have to go a ways outside of it, and all of the player tokens have to leave. I'm not sure why the entrance is different from the exit, but just make sure to go outside of it a bit further.
New issue, it's moving the roof between the GM and Map layer, which means when they go "under" the roof before it goes to the GM layer, they appear to be walking on top if it.
1507484519

Edited 1507484538
Do a pull request to roll20 api scripts Basto, if not one of us can. This would be handy if the dm urge strikes again like the infamous Turn Clock script! great work on that one Bast
1507484881

Edited 1507485034
Bast L.
API Scripter
Update: Now moves the roof to the walls (dynamic lighting) layer, for prettier GM viewing. Mark, mind doing the pull request for me? I have no idea how to use github. edit: also, my turn clock script was really rewritten by Aaron, maybe he should get credit for it :) edit further: Given The G's error, maybe we should hold off on the pull request
Getting the following error and no clue why: TypeError: Cannot read property 'set' of undefined TypeError: Cannot read property 'set' of undefined at removeRoof (apiscript.js:12426:34) at apiscript.js:12455:58 at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16) at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:909:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1378: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)
Bast L. said: Update: Now moves the roof to the walls (dynamic lighting) layer, for prettier GM viewing. Mark, mind doing the pull request for me? I have no idea how to use github. Can you have it go back to the GM layer? I've found a way to use it with dynamic lighting and have it look very pretty (Well, maybe I'm testing but could be wrong.)
On line 66, change 'walls' to 'gmlayer', that should do it. I'm trying to figure out the error. Do you know what leads to it? I've tried deleting, and messing around with tokens, but I can't replicate it.
I'm not sure; I'm not getting the error now, but I have a different issue. The roof won't change back. It just stays GM layer, and when I try to change it manually, it automatically changes back to GM layer.
1507485759

Edited 1507485795
Bast L.
API Scripter
Is there an assigned token inside of the roof token? If so, that result would make sense. (the token limit is the box you see when you select it, not the image that you see)
I found the issue. It was part of my attempt to work around and make dynamic lighting work. Is there a way to make detect all player tokens, but exclude one with a specific name?
On line 52, put a conditional around the if and its nest. something like,&nbsp; if (allPlayerTokens[i].get("name") != "yourExcludedName")
Hmm, so, it kinda works. Pretty much, I was the idea was to have the roof token controlled by a "player" that no player actually controlled and have it share vision but change the sight radius to 0, that way they could see it regardless of dynamic lighting but couldn't see it if they weren't close enough. It ended up not working because they could just see the roof floating even if they weren't near it. It could work on an outside daytime map if you wanted to have the walls of building to obstruct view, but if it was outside and night or inside a cave, it wouldn't work as intended. Oh well, your script still works perfectly for my original desire! Which is fine because on an outside map, I wouldn't use enforce line of sight anyway.
So, I thought about it before, and trying to link roof tokens and paths seemed like a pain, but then I realized I can just do the same check to see if a player is inside to deal with dynamic lighting paths. It may cause even more errors, and it stores the dynamic lighting paths on the gm layer when not used, but here's a new gist for rooftops + dynamic lighting:&nbsp; <a href="https://gist.github.com/Bastlifa/5a8eaa6f7259c2e9e" rel="nofollow">https://gist.github.com/Bastlifa/5a8eaa6f7259c2e9e</a>... Some screenshots from player perspective: player token outside: Player looking in window: Player inside:
1507489097

Edited 1507489457
Wait so, does it store the walls on the gm layer, but then when you "enter" the building, it moves it to the walls layer?
Yeah
How does it detect the player token in order to switch in the dynamic lighting to the walls layer? I can't figure that out.
When the player enters the roof area, the roof switches to the dynamic lighting layer (and does nothing there, since only paths do anything on that layer, unless it emitted light), and at the same time, any paths within that roof area will switch to the dynamic lighting layer, which will make dynamic lighting begin working for that building.&nbsp; When the player leaves the roof area, the roof goes to the map layer, and any paths in that roof area will transfer to the gm layer, disabling dynamic lighting walls for the building. The removeRoof function calls the restorePath function, and the restoreRoof function calls the removePath function. Basically, they toggle.
Hmm, I'm not sure what's wrong then. I've got paths in the GM layer under the roof and they don't seem to be changing. Do they have to be lines or can they be boxes?
I'm not sure about boxes, but I suggest using the polygon tool. Also, did you update the script? There are now two versions, original and rooftops + dynamic lighting. The way to go about it is: Have a map with a building. Draw the dynamic lighting for the building on the dynamic lighting layer (it should be layer independent actually), using polygon tool. Switch to the map layer. Drag out a roof token. Size is and place on building. Name it roof. Have a player token somewhere on the map. enter !RoofReady into chat. Move player up to the building.
Okay, when I draw the dynamic lighting layer, everything else works properly, but the dynamic lighting just stays as it is.
1507491759

Edited 1507491853
Bast L.
API Scripter
I'm not sure what's up with it. Want to invite me, or have me invite you to a test game to see? edit: though roll20 is being difficult atm, so maybe we can try later.
Invited you to my game. I'll GM you when you join.
Seems sorted now.
1507501549
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It's looking really good. I tried the first script with little success. I had better luck with the DL script, though it might be because I also moved the player flag to the map I was on. Would that affect the action? Also, it looks like it may require cropping roof tokens very tightly. It disappears once my token gets within 5 squares of it, though there is only 1 square of transparent padding.
1507501724

Edited 1507501923
Bast L.
API Scripter
Yeah, I mean, it's just based on the token size, so if there's padding, then it'll disappear early. Also, I think it only works on the page where the player flag is. I suppose that could be an issue if the players are split up into different pages. I'll take a look maybe at making it work on any page that a player (including gm) is on. edit: oh, as for disappearing within 5 squares, I'll have to test that.
1507501896
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Also, I have two PC tokens that are controlled by the GM on the token layer, though neither has specific "controlled by" settings. they are just my personal PCs. One of them it works for, but not the other. I am attaching the edit screens, though I can see no difference between the two. Also, the report shows only 1 player token. Any ideas?
1507502224

Edited 1507502245
Bast L.
API Scripter
That is very strange. I wonder, if you drag out their tokens onto the map, and then open the tokens, are either of them unlinked from character sheets? If so, are they assigned to anyone? That's the only way I could replicate it.
Also, regarding padding, Mine only turns off when it's actually inside the box on the roof token. I wonder if I could join your game to see what's up.
1507502387
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I think I have solved the margin issue. One of my rooftop tokens is rotated, but the script is acting as if it is not. In other words, for a 20 x 40 roof, the token activates as if it were filling a 40 x 20 space. Keep up the debugging though. I think you have a really hot idea on your hands. This is a very simple and easy to use solution for a problem a lot of people would like&nbsp;solved. This is better and less overhead than a "roof layer" would be. The fact that each roof has its own space and action is fantastic.
keithcurtis said: I think I have solved the margin issue. One of my rooftop tokens is rotated, but the script is acting as if it is not. In other words, for a 20 x 40 roof, the token activates as if it were filling a 40 x 20 space. That's an issue that likely needs to be handled. If you were to make a cityscape it could look kinds weird if you couldn't rotate things properly
1507502554
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It works fine with other PC tokens.
1507502595
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Gotta go now, but I will work more on debugging tonight. Again, great idea for a script!
Hmm, rotated tokens could be an issue. I mean, it's trivial to fix for rotations with multiples of 90 degrees, but 45, or weird rotations might be a problem.
1507504335

Edited 1507505482
Bast L.
API Scripter
I've updated the script to work with rotations of 90, 180, 270, and 0 degrees. Odd rotations are still off, but.. whatever :) edit: more bugs, working on it. edit: bugs fixed, as far as I can tell.
1507510090
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Are all changes only to the DL version of the script?
Yeah
1507510815
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That is working great. I haven't tested the Dynamic Lighting yet, but I will tonight.
Nice. Thanks for testing it. I think I may end up using this one.
1507515399
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It could also be used to reveal something beyond the edge of a cliff. I.e. the area below, which can only be seen when standing on the edge.
1507518807
The Aaron
Pro
API Scripter
Bast L. said: edit: also, my turn clock script was really rewritten by Aaron, maybe he should get credit for it :) Eh?&nbsp; What Turn Clock Script?&nbsp; I'm fine with just a mention in the comments, if you put my name on it I'll have to support it! =D (of course, I'd probably help support it anyway...)