IF() and IF(roll option) question

Talk about whatever topic you'd like, RPG related or not. (But please discuss things related to our software in the Tools section, below.)

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
darkeness66
Giant
Posts: 124
Joined: Wed Feb 07, 2007 8:55 pm
Location: Fremont, OH

IF() and IF(roll option) question

Post by darkeness66 »

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. :?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: IF() and IF(roll option) question

Post by wolph42 »

darkeness66 wrote:Is the same true of the IF(roll option) function
no
Are Json faster or just considered easier to use?
read the 'speed up macros' link in my sig. for more info (see no 8) but in short: no
and 'easier': depends on what you want to achieve.

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

Re: IF() and IF(roll option) question

Post by aliasmask »

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:

Code: Select all

Attack: {attackRoll} Damage: {damageRoll}
Do do this:

Code: Select all

[R: strformat("Attack: %{attackRoll} Damage: %{damageRoll}")]
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.

User avatar
darkeness66
Giant
Posts: 124
Joined: Wed Feb 07, 2007 8:55 pm
Location: Fremont, OH

Re: IF() and IF(roll option) question

Post by darkeness66 »

Thanks guys.


Post Reply

Return to “General Discussion”