Break and Return

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

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. :)
Post Reply
MafiaPUppet
Cave Troll
Posts: 33
Joined: Thu Aug 02, 2012 9:36 pm

Break and Return

Post by MafiaPUppet »

Are there break and return commands for maptool?

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Break and Return

Post by aliasmask »

There is Wiki: abort(), but that ends macro execution and not just that particular macro call. You can create other macro execution chains with Wiki: execLink() and using the defer parameter. What that will do is start another macro when the current execution chain ends. But if you're looking just just bail out of a loop, I would use [while:] and set the condition to escape inside the loop. The loop still keeps track of the roll.count, but I recommend assigning it to a variable at the top of the loop because there are things out there that may change it in the middle of loop.

Code: Select all

[H: condition = 1]
[H, while(condition), code: {
   [H: index = roll.count]
   <!-- do stuff -->

   <!-- set condition to exit -->
   [H: condition = if(index >= 10,0,1)]
}]
This would just loop 11 times because roll.count starts at 0, but you can set whatever condition you like based off of calculations rather than the index. But I would also build in a max loop condition so it doesn't run forever (1000 iterations is maptool max).

Post Reply

Return to “MapTool”