Page 1 of 2

Beam me up, Scottie

Posted: Wed Oct 21, 2009 12:39 pm
by patoace
Please check this reply in this same thread for an updated version of this macro with the same functionallity. It no longer needs tables!

This short macro can be dropped in any campaign to transport all your PC tokens between maps, with a few clicks.

All it needs is a table called "Mapa" with this format:

Code: Select all

Range     Value
[number]  [mapName],[x coordinates],[y coordinates]


ie

Code: Select all

Range    Value
1          Sandpoint,10,45
2          Varisia,140,85
3          Magnimar,11,134


This is the macro

Code: Select all

[h,code:{
[abort(isGM())]

[in=0 ]
[Lst=""]
[while(tbl("Mapa",in)!=tbl("Mapa",in+2)),code:{
   [in=in+1]
   [Lst=Listappend(Lst,listGet(tbl("Mapa",in),0))]
}]

[bla=input(
"map|"+Lst+"|Destino|Radio"
)]

[abort(bla)]
[map=map+1]

[Dest=listGet(tbl("Mapa",map),0)]
[x=listGet(tbl("Mapa",map),1)]
[y=listGet(tbl("Mapa",map),2)]
[foreach(in,getPC()),code:{[moveTokenToMap(in, Dest, x, y)][x=x+1]}]
}]
Todas las fichas transportadas al mapa "[r:Dest]"

Re: Beam me up, Scottie

Posted: Wed Oct 21, 2009 4:02 pm
by PinkRose
I get the following error.

Code: Select all

  Invalid condition in WHILE(tbl("Mapa",in)!=tbl("Mapa",in+2)) roll option.       Statement options (if any): while(tbl("Mapa",in)!=tbl("Mapa",in+2)),code       Statement Body : { [in=in+1] [Lst=Listappend(Lst,listGet(tbl("Mapa",in),0))] }

Re: Beam me up, Scottie

Posted: Wed Oct 21, 2009 5:29 pm
by patoace
I'm sorry to hear that.

It seems the macro can't find the "Mapa" table, can you upload the campaign file?

Re: Beam me up, Scottie

Posted: Thu Oct 22, 2009 2:31 am
by nortonweb
Bit of a tweak. This moves the selected tokens to the visible map from a select drop down. You enter the x and y of where you want to go.

You can jump on the same map or onto a new map.

For every extra token the x is increased by 1. This is from patoace's code. I guess it could be clever and try to keep a formation by looking at the group set up first but that would take too much brain power for 5.30pm at work :)

Code: Select all

[h:abort(isGM())]


[H:bla=input("mapName|"+getVisibleMapNames()+"|Destino|LIST|value=string", "x|0|X loc|TEXT|WIDTH=4", "y|0|Y Loc|TEXT|WIDTH=4")]

[h:abort(bla)]

[h:Dest=mapName]


[h: ids = getSelected()]
[h,if(getCurrentMapName()==Dest),code:{
[h,foreach(idHere,ids),code:{[h:moveToken(x, y,0,idHere)][h:x=x+1]}]
};{
[h,foreach(idHere,ids),code:{[h:moveTokenToMap(idHere, Dest, x, y)][h:x=x+1]}]
}]

moved

Re: Beam me up, Scottie

Posted: Thu Oct 22, 2009 10:13 am
by patoace
Interesting

Your approach has the advantage of not requiring a table to store the coordinates, but in the other hand, it's hard to remember the "entry point" for every map.

I'll adopt the abilities to move a token in the same map, which then takes me to think of having several entry points for the same map (tavern and town square for instance). Also, I'll add the function to to transport or move selected tokens only, but stating that if there are none selected, the macro affects all PCs.

So, latest version:

Code: Select all

[h,code:{
[abort(isGM())]


[tokenId=if(getSelected()=="",getPC(),getSelected())]
[tokenNm=""]
[foreach(in,tokenId):tokenNm=listappend(tokenNm,getName(in))]
[Lst=""]
[in=0]
[while(tbl("Mapa",in)!=tbl("Mapa",in+2)),code:{
   [in=in+1]
   [Lst=Listappend(Lst,listGet(tbl("Mapa",in),0))]
}]

[bla=input(
"Fichas|"+tokenNm+"||Label",
"map|"+Lst+"|Destino|Radio"
)]

[abort(bla)]
[map=map+1]

[Dest=listGet(tbl("Mapa",map),0)]
[x=listGet(tbl("Mapa",map),1)]
[y=listGet(tbl("Mapa",map),2)]
}]

[if(getCurrentMapName()==Dest),code:{
   [h,foreach(in,tokenId),code:{[moveToken(x, y,0,in)][x=x+1]}]
   [r:tokenNm] movido(s) a [r:Dest]
   };{
   [h,foreach(in,tokenId),code:{[moveTokenToMap(in, Dest, x, y)][x=x+1]}]
   [r:tokenNm] llevado(s) al mapa [r:Dest]
}]

Re: Beam me up, Scottie

Posted: Thu Oct 22, 2009 7:18 pm
by PinkRose
Works like a charm.
Thanks to you both.

Re: Beam me up, Scottie

Posted: Fri Oct 23, 2009 8:21 pm
by patoace
PinkRose wrote:Works like a charm.
Thanks to you both.

Glad to hear, you're welcome

The latest 1.3b60 comes with the setCurrentMap() of evident interes for this macro. This version, once the token are moved to the new map, changes the current map and centers the image in the destination.

[h,code:{
[abort(isGM())]


[tokenId=if(getSelected()=="",getPC(),getSelected())]
[tokenNm=""]
[foreach(in,tokenId):tokenNm=listappend(tokenNm,getName(in))]
[Lst=""]
[in=0]
[while(tbl("Mapa",in)!=tbl("Mapa",in+2)),code:{
[in=in+1]
[Lst=Listappend(Lst,listGet(tbl("Mapa",in),0))]
}]

[bla=input(
"Fichas|"+tokenNm+"||Label",
"map|"+Lst+"|Destino|Radio"
)]

[abort(bla)]
[map=map+1]

[Dest=listGet(tbl("Mapa",map),0)]
[x=listGet(tbl("Mapa",map),1)]
[y=listGet(tbl("Mapa",map),2)]
}]

[if(getCurrentMapName()==Dest),code:{
[h,foreach(in,tokenId),code:{
[moveToken(x, y,0,in)][x=x+1]
}]
[r:tokenNm] movido(s) a [r:Dest] [goto(x,y)]
};{
[h,foreach(in,tokenId),code:{
[moveTokenToMap(in, Dest, x, y)][x=x+1]
}]
[r:tokenNm] llevado(s) al mapa [r:setCurrentMap(Dest)] [goto(x,y)]
}]

Re: Beam me up, Scottie

Posted: Fri Nov 27, 2009 9:46 pm
by PinkRose
Hey Code Monkeys,

Can I ask for a few updates?
1. Can the formation of the selected tokens be saved when they teleport?
2. Can we apply a name to the teleport location, instead/in addition to the map?
So that way we can teleport to specific destinations on the same map easily?

Thank you in advance.

Re: Beam me up, Scottie

Posted: Wed Dec 02, 2009 4:21 pm
by patoace
The first request, I guess it can be done, but it's too hard for my macro ranks. The second one, is just a label for the input dialog, and it can be implemented via a fourth parameter in the "maps" table, and changing this

Code: Select all

[Lst=Listappend(Lst,listGet(tbl("Mapa",in),0))]

to this

Code: Select all

[Lst=Listappend(Lst,listGet(tbl("Mapa",in),3))]


Now your "map" table should look like this

Code: Select all

Range   Value
1       Sandpoint, 83,11, Sandpoint Church
2       Sandpoint, 130,52, Sandpoint Tavern
3       Dungeon, 0, 0, Dungeon

Re: Beam me up, Scottie

Posted: Wed Dec 02, 2009 5:43 pm
by CoveredInFish
Hmm... first request would require...

a) select a reference token.

b) calculate x/y-offset for any token to reference token and store it somewhere (on a lib:token?), store offset 0/0 for reference token.

c) place any token to the new place considering the stored offset.

Doesn't sound too complicated ... if I find the time, i'll give it a shot. Cant promise anything, though :-/

Re: Beam me up, Scottie

Posted: Wed Dec 02, 2009 8:03 pm
by PinkRose
patoace, thank you very much.
For the help here and for the involvement in the community in general.

Instead of exact formation, would it be easier to at least form them in a group?
A 3x2 or 2x3 block of adventurers would fit much better on most maps then a 1x6 column of adventurers.

Doesn't sound too complicated

Your words, not mine.
Thanks for looking into it CoveredInFish.

Re: Beam me up, Scottie

Posted: Thu Dec 03, 2009 3:25 am
by CoveredInFish
Okay, done it. Seems to work fine. Destination-Table should have 4 values (Map, x, y, Label).

EDIT: removed buggy code. You find fixed version below.

Re: Beam me up, Scottie

Posted: Fri Dec 04, 2009 12:11 am
by lmarkus001
Just sharing in case they were missed... I have two ways of moving tokens in the generic toolset linked below...

Re: Beam me up, Scottie

Posted: Fri Dec 04, 2009 12:00 pm
by PinkRose
I'm getting this error now.

Code: Select all

   Roll option list can't end with a comma.       Statement options (if any): r if(getCurrentMapName()==Dest),code       Statement Body (first 200 characters): { [h,foreach(in,tokenId),code:{ [h: jsonOffset = json.get(jsonAllOffsets, in)] [h: xOffset = json.get(jsonOffset, "x")] [h: yOffset = json.get(jsonOffset, "y")] [m 

Re: Beam me up, Scottie

Posted: Fri Dec 04, 2009 5:58 pm
by CoveredInFish
Darn ... a typo. How could that happen? I guess copy-paste is NOT idiot-proof.

replace this

Code: Select all

[r if(getCurrentMapName()==Dest),code:{


with this (note the missing ,)

Code: Select all

[r,if(getCurrentMapName()==Dest),code:{
 


Hope thats the only one ...