Moving a Token to a random coordinate

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

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

Re: Moving a Token to a random coordinate

Post by wolph42 »

in case you're still interested. I found it a fun thing to contemplate so I whipped up a test version both the 'sheet roller' and the 'room layout builder' (including doors). It works.

you can download it here


chap126
Kobold
Posts: 24
Joined: Wed Jul 31, 2013 9:57 am

Re: Moving a Token to a random coordinate

Post by chap126 »

Nice Wolph, here's what I ended up with:

Code: Select all

[roll=roll(1,4)]
[h:gs = json.get(json.get(getInfo("map"),"grid"),"size")]
[h, token("dice_drop_d4"):setTokenImage(tblImage("tbld4",roll))]
[h:moveToken(
    getTokenX(1,"dice_drop_area") + roll(1,getTokenWidth("dice_drop_area")), 
    getTokenY(1,"dice_drop_area") + roll(1,getTokenHeight("dice_drop_area")), 
    1, 
    "dice_drop_d4"
)]
[h:setTokenFacing(roll(1,360),"dice_drop_d4")]
I made a table called tbld4 and added 4 different images of a d4, one image for each side.
Then I made a simple token that's a transparent square with a solid colored border around it, and named it "die_drop_area".
I made a token called "dice_drop_d4" and set it to top down view in its properties.
I adjust my die drop area to whatever size I need. The dice will change it's image based on what's rolled and will rotate to a random angle at a random spot within the "dice_drop_area" I specify.


chap126
Kobold
Posts: 24
Joined: Wed Jul 31, 2013 9:57 am

Re: Moving a Token to a random coordinate

Post by chap126 »

wolph42 wrote:why the facing of the die?

have you also noticed the room divider?
Yeah! Super cool and clever! I added it to my campaign.

I did facing because sometimes I use a dice drop to point me in the direction of something being looked for. A d4 makes a good arrow: the direction it points is the direction the target is, and the number represents a distance (could be blocks, or miles, or 10s of miles, etc)

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

Re: Moving a Token to a random coordinate

Post by wolph42 »

chap126 wrote:
wolph42 wrote:why the facing of the die?

have you also noticed the room divider?
Yeah! Super cool and clever! I added it to my campaign.

I did facing because sometimes I use a dice drop to point me in the direction of something being looked for. A d4 makes a good arrow: the direction it points is the direction the target is, and the number represents a distance (could be blocks, or miles, or 10s of miles, etc)
ah clever!

Post Reply

Return to “Macros”