Beam me up, Scottie

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

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Beam me up, Scottie

Post by CoveredInFish »

Nah ... wasnt the last one. Thanks to PinkRose to finding it for me.

I made an error in calculating the new position that caused the formation to appear mirrored. This is now fixed...

Code: Select all

[habort(isGM())]

[
htokenId = if(getSelected()=="",getPC(),getSelected())]
[
htokenNm ""]

[
hCoordinatesInUnits 0]
[
hjsonAllOffsets ""]
[
hreferenceToken listGet(tokenId0)]
[
hxOrigin getTokenX(CoordinatesInUnitsreferenceToken)]
[
hyOrigin getTokenY(CoordinatesInUnitsreferenceToken)]

[
h, foreach(in,tokenId), code: {
    [
htokenNm listAppend(tokenNm,getName(in))]
    [
hxOffset getTokenX(CoordinatesInUnitsin)]
    [
hyOffset getTokenY(CoordinatesInUnitsin)]
    [
hjsonOffset json.set("""x"xOrigin xOffset"y"yOrigin yOffset)]
    [
hjsonAllOffsets json.setjsonAllOffsetsinjsonOffset )]
}]
[
hLst ""]
[
hin  =0]
[
h, while(tbl("Mapa",in)!=tbl("Mapa",in+2)),code:{
    [
hin=in+1]
    [
hLst=listAppend(Lst,listGet(tbl("Mapa",in),3))]
}]

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

[
hDest=listGet(tbl("Mapa",map),0)]
[
hx=listGet(tbl("Mapa",map),1)]
[
hy=listGet(tbl("Mapa",map),2)]


[
r,if(getCurrentMapName()==Dest),code:{
    [
h,foreach(in,tokenId),code:{
        [
hjsonOffset json.get(jsonAllOffsetsin)]
        [
hxOffset json.get(jsonOffset"x")]
        [
hyOffset json.get(jsonOffset"y")]
        [
moveToken(x-xOffsety-yOffset,0,in)]
    }]
    [
r:tokenNmmovido(s[r:Dest] [goto(x,y)]
};{
    [
h,foreach(in,tokenId),code:{
        [
hjsonOffset json.get(jsonAllOffsetsin)]
        [
hxOffset json.get(jsonOffset"x")]
        [
hyOffset json.get(jsonOffset"y")]
        [
moveTokenToMap(inDestx-xOffsety-yOffset)]
    }]
    [
r:tokenNmllevado(sal mapa [r:setCurrentMap(Dest)] [goto(x,y)]
}]
 

User avatar
PinkRose
Dragon
Posts: 732
Joined: Sat Nov 15, 2008 2:28 pm
Location: The City of Roses, Oregon

Re: Beam me up, Scottie

Post by PinkRose »

Thank you so much.
As a non-coder, I sincerely appreciate it.
I am a special snowflake!

User avatar
patoace
Dragon
Posts: 313
Joined: Mon Sep 24, 2007 6:10 pm
Location: Rancagua - Chile

Re: Beam me up, Scottie

Post by patoace »

I guess by now most people are using Lindsay's excellent tool for moving tokens between maps, but for documentation purposes I left here the code I'm currently using, based on the macro in the original post.

You don't need a specifically formated table anymore, the macro considers every token in the destination map hidden layer an available drop point. If it doesn't find any token in the hidden layer, it defaults to the 0,0 coordinates. This way, the only preparation needed is to put a token in that layer. It also moves tokens inside a map.

To "install", just drop this code in a campaign macro.

Code: Select all

<!--
Aborts if the user isn't the GM
[abort(isGM())]

If there are tokens selected, apply to them, else all PC are affected
[tokenId=if(getSelected()=="",getPC(),getSelected())]
[tokenNm=if(getSelected()=="",getPCNames(),getSelectedNames())]
[Desde=getCurrentMapName()]

Ask for the destination map
[abort(input(
"Fichas|"+tokenNm+"|Tokens|Label",
"map|"+listSort(getVisibleMapNames(),"a")+"|Destination|Radio|value=string"
))]

If the destination isn't the current map, send the token there (at 0,0).
[if(Desde!=map),code:{
   [setCurrentMap(map)]
   [foreach(in,tokenId):moveTokenFromMap(in,Desde,0,0,0)]
   [cambio=1]
   };{
   [cambio=0]
}]

Builds the list of available destinations (tokens in the hidden layer)
[marca=""]
[foreach(in,getTokenNames()):marca=if(getLayer(in)=="GM",listAppend(marca,in),marca)]

Ask for one destination
[if(marca!=""),code:{
[abort(input(
"Lugar|"+marca+"|Place|List|Value=string"
))]
[x=getTokenX(0,Lugar)]
[y=getTokenY(0,Lugar)]
[goto(Lugar)]
};{
[Lugar="mapa"]
[x=0]
[y=0]
}]

Move tokens to the selected destination
[foreach(in,tokenId),code:{
   [moveToken(x,y,0,in)][x=x+1]
   }]
-->

<!--Send output to chat -->
[if(cambio),code:{
[r:tokenNm] taken to map [r:macroLink (map,"[email protected]:token","","Dest="+map+";x="+x+";y="+y)]
};{
[r:tokenNm] moved to [r:macroLink (Lugar,"[email protected]:token","","Dest="+map+";x="+x+";y="+y)]
}]


The macro is for the use of the GM only, but it send a link for the player to click and be sent to where the token is.

This is the code for the "[email protected]:token" macro

Code: Select all

[h:varsFromStrProp(macro.args)]

[h,if(getCurrentMapName()==Dest),code:{
[goto(x,y)]
};{
[setCurrentMap(Dest)] [goto(x,y)]
}]

Post Reply

Return to “User Creations”