My input only shows up once outside of the loop. What may be happening in your testing is you have the macro set to "Apply to all tokens" which you don't want to do. That will essentially run it on each token, then loop through all the tokens making it run X squared times where X is the number of tokens selected.Irrlicht wrote:I thought Raktus wanted the input to pop up only once and apply the same settings for every token, doesn't that code make it appear for every token selected?
Mass Rolling Macro (Help Needed)
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Mass Rolling Macro (Help Needed)
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Mass Rolling Macro (Help Needed)
Ah, alright, I hadn't tested it, but yes, I was mentally applying to selected tokens for habit.
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
Re: Mass Rolling Macro (Help Needed)
Something to note on that part though, if you do it my way anyone can run the macro on any tokens, even unowned tokens. More code will be needed if you want to limit the selected tokens to owned tokens, which is pretty easy. But in a friendly game, that probably isn't a high priority.Irrlicht wrote:Ah, alright, I hadn't tested it, but yes, I was mentally applying to selected tokens for habit.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Mass Rolling Macro (Help Needed)
edit: missed the fact that there was an entire page of discussion on teh next page, but ill leave this post anyway here.
I would do it slightly more efficient and more 'resilient':
I would do it slightly more efficient and more 'resilient':
Code: Select all
[H: selected = getSelectedNames("json")]
[h:assert(listCount(selected),"Make sure at least one token is selected",0)]
<!-- Set a variable outside of the foreach -->
[H:abort(input("attribute|Strength,Dexterity,Constitution|Select Attribute|LIST|VALUE=STRING"))]
[H: output = "[]"]
[H, foreach(tokenName,selected), if(isOwner(getPlayerName(), tokenName)), code: {
[roll = 1d20]
[attributeBonus = floor((number(getProperty(attribute, tokenName))-10)/2)]
[result = roll + attributeBonus]
[output = json.append(output,strformat("%{tokenName}: %{roll} + %{attributeBonus} = %{result}"))]
}]
[R: json.toList(output,"<br>")]
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