Hello again.
Is it possible, to get array of tokens in XY coordinations without checking every token in map? Wiki: getTokens() function works well, but with larger amount of tokens in map, it deffers macro quite lot.
getTokens - without check every token?
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.
getTokens - without check every token?
Last edited by Nertht on Mon Aug 11, 2014 9:52 am, edited 3 times in total.
Re: getTokens - without check every token?
Yes and no. If you read Wiki: getTokens() you can specify a range around a token. So, yes you can specify filters to the getTokens, but no you can't specify with just an x,y coordinate. It has to be centered on a token. One method would be to move a token to area and make the check. Also, you can get visible tokens and filter those with canSeeToken from that token's position. I don't know what your application is, so I can't give you specifics on your needs.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: getTokens - without check every token?
First of all, thanks for instant reply,
but my problem isnt, that I cant define tokens in XY. Problem is, that i cant do that without checking every token in the map. When I use Wiki: getTokens() and define condition (for example - State), MT will check every token with defined state. But when I define area as condition, MT will check every token in the map and after it will define which tokens from whole map is in XY. And when i have about 10000 tokens, using of this function will deffer execution really lot.
Is there any better way to do it?
but my problem isnt, that I cant define tokens in XY. Problem is, that i cant do that without checking every token in the map. When I use Wiki: getTokens() and define condition (for example - State), MT will check every token with defined state. But when I define area as condition, MT will check every token in the map and after it will define which tokens from whole map is in XY. And when i have about 10000 tokens, using of this function will deffer execution really lot.
Is there any better way to do it?
Last edited by Nertht on Mon Aug 11, 2014 11:10 am, edited 1 time in total.
Re: getTokens - without check every token?
No. If you define area correctly then it will only retrieve tokens in that area. That method can however be insanely slow. Fastest method is using states, next you can move a token to the centre of the area you wish to grab and use that token together with the range option.
I usually just cycle through all tokens, using a slice method in case their are more than 1000 tokens(which is the loop limit in mt)
I usually just cycle through all tokens, using a slice method in case their are more than 1000 tokens(which is the loop limit in mt)
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: getTokens - without check every token?
Slice method? Could you tell me more about it?
Re: getTokens - without check every token?
Argh on.the.autocorrect. splice method. Anyway, it's a function on the bag of tricks that creates an array of lists of exactly 1000 elements per list, allowing for a loop upto 1000000 tokens. You can cycle through them with two for each loops. Usually you then run into the other limit of max 2 {} nesting, which can be omitted by the '' method(read the working with two code levels article, linked in Sig) .Nertht wrote:Slice method? Could you tell me more about it?
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: getTokens - without check every token?
examples are always so much more useful, im currently working on something so its a copy paste for me:
bot_createSplices() is a function available as soon as you have lib:ontokenmove installed in your framework.
The '' are single quotes (two of them. And placed where they are, they allow for more than two code levels.
Code: Select all
[h:allToks = getTokenNames(",", '{layer:["TOKEN", "HIDDEN", "OBJECT", "BACKGROUND"]}')]
[h:splices = bot_createSplices(allToks)]
[h,foreach(splice, splices), CODE:{
[foreach(tok, splice), CODE:{
[x = getTokenX(0, tok)]
[y = getTokenY(0, tok)]
[if(x >= 0 && y >= 0 && x <= 35 && y <= 35), CODE:{
<!-- your code here -->
''
};{}]
''
}]
''
}]
The '' are single quotes (two of them. And placed where they are, they allow for more than two code levels.
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: getTokens - without check every token?
Thanks a lot, it saves me again...