copyToken questions
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: copyToken questions
yup
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: copyToken questions
by the way
xavram wrote:Oh cool, documentation on wiki doesn't say that it returns the Id...excellent.
Any ideas on the positioning issue?
i've further updated the wiki to make it even more clear, also added the 'change after copy methods' and (tested) examples.wiki wrote:The return type of this function is determined by the number of copies that you are making. If you are only creating a single copy of the token then a string containing the Tokens id, if you are making more than one copy then a JSON Array containing the Token ids of all the newly created Tokens is returned.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: copyToken questions
Missed that! Thanks Wolph!
I have been without power at my house for 3 days (crazy wind storm knocked down like 8 power poles), so I'm looking forward to actually trying to get this to work over the weekend...
I have been without power at my house for 3 days (crazy wind storm knocked down like 8 power poles), so I'm looking forward to actually trying to get this to work over the weekend...
Re: copyToken questions
So, related to this...
the "MoveTokenFromNap" call that I was going to use requires the token id for the token that's on the other map. In my case, this is the "Resource" map.
I know the names of all the relevant tokens on that map, but not the Ids. And "FindToken" only works on the current map, right? So how do I get the Id of the token I want to move to my current map, without actually switching maps?
the "MoveTokenFromNap" call that I was going to use requires the token id for the token that's on the other map. In my case, this is the "Resource" map.
I know the names of all the relevant tokens on that map, but not the Ids. And "FindToken" only works on the current map, right? So how do I get the Id of the token I want to move to my current map, without actually switching maps?
Re: copyToken questions
You can try using the name of token and see if that works. Sometimes the wiki won't specify some things that work. One common one is where ever token id is used, the token name may be able to be used. (but not always)
Other than that, changing maps is exactly what you do, but if you change the map back to the original they there is only a brief flicker on the screen. It doesn't actually need to reload everything.
Other than that, changing maps is exactly what you do, but if you change the map back to the original they there is only a brief flicker on the screen. It doesn't actually need to reload everything.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: copyToken questions
That actually did work, but moving the token to the map seems to have an odd behavior. Once moved, I can't get the token Id.
You would think this would display the token ID but it does not. it DOES move the token from the Resources map over to the current map.
But if I can't get the ID, certain functions aren't going to work. I need to be able to move that token and set some properties, so that I can THEN call the copyToken function on it.
Code: Select all
[h : moveTokenFromMap("Spikes", "Resources" , 10000, 10000, 1)]
[h : droppedId = findToken("Spikes")]
[r : droppedId]
But if I can't get the ID, certain functions aren't going to work. I need to be able to move that token and set some properties, so that I can THEN call the copyToken function on it.
Re: copyToken questions
ok thats really weird cause that should work. you *can* use the token name ALWAYS instead of the ID unless there are two tokens with the same name, then you don't know which one will be changed.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: copyToken questions
So here's the test...
The first time this is called, it moves the "Spikes" token from the Resource map to current map, at 10000, 10000.
If you call it a second time (when the spikes have already been moved to current map), THEN it moves them to 8873, 10633 and sets the rotation to 45.
But that, obviously, is a problem, the fact that it has to be called twice. Its almost like the same issues with copyToken, where you can't immediately access it.
Note that if i change this code to use "Spikes" instead of "droppedId", I get the same behavior.
Code: Select all
[h : moveTokenFromMap("Spikes", "Resources" , 10000, 10000, 1)]
[h : droppedId = findToken("Spikes")]
[h : moveToken(8873.5,10633, 1, droppedId)]
[h : setTokenFacing(45, droppedId)]
If you call it a second time (when the spikes have already been moved to current map), THEN it moves them to 8873, 10633 and sets the rotation to 45.
But that, obviously, is a problem, the fact that it has to be called twice. Its almost like the same issues with copyToken, where you can't immediately access it.
Note that if i change this code to use "Spikes" instead of "droppedId", I get the same behavior.
Re: copyToken questions
There is likely some timing issues. When tokens need to be redrawn, that is done last. Perhaps change the facing and then move token? I recall doing something similar with states and moving a token where I had to move the token last for the state to take effect.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: copyToken questions
I took the "setTokenFacing" line out completely, same results. Token never moves to the coodinates specified in "moveToken"
Re: copyToken questions
I did this test
And I can see the token move to 2,2 and then back to 0,0. It seems moving the token from another map is pretty much done last no matter what. I actually tried several things including using my custom macros:
With the following code:
And I got the same result. You see the token move to 0,0 then to 2,2 and back to 0,0.
I would treat tokens moving from another map as if they were newly created with the same limitations.
Code: Select all
[h : moveTokenFromMap("MoveMe", "Grasslands" , 0, 0, 0)]
[h : id = findToken("MoveMe")]
[H, for(i,0,1000): "pause"]
[h: moveToken(2,2,0,id)]
Code: Select all
@@ @deferFunction
<!-- deferFunction(function,args)
function - function to be deferred
arg - arguments to be passed to function (json array)
-->
[H: function = arg(0)]
[H, if(argCount() >= 2), code: {
[H: args = arg(1)]
[H, if(json.type(args) != "ARRAY"): args = json.append("",args)]
};{
[H: args = ""]
}]
[H, if(currentToken() == ""): target = getMacroLocation();target = currentToken()]
[H: deferArgs = json.append("",function,args)]
[H: link = macroLinkText("execFunction@"+getMacroLocation(),"none",deferArgs,target)]
[H: execLink(link,1)]
!!
@@ @execFunction
[H: function = arg(0)]
[H: args = arg(1)]
[H: argList = ""]
[H, foreach(arg,args), code: {
[H: argList = listAppend(argList,"arg"+roll.count)]
[H: set("arg"+roll.count,arg)]
}]
[H: fnStr = strformat("%{function}(%{argList})")]
[H, C(500):"pause"]
[H: eval(fnStr)]
!!
Code: Select all
[h: moveTokenFromMap("MoveMe", "Grasslands" , 0, 0, 0)]
[H: args = json.append("",2,2,0,"MoveMe")]
[H: am.play.deferFunction("moveToken",args)]
I would treat tokens moving from another map as if they were newly created with the same limitations.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: copyToken questions
Drat...okay, I need to take a step back on how I envisioned this working and tackle it from a different angle.
Re: copyToken questions
So, what are you trying to do specifically.xavram wrote:Drat...okay, I need to take a step back on how I envisioned this working and tackle it from a different angle.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: copyToken questions
Well, what I had was this.
Dropped weapon makers (Oil, spikes, paint, etc, etc) were off on a seperate "Resources" map, with all of their statistics already set in the properties of the weapon.
When a player fires one of these weapons, I was going to move the "resource" token onto the "game" map, position it correctly, and set some additional properties. Then i was going to copyToken on this resource token, then move the resource token BACK to the "Resources" map, to be ready for the next time.
Unfortunately, after the "moveTokenFromMap" call, I can't manipulate the resource token.
In the end, I think I'm going to have to have a "baseDroppedItem" token on the "game" map. I will then have to size it, set the image, set the base properties and all that, then copy it, etc, etc. Effectively, I'm going to have to create a token "from scratch" each time, instead of being able to save a bunch of steps by using "pre-set" resource tokens.
But it looks like that's the road I'm going to have to travel to make this work.
Dropped weapon makers (Oil, spikes, paint, etc, etc) were off on a seperate "Resources" map, with all of their statistics already set in the properties of the weapon.
When a player fires one of these weapons, I was going to move the "resource" token onto the "game" map, position it correctly, and set some additional properties. Then i was going to copyToken on this resource token, then move the resource token BACK to the "Resources" map, to be ready for the next time.
Unfortunately, after the "moveTokenFromMap" call, I can't manipulate the resource token.
In the end, I think I'm going to have to have a "baseDroppedItem" token on the "game" map. I will then have to size it, set the image, set the base properties and all that, then copy it, etc, etc. Effectively, I'm going to have to create a token "from scratch" each time, instead of being able to save a bunch of steps by using "pre-set" resource tokens.
But it looks like that's the road I'm going to have to travel to make this work.
Re: copyToken questions
Best method is to switch to resource map, make your changes then copy the token to the target map. It'll give you a minor flicker when done, but that's it. Or at the start you can copy all the needed resources to the map and then you can adjust and move without the flicker.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools