calling macro problem

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
sigmarpriest
Kobold
Posts: 5
Joined: Fri Nov 20, 2015 4:34 pm

calling macro problem

Post by sigmarpriest »

Hi,
I'm trying to separate one big macro into few small, because it use too much memory.
On wiki I found how to call macros, but in all of examples macro_arguments is a roll.
Can I insert there a normal argument, which refer to results from switch() option?
I mean:

Code: Select all

[h: Property= criticaldmg]
[h: hit= 1d10]
[h: val=10-hit]
[h: val1=val+1]

[h: string1=substring("1122334455", val, val1)]
[h: string2=substring("2334455667", val, val1)]
[h: string3=substring("4556677889", val, val1)]
[h: string4=substring("5667788990", val, val1)]
[h: string5=substring("6677889900", val, val1)]
[h: string6=substring("6778899000", val, val1)]
[h: string7=substring("7788990000", val, val1)]
[h: string8=substring("7889900000", val, val1)]
[h: string9=substring("8899000000", val, val1)]
[h: string0=substring("8990000000", val, val1)]

[h, switch(Property):
case "1": string=string1;
case "2": string=string2;
case "3": string=string3;
case "4": string=string4;
case "5": string=string5;
case "6": string=string6;
case "7": string=string7;
case "8": string=string8;
case "9": string=string9;
case "10": string=string0]

[h: value=string]
[h, if(body==0), CODE: {[macro("cglowa@Lib:Token"): value]};{}]

I checked whether value is number, yes it is.
Macro call work if I set value as 1d10 roll.

Best regards.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: calling macro problem

Post by Craig »

That code you have there looks all right. Its hard to tell because I can't see the macro you are calling but if you say it works with a roll like "1d10" but not a number make sure you are not trying to call eval() on the args as in the example macro.args. eval should only be used to turn a roll string into a number.

sigmarpriest
Kobold
Posts: 5
Joined: Fri Nov 20, 2015 4:34 pm

Re: calling macro problem

Post by sigmarpriest »

Eval() was my mistake. :oops:

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: calling macro problem

Post by aliasmask »

You could use eval on a number but need to wrap it in Wiki: string().

Code: Select all

[R: eval(string(10))]

Post Reply

Return to “Macros”