DungeonDraft, portals and tokens

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

DungeonDraft, portals and tokens

Post by notbono »

Posting in case this can help someone.

So, I really like DungeonDraft, and want to incorporate it into my workflow. The import function in MapTool 1.7.0 works very well, and creates the vision/movement blocking required. But my existing campaign uses tokens for doors, with VBL drawn/removed over the token for open and closed states. DungeonDraft allows you to place portals, such as windows and doors, but of course in the import process, these are just part of the background map it seems.

I tried opening the dd2vtt file created by DungeonDraft, and it turns out it's a JSON text file. The portals are all broken out in an array:

Code: Select all

	"portals": [
		{
			"position": {
				"x": 46,
				"y": 28
			},
			"bounds": [
				{
					"x": 45.5,
					"y": 28
				},
				{
					"x": 46.5,
					"y": 28
				}
			],
			"rotation": 0,
			"closed": true,
			"freestanding": false
		},
This made it pretty simple to write a macro to copy a blank transparent png token to the correct position and orientation (jPortals is the JSON array from the file.):

Code: Select all

[h: newDoors = ""]
[r, foreach(jPortal, jPortals, ""), code:{
	[h: pos = json.get(jPortal, "position")]
	[h: xpos = (json.get(pos, "x")-0.5) * 50]
	[h: ypos = (json.get(pos, "y")-0.5) * 50]
	[h: facing = if(json.get(jPortal, "rotation") == 0, 90, 0)]
	[h: update = json.set("{}", "x", xpos, "y", ypos, "layer", "Object", "useDistance", 1, "facing", facing) ]
	[h: newDoor = copyToken("Door", 1, "GM Area", update) ]
	[h: newDoors = listAppend(newDoors, newDoor)]

}]

[h: selectTokens(newDoors, 0, ",")]
[h, macro("MakeDoor@Lib:Door"): ""]
The transparent png allows the artwork to show through, while the token retains the orientation for the "MakeDoor" macro. I had to make sure that the "Snap to Grid" setting for the blank "Door" token was turned off, because DungeonDraft allows putting doors in between squares. (Admittedly nice to have a 10 foot corridor with a door in the middle of the end wall.)

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: DungeonDraft, portals and tokens

Post by bubblobill »

You might want to look at Smart Doors
Then you can just use a Smart Door in your copyToken().
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

Re: DungeonDraft, portals and tokens

Post by notbono »

That looks pretty cool. The only issue is that the doors are already drawn onto the map in DungeonDraft.

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: DungeonDraft, portals and tokens

Post by bubblobill »

Replace the images on the door tokens with your transparent PNG and you will still get the VBL functionality
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: DungeonDraft, portals and tokens

Post by Phergus »

notbono wrote:
Sun Aug 30, 2020 6:41 pm
DungeonDraft allows you to place portals, such as windows and doors, but of course in the import process, these are just part of the background map it seems.
DD always bakes the portal images into the exported image. Nothing to do with the import process.

If you use the "empty" portals in Dungeondraft ("X" and "Threshold 1") then you'll still have the VBL info but no door image. That way you can take whatever door token you like, place it on the map and transfer the VBL to it with the Edit Token dialog or via macro.

notbono
Cave Troll
Posts: 61
Joined: Sun Oct 24, 2010 4:44 pm

Re: DungeonDraft, portals and tokens

Post by notbono »

Oh, I was wondering what the red X was for! Good to know. The door options they have are actually kind of difficult to see when you are using VBL, and I have an old school blocky one I would like to use instead. Thanks for the tip.

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: DungeonDraft, portals and tokens

Post by Phergus »

The native doors in Dungeondraft don't stand out that well. I tend to prefer slightly oversize doors to make them easier to see.

ranulph
Kobold
Posts: 1
Joined: Tue Oct 27, 2020 5:23 pm

Re: DungeonDraft, portals and tokens

Post by ranulph »

I really like the macro idea - did you get it working? I'd love to use this with the smart doors. When I cut and paste it as a new global macro, it reports "Argument number 2 "position" to function "json.get" must be an integer." Could someone please help? I've done computer programming instructing at high school level but have not worked with json before.

Post Reply

Return to “Macros”