Open door macro (VBL deletion)

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Open door macro (VBL deletion)

Post by Trole »

I've been looking through the forums, and have been unable to find this, so if anyone out there could either point me to it, or provide the code, it'd be much appreciated.

I'm looking for a macro that would delete the VBL "under" a object, such as a door when the button is clicked.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Open door macro (VBL deletion)

Post by JamzTheMan »

Hi, your best bet is here: http://forums.rptools.net/viewtopic.php?f=46&t=16066

Wolf's BoT has that plus a few other VBL tooks along with a lot of other useful stuff. If it's too overwhelming or you truly just want a simple macro or learn how to do it, my original thread is here: http://forums.rptools.net/viewtopic.php?f=3&t=22624

There's some sample code there and there is also the wiki documentation. If you get stuck or have any questions let us know.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Re: Open door macro (VBL deletion)

Post by Trole »

I've looked over Wolph's BoT, and from what I've gathered from the documentation, it doesn't do anything with the VBL, it just rotates the image of the door . . . I'm basically looking for a macro that can get the coordinates of a token (the door), and then delete any VBL that may be in the same area. I've got a macro for opening the door, and want to combine it with the VBL deletion macro so when clicked, the door opens, and the VBL is removed.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Open door macro (VBL deletion)

Post by JamzTheMan »

His bot does indeed erase the vbl and draw it again where ever the door rotates to, our closes, as well as allowing you to peek through the key hole and just crack the door open. Not sure about the documentation but I know it does do it as long as you are running b89.

I'm not at my computer but I will try and post my macro tonight. It sets up a little different and may not be foolproof but it works.

FYI, basically you use getTokenX (and y) to get token location, then use getTokenWidth and getTokenHeight and use that to create a rectangle shape for erase VBL as per the wiki.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Open door macro (VBL deletion)

Post by JamzTheMan »

Here are a set of macro's to open/close doors with VBL. I use properties to store the VBL data and a State to store the fact that it's a door so I can find it relative to a token. It needs some improvements that I haven't gotten around to like only looking for "open doors" to open, etc. Currently if you have more than 1 door on the same square as the token, you can't easily control which door opens so you have to do it manually. Wolf's BoT does this with a prompt box.

Step 1: Set your door where you want it
Set Door Closed

Code: Select all

[h: setPropertyType("Door")]
[h: setTokenShape("TOP DOWN")]
[h: setState("isDoor", 1)]
[r: tokenWidth = getTokenWidth()]
[r: tokenHeight = getTokenHeight()]
[r: xClose = getTokenX()]
[r: yClose = getTokenY()]
[r: closedAngle = getTokenFacing()]

[h: doorVBL = json.set("{ }", "Shape", "Rectangle", "X", xClose + 2, "Y", yClose + (tokenHeight / 2) - 2, "w", tokenWidth - 4, "h", 4, "facing", closedAngle)]

<!-- Let's do some semi-intelligent guessing, assuming a door is higher than wider, let set the VBL to
     run along the long side of the door -->
[r, if(tokenHeight > tokenWidth), code: {
  [x = xClose + (tokenWidth / 2) + 1]
  [y = yClose]
  [x2 = x]
  [y2 = yClose + tokenHeight]
  [doorVBL = "{'Shape':'Polygon', 'thickness':2, 'facing':" + closedAngle +", 'points':[{'x':"+x+", 'y':"+y+"}, {'x':"+x2+", 'y':"+y2+"}]}"]
}]

[h: VBLforDoorJSON=json.append('', doorVBL) ]

[h: closedVBL = VBLforDoorJSON]

[h: drawVBL(closedVBL) ]
Step 2: Rotate and set door to where it looks opened
Set Door Open

Code: Select all

[h: setPropertyType("Door")]
[h: setTokenShape("TOP DOWN")]
[h: setState("isDoor", 1)]
[r: tokenWidth = getTokenWidth()]
[r: tokenHeight = getTokenHeight()]
[r: xClose = getTokenX()]
[r: yClose = getTokenY()]
[r: closedAngle = getTokenFacing()]

[h: doorVBL = json.set("{ }", "Shape", "Rectangle", "X", xClose + 2, "Y", yClose + (tokenHeight / 2) - 2, "w", tokenWidth - 4, "h", 4, "facing", closedAngle)]

<!-- Let's do some semi-intelligent guessing, assuming a door is higher than wider, let set the VBL to
     run along the long side of the door -->
[r, if(tokenHeight > tokenWidth), code: {
  [x = xClose + (tokenWidth / 2) + 1]
  [y = yClose]
  [x2 = x]
  [y2 = yClose + tokenHeight]
  [doorVBL = "{'Shape':'Polygon', 'thickness':2, 'facing':" + closedAngle +", 'points':[{'x':"+x+", 'y':"+y+"}, {'x':"+x2+", 'y':"+y2+"}]}"]
}]

[h: VBLforDoorJSON=json.append('', doorVBL) ]

[h: closedVBL = VBLforDoorJSON]

[h: drawVBL(closedVBL) ]
Step 3: To open the door, click a PC token closest to door
Open Nearest Door

Code: Select all

[h: cond = '{ range: {upto:4, distancePerCell:0, metric:"NO_GRID"}, setStates:["isDoor"], layer:["TOKEN", "HIDDEN", "OBJECT", "BACKGROUND"] }']
[h: tokenList = getTokenNames("json", cond)]
[h: tokenA = getImpersonated()]
[h, if(! json.isEmpty(tokenList)): tokenB = json.get(tokenList, 0); abort(0)]
[H: distance = 25]

[h, foreach(tempToken, tokenList), code: {
   [h: this.distance = getDistance(tempToken, 1, tokenA, "NO_GRID")]
   [h, if( this.distance < distance), code: {
      [h: distance = this.distance]
      [h: tokenB = tempToken]
   };{}]
}]

[h, macro("openNearestDoor@Lib:NerpsForPathfinder"): "doorToken=" + tokenB]
Step 4: To close the nearest door
Close Nearest Door

Code: Select all

[h: cond = '{ range: {upto:4, distancePerCell:0, metric:"NO_GRID"}, setStates:["isDoor"], layer:["TOKEN", "HIDDEN", "OBJECT", "BACKGROUND"] }']
[h: tokenList = getTokenNames("json", cond)]
[h: tokenA = getImpersonated()]
[h, if(! json.isEmpty(tokenList)): tokenB = json.get(tokenList, 0); abort(0)]
[H: distance = 25]

[h, foreach(tempToken, tokenList), code: {
   [h: this.distance = getDistance(tempToken, 1, tokenA, "NO_GRID")]
   [h, if( this.distance < distance), code: {
      [h: distance = this.distance]
      [h: tokenB = tempToken]
   };{}]
}]

[h, macro("closeNearestDoor@Lib:NerpsForPathfinder"): "doorToken=" + tokenB]
To manually open/close the door, select the door:
Open Door

Code: Select all

[h: w = getTokenWidth()]
[h: h = getTokenHeight()]
[h: updown = 1]

[h, if(closedAngle == 0 || closedAngle == 180), code: {
	[h = getTokenWidth()]
	[w = getTokenHeight()]
	[h: x = xClose + floor(w / 2)]
	[updown = 0]
	
}]

[h, if(updown == 1), code: {
	[h: y = yClose + floor(h / 2)]
	
}]


[h: setTokenFacing(openAngle)]
[h: moveToken(xOpen, yOpen)]

[h: eraseVBL(closedVBL) ]
[h: drawVBL(openVBL) ]

[h: exposePCOnlyArea()]
Close Door

Code: Select all

[h: setTokenFacing(closedAngle)]
[h: moveToken(xClose, yClose)]

[h: w = getTokenWidth()]
[h: h = getTokenHeight()]
[h: updown = 1]

[h, if(closedAngle == 0 || closedAngle == 180), code: {
	[h = getTokenWidth()]
	[w = getTokenHeight()]
	[h: x = xClose + floor(w / 2)]
	[updown = 0]
	
}]

[h, if(updown == 1), code: {
	[h: y = yClose + floor(h / 2)]
	
}]

[h: eraseVBL(openVBL) ]
[h: drawVBL(closedVBL) ]

[h: exposePCOnlyArea()]
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Re: Open door macro (VBL deletion)

Post by Trole »

Heh, yours is a lot fancier than what I came up with . . . and mine required the selection of the door token itself. Either way, I thank thee, and I'm sure others out there will do the same.

I'm actually quite surprised there wasn't a request for something like this already. I know Wolph has his BoT, but to be honest, there's quite a few features in that which I would never have the need to use, and there's so much that I really don't know what to pull out and what to keep . . .

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Open door macro (VBL deletion)

Post by JamzTheMan »

No problem. Tech Tip, Sometimes I find it easier to place the doors first, use the "set door closed macro" then draw the VBL connecting the doors.

Also, you need to check after the door is open to make sure when it's closed again it doesn't leave a slit open. Or you can remove the draw/erase part of the "Open Door" macro if you want a simplier looking/using set of macros.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Open door macro (VBL deletion)

Post by wolph42 »

Trole wrote:I've looked over Wolph's BoT, and from what I've gathered from the documentation, it doesn't do anything with the VBL, it just rotates the image of the door . . . I'm basically looking for a macro that can get the coordinates of a token (the door), and then delete any VBL that may be in the same area. I've got a macro for opening the door, and want to combine it with the VBL deletion macro so when clicked, the door opens, and the VBL is removed.
dude, sorry to be harsh, but learn to read. I've literally spend hours on documentation so I do get slightly annoyed when you mark something with big red letters and then hear that someone can't find it... :roll: here a copy paste from the BoT forum post:
ision Blocking Layer (VBL) macros
To make use of these functions in 1.3b87 you need Jamzthemans special .jar file which can be downloaded below in the download section and replace the .jar file in your MT install directory with that one.
This is not required in 1.3b89, here these functions are embedded.
VBL to doors. Toggling a door will give the following options: look through key-hole, look through window, crack door open, open door half way, open door fully. The VBL will be adjusted accordingly
VBL Stamps on tokens. With this macro you can add a VBL layer upon a token that 'moves' with the token. (Its not really ON the token, but erased and redrawn as you move the token). Possible VBL are Square, Rectangle, Line, Regular Polygon. With a bunch of extra options (like offset, scale, fill, etc.).
NEW: Drawable Polygon Stamps: in addition to the 'normal' stamps, you can now also draw and store multiple polygon VBL on a token. This is particular usefull for dungeon tiles where you can store the VBL data onto the tile and then copy paste the tile over the map.
Mass VBL. This function will draw VBL on ALL tokens that match a (partial) search string. Its mainly intended for roofs and canopy but options (selection, all, layers) have been added to use it for other purposes. This macro also contains 2 different scaling techniques to apply the VBL onto the token. Finally you can also store the ENTIRE VBL structure and you can use Toggle VBL to turn that on or off
Toggle VBL. This function corresponds with Mass VBL. In Mass VBL you can store all the added VBL and with this function you can turn it on or off instantly.
VBL Grenade. This function will erase ALL VBL in a given radius (in grid cells) around one or more selected tokens.
if you really *have* trouble reading, use ctrl+f.

Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Re: Open door macro (VBL deletion)

Post by Trole »

And, you sir, should do the same . . . I never said it didn't draw/erase VBL, I said "from what I gathered" . . . which, in this context, meant "I'm not saying it doesn't, nor that it doesn't say it does, just that I didn't see it if it did."

I never once said anything bad, nor did I attack, or even imply that your documentation wasn't complete. I stated *MY* interpretation of said documentation, and clearly stated that it was such, so I'd appreciate it if you'd lose the crappy attitude.

One final thing: your own quote of your documentation does not say that the VBL is drawn/erased with the opening/closing of the door. It states that there are macro options to have such done, but, as it's in it's own section, not with the open/close door macro, implies that these functions are separate, and as such, is exactly what I said: it does not draw/erase the VBL when the door is opened/closed.

Edit: And, like I said in my last post, you have a lot of features in your BoT that I would never use, so I focused solely on those features that I needed - i.e. the open/close door macro . . . so the fact that what I was looking for was in a separate location, did not give me the information I needed:

(cut & pasted from your documentation)
Here's a short screencast showing what it can do.
Here a screencast showing a different way to toggle the doors and it shows the 'ghosting effect' on the GM client with two clients connected (with a fast connection, with a slow connection, you'll likely see the first screencast as gm). Note that this effect is ONLY seen by the GM.
Tutorial Screencast - Setting up Animated Doors
And here's the manual of the animated doors, to give an impression of the howto:
Parameters
To make use of this functionality you need to create special 'door' tokens, with the following parameters.
- The length of these tokens needs to be twice the length of the door. The width is irrelevant. Select a couple of doors in the campaign file to get an idea.
- The name of the token needs to start with 'Door ' followed by an identifier, usually a number, but can also be a string.
- In case of a double door, there needs to be a mirrored copy of the 'main' door with the same name ending with 'a'. E.g. if the main door is 'Door 5' then the mirrored copy must be called 'Door 5a'. You only need to setup the main copy.

Setup
To create a single animated door you simply need to select the door and click 'Set Door' and enter the parameters for that door:
angle closed door: When you set the door for the first time, the current angle of the door is automatically picked. Its thus best to put the door in the closed position and then run the setup. If you copy paste a door that has already been set, the set value will be taken. To reset it, make sure this field is empty, click save and run setup again. You will now get the current angle of the door.
degrees open door: The is the amount of degrees the door turns when you open it. Half open would be 45, open would be 90 and wide open is 160 (default)
open clockwise: The way the door turns
time (ms): The amount of time it takes for the door to open. 1000 = 1 second. The default is 2000 (2 seconds).
double door: If there is another door with the same name as the door you set, but with 'a' at the end (e.g. 'Door 5a') then you can check this. When you open the door, then 'Door 5a' will also open in a mirrored direction
Message opened door: This message will be send to the chat when the door is opened. No message will be send to the chat when the value is set to 0 or blank.
Message closed door: Dito for opened door, only now when closed
Note: When you have set the door, the name of the door will appear in the GM Notes. So when the door is on the object layer and you click on it while on the token layer, the name of the door will appear!

Operating doors
There are several ways to operate a door:
1. Select the door and run the 'Toggle Door' macro from the campaign panel.
2. Impersonate the door and enter '[r:toggleDoor()]' in the chat
3. Enter '[r:toggleDoor(5)]' in the chat to operate 'Door 5'
4. Create a macro on the campaign panel with: '[r:toggleDoor(5)]' to specifically operate 'Door 5' with a one click button
5. Run 'Toggle Doors' macro from the campaign panel, this will give you a list of doors that have been set up AND are on the OBJECT layer. The ones you select will be animated.
Not a single mention of the VBL being modified, or even having an option to do so with other macros . . .

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Open door macro (VBL deletion)

Post by wolph42 »

Ive seperated the VBL from the doors in the manual cause it's mt version dependent and I don't want to cause confusion. Hence the VBL has its own section.
FYI: the VBL Is integrated with the door macros IF you're using the latest version of mt. Finally as for the *many options and I only want to use 1* I like to refer to the last section of the Bot post where it is explained how to use the bot for a limited amount of functions.

Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Re: Open door macro (VBL deletion)

Post by Trole »

I'm sure you have your reasons, and I'm not saying they are invalid. I'm just saying that nowhere in the documentation for the doors, does it mention VBLs, nor does it mention that the VBL draw/erase is integrated . . . which was the only reason for me saying what I originally said about the BoT . . . which received your snide remark.

And as I've pointed out, I have a perfectly valid reason for assuming what I did. So there was no grounds for your snide remark to begin with.

I have the macro I needed. One I wrote myself, with the help of posted code by a few people on here. So the purpose of this thread has been fulfilled. I thank you both for your replies, and the help that you have provided.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Open door macro (VBL deletion)

Post by wolph42 »

I'm glad it worked ot for you. The snide remark was just and only just because of the remark about the documentation. And yes I'm aware that it's impossible to full fill everyone's expectations. Would I have combined it (so it would have met your expectations) then I would have others complaining it not working cause theyre using an older version of my...sigh...it's just a bit frustrating.

Trole
Kobold
Posts: 6
Joined: Mon May 20, 2013 1:37 pm

Re: Open door macro (VBL deletion)

Post by Trole »

Don't misunderstand me. Your BoT is really nice, and given a bit of time and experience, I will probably take stuff from it to use in my HERO games. And the documentation was more than enough to provide information on what each feature was capable of doing. All I was saying is that, given the large amount of capability it has, and the fact that it might not all be stuff that others may use, they might not read the whole documentation and focus only on the areas detailing the features they want from it. So if you have two features that, while separate, work in conjunction or compliment each other, you may want to include a small note in each section so they don't miss that aspect of the BoT.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Open door macro (VBL deletion)

Post by wolph42 »

Trole wrote:Don't misunderstand me. Your BoT is really nice, and given a bit of time and experience, I will probably take stuff from it to use in my HERO games. And the documentation was more than enough to provide information on what each feature was capable of doing. All I was saying is that, given the large amount of capability it has, and the fact that it might not all be stuff that others may use, they might not read the whole documentation and focus only on the areas detailing the features they want from it. So if you have two features that, while separate, work in conjunction or compliment each other, you may want to include a small note in each section so they don't miss that aspect of the BoT.
done.

I noticed that the quoted text you pasted earlier *not* showing the VBL was actually an old part of the manual copy pasted into the forum. As I keep updating the *real* manual this obviously leads to misconceptions so I completely removed that section and 'spread the word' about the VBL in several sections. (So next time when someone 'cannot find anything about it in the documentation' I can once again start whining :twisted: ).

edit:
I still have to make one remark though... or better yet, a quote, the first few lines of the post:
Tutorial session of the bag of tricks, it deals with roughly 75% of the features, the remainder I'll do another time.
TUTORIAL VIDEO CONTENT
0 - 29:44 settings
30:41 - 56:11 ALL teleport pads
56:11 - 1:02:00 other special pads (canopy, foliage, roof, wards)
1:02:00 - 1:12:56 special areas (e.g. difficult terrain)
1:12:56 - 1:15:45 Warded Roofs (forgot that part for the roof pads)
1:15:45 - 1:23:50 Animated doors
1:23:50 - 1:29:00 Vision blocking layers on doors. However this functionality does NOT work under MT b87, you need a special patch for it to work.
1:29:00 - 1:33:30 Animated token movement
1:33:30 - end Most of the utility functions (e.g. switch map, show handout, etc.)

Post Reply

Return to “User Creations”