The description of the IF() function says that both the true & false expressions are evaluated, regardless of the condition.
Is the same true of the IF(roll option) function?
Just checking, looking for ways to reduce the stack size needed for my campaign.
In the same vain... I tend to use string functions vs JSON Functions. Are Json faster or just considered easier to use? I'll be honest I keep scratching my head with Json functions. I know I shouldn't, but I do.
IF() and IF(roll option) question
Moderators: dorpond, trevor, Azhrei
- darkeness66
- Giant
- Posts: 124
- Joined: Wed Feb 07, 2007 8:55 pm
- Location: Fremont, OH
Re: IF() and IF(roll option) question
nodarkeness66 wrote:Is the same true of the IF(roll option) function
read the 'speed up macros' link in my sig. for more info (see no but in short: noAre Json faster or just considered easier to use?
and 'easier': depends on what you want to achieve.
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: IF() and IF(roll option) question
The best way to reduce stack size is to not dump output to chat straight from the macro code, for example
Don't do this:
Do do this:
This is just a simple example and wouldn't by itself cause that big of a stack but does demonstrate the difference. IMO, all output should be posted using the [r: ] roll option. When building output, I usually put it in a variable and the last line of function is [r: output] or [r: json.toList(output,"<br>")] where output is a json array and each entry is a new line.
Also, comments around code, especially loops. You should never do this. Use UDFs and set output to 0 for the function. You can then use all the <!-- comments --> you want without affecting the stack. IMO, a framework shouldn't have more than 3M for a stack setting.
There are some stack intensive functions that exist usually dealing with string manipulation, but on impacts the stack if the strings are really big and you nest multiple functions of that type. But this is a very uncommon circumstance.
Don't do this:
Code: Select all
Attack: {attackRoll} Damage: {damageRoll}
Code: Select all
[R: strformat("Attack: %{attackRoll} Damage: %{damageRoll}")]
Also, comments around code, especially loops. You should never do this. Use UDFs and set output to 0 for the function. You can then use all the <!-- comments --> you want without affecting the stack. IMO, a framework shouldn't have more than 3M for a stack setting.
There are some stack intensive functions that exist usually dealing with string manipulation, but on impacts the stack if the strings are really big and you nest multiple functions of that type. But this is a very uncommon circumstance.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- darkeness66
- Giant
- Posts: 124
- Joined: Wed Feb 07, 2007 8:55 pm
- Location: Fremont, OH
Re: IF() and IF(roll option) question
Thanks guys.
Re: IF() and IF(roll option) question
o theres also the 'stack overflow' article in my sig. that might help as well.
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