or it's just me... but, I'm trying to spawn an evil rat near a bad guy necromancer. I wrote a macro in my necromancer :
---
[h: CurrentX = getTokenX()]
[h: CurrentY = getTokenY()]
[h: x = CurrentX]
[h: y = CurrentY]
[h: NumRats = 1d4 +1]
[h: cloneNo = 0]
[h: updates = "{
name: 'Rat - [r: cloneNo = cloneNo + 1]',
x: '[r: x = x + 2]',
y: '[r: y = y + 1]',
delta: 0
}"
]
[h: cloneNo = 0]
[h: copyToken("RatSangi", NumRats, "Accueil", updates)]
----
And... My Rats spawn near their original position of the map "Accueil" but too far from my Necromancer.
Thank's for helping.
Something wrong with copytoken() ?
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Something wrong with copytoken() ?
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).
Re: Something wrong with copytoken() ?
There were changes to Wiki: copyToken(), so your MT version is important to know. But it does sound like a bug if they're being copied to the "from" map. If that is the same map, then it could be related to the delta value. I would assume 0 is token running the macro and 1 is the source token, but try and change to 1 to see if it does it correctly. You can also test the useDistance option. Should be set to 0, which is supposed to be the default.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Something wrong with copytoken() ?
I use version 1.5.14
The first Rat is on my first map ("Acceuil") and copied on the third map. When I use "usedistance", set to 1 or 0, nothing change same for delta: 0 or 1. My Rats pop and the same corner of my map. Seems this 2 parameters are "useless".
The first Rat is on my first map ("Acceuil") and copied on the third map. When I use "usedistance", set to 1 or 0, nothing change same for delta: 0 or 1. My Rats pop and the same corner of my map. Seems this 2 parameters are "useless".
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).
Re: Something wrong with copytoken() ?
Yeah, sounds like a bug. I'll test and see if I can duplicate, the file report on github.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Something wrong with copytoken() ?
After some testing, I did get it to copy where I wanted. I'm thinking your format for the x,y coordinates is the problem.
Here is my test code:
You need to specify 0 for your getTokenX and Y so it uses grid coords rather than pixel.
Here is my test code:
Code: Select all
[H: x = getTokenX(0)]
[H: y = getTokenY(0)]
[H: copyToken("Monster Ape",2,"TestMap",json.set("{}","x","[r: x = x + 1]","y",y))]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Something wrong with copytoken() ?
However, I did find a bug with the delta. When you specify the delta of 1 the offset of X is the calling token. So, if your x is 1, then it will use your token position, plus 1. BUT.... for some reason instead of your token position, it's the token position +2 and +1 in y-direction (two over, one down).
So, this would make it correct:
So, this would make it correct:
Code: Select all
[H: x = -2]
[H: y = -1]
[H: copyToken("Monster Ape",2,"TestMap",json.set("{}","delta",1,"x","[r: x = x + 1]","y",y))]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Something wrong with copytoken() ?
Well that's rather strange but ye your solution above worked just fine but you are sure the +2 inc and +1 in y isn't caused by those 2lines of codes ?
x: '[r: x = x + 2]',
y: '[r: y = y + 1]',
Because logically it will take the position and add +2 in x and +1 in y no ?
x: '[r: x = x + 2]',
y: '[r: y = y + 1]',
Because logically it will take the position and add +2 in x and +1 in y no ?
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).
Re: Something wrong with copytoken() ?
No, the weird offset was due to the x,y position of the token on the other map. IMO, this is wrong. It should be using the x,y of the calling token, but it may have been designed that way for *reasons*.SamCCB wrote: ↑Fri Mar 20, 2020 11:08 amWell that's rather strange but ye your solution above worked just fine but you are sure the +2 inc and +1 in y isn't caused by those 2lines of codes ?
x: '[r: x = x + 2]',
y: '[r: y = y + 1]',
Because logically it will take the position and add +2 in x and +1 in y no ?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Something wrong with copytoken() ?
Well it's working now. [H: x = getTokenX(0)] [H: y = getTokenY(0)] fix the start point of spawn. For the relative position, I'm happy with that but it's seems "strange" as you write.
Thank you for helping.
Thank you for helping.
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).