Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Calling character abilities from within other character abilities

February 13 (6 years ago)

Hi everyone,

I hope some of you might be able to help me: I'm creating a Campaign for my own self-made system, so I'm trying to make things easier for the players (and me) by using Macros and abilities. Since it would be a hell lot of work to do each character individually by hand, I wanted to create a template char, already holding all the attributes and abilities, so that I can just duplicate this and individualize it.

Now for the interesting part: I want to create an ability, which calls three other abilities from the same character, to avoid having to put the same code in all over again. But since I want it to be a template, I'd like to avoid calling the ability for the specific template char, and rather call it generally from the char executing this macro. Is there a way to do so?

February 13 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

It would help to have examples of your code so we can tell you how to do it with practical examples. It can be done, just use % before the ability name (or # for macros). You have to be careful though, not all abilities will work this way - it depends on their contents.

February 13 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

If an ability calls abilities from the same character, you can use just plain old ~AbilityName in some cases. It will automatically call the ability from the current sheet. But as GIgs said, some code examples will help. There are different ways of doing everything.

I'd suggest using a macro sheet for the actual abilities, and have the characters call abilities from it. That way your code is centralized and portable. There's less of it, and you can modify the ability for all characters by editing one ability.

February 13 (6 years ago)

Edited February 13 (6 years ago)

Alright, examples:

The ability "Wissen" contains

/w gm Wert ist @{Wis}
#1d100

The macro  1d100 is this:

/roll [[(1d100cs<10cf>90)]]

The ability I'm struggling with is at the moment like this:

/w gm Ausgleichwert ist @{Tal1}
%{TestDude|Wissen}
%{TestDude|Charisma}
%{TestDude|Intuition}

What I want is pretty much like this, but without having to write the TestDude all the time, so that I can more easily rename that character or its clone.

Initially I wanted to have the basic ability "Wissen" to roll against the attribute Wis, but I couldn't figure out, how to get that to work, so I just whisper the value to the GM (me) and check manually, if it worked out.

The ability in question should then have an extra attribute, from which can points be drawn, if one of the basic abilities ("Wissen", "Charisma" or "Intuition") fails to be below it's related specific attribute.

Just for you to get the initial plan, maybe it is easier to figure out how to do that, than the things I want to do ;)

February 13 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

If you have created all the Abilities on the same character, this should work:

/w gm Ausgleichwert ist @{Tal1}
%{Wissen}
%{Charisma}
%{Intuition}

Assuming they are all abilities, and not attributes. What error messages do you get?

Does the macro command #1d100 work? Often in programming, things that start with numbers dont work, and you would rename it to something like d100 or oned100, but I don't know if thats necessary on roll20.

This is how do do a roll against an attribute (I think this is the proper ordering)

/w gm Wert ist @{Wis}
/roll [[1d100<@{Wis}cs<10cf>90]]
February 13 (6 years ago)

The first suggestion sadly doesn't work, it prompts

TypeError: l is undefine

The second one does work the way I wanted it to, thanks.

The macro does work, at least I didn't encounter any problems particular with this

February 13 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

Asd Z. said:

The first suggestion sadly doesn't work, it prompts

TypeError: l is undefine

That error is saying one of your abilities is calling an attribute named I that doesnt exist. 

Check the contents of your three abilities. Do they each work individually, and can you post them? 

February 13 (6 years ago)

Tested them, they're all running. No clue what it could be. All abilities individually:

"Wissen"

***Probe auf Wissen***
/roll [[1d100<@{Wis}cs<10cf>90]]

"Charisma"

***Probe auf Charisma***
/roll [[1d100<@{Cha}cs<10cf>90]]

"Geschick"

***Probe auf Geschick***
/roll [[1d100<@{Ges}cs<10cf>90]]

That is all, which the abilities do.

Our problematic ability again, just to be sure:

***Probe für *** *Tal1*
/w gm Ausgleichwert ist @{Tal1}
%{Wissen}
%{Charisma}
%{Intuition}

Hope we can get anywhere near a solution...

February 13 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

I've been testing this and am getting weird errors that shouldn't be happening. It might be a bug of some sort.

Anyone else want to try this.

I created a new blank character, and added two abilities:

First contained the following:

Probe fur Tal1
/w gm Ausgleichwert ist
%{Test}

Second, named Test, contained the following

A Test

When I run the first macro I get an error:

TypeError: Cannot read property 'substring' of undefined

I'm pretty sure this should not be happening.

I removed all special characters, attribute calls, etc., to make sure it wasnt a html entity problem. It looks like nesting abilities is failing, even with the simplest text. Anyone have any idea why this is happening?

February 13 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

You are referencing an ability on the same sheet. Use a tilde instead of percent:

Probe fur Tal1
/w gm Ausgleichwert ist
~{Test}
February 13 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Of course, as written, running the central Ability will trigger all sub-Abilities at run time. Was the intent to have the ability to run the central macro and then choose the final macro from a list? In which case, I'd put it in a roll template:

/w gm &{template:default} {{name=Probe fur Tal1}} {{=Ausgleichwert ist
[Ability One](~Ability1)
[Ability Two](~Ability2)}}

I'm not sure what the text translates to, so you might need to tweak.


February 13 (6 years ago)

Edited February 13 (6 years ago)


keithcurtis said:

You are referencing an ability on the same sheet. Use a tilde instead of percent:

Probe fur Tal1
/w gm Ausgleichwert ist
~{Test}

I've tried and replaced percentage with tilde. Now it doesn't error anymore, but also stopped running the abilities and instead just prints the lines out (which is not exactly what I want it to do, obviously)


keithcurtis said:

Of course, as written, running the central Ability will trigger all sub-Abilities at run time. Was the intent to have the ability to run the central macro and then choose the final macro from a list? In which case, I'd put it in a roll template:

/w gm &{template:default} {{name=Probe fur Tal1}} {{=Ausgleichwert ist
[Ability One](~Ability1)
[Ability Two](~Ability2)}}

I'm not sure what the text translates to, so you might need to tweak.


At this point, I must admit that I'm no longer able to follow. And whatever it is doing, it is neither what I want it to, nor working properly. I copied your code and replaced the Ability1 and Ability2 with actual abilities I've already got, up and running. I clicked one of the promted buttons, to generate a value (at least that is what I think it is for) and I just get the old "TypeError: l is undefined" thing again.


I realize, that my code might be difficult to understand, since it contains German parts. I'll try a rough translation of it.

***Test on *** *Tal1*
/w gm compensation value is @{Tal1}
%{Knowledge}
%{Charisma}
%{Intuition}

The called ability Knowledge would include

***Test on knowledge***
/roll [[1d100<@{Wis}cs<10cf>90]]

The others are analogue, just altering the message and the questioned attribute. The attribute I try to call exist, I double-checked that. The abilities I use work fine on their own, just in combination they seem to fail. As mentioned earlier, I've no further clue, what the problem could be.

February 14 (6 years ago)

Edited February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

So the output you are expecting will be:

Test on Tal1
compensation value is [Some value for Tal1]
Test on knowledge
rolling 0
0
= 0
Test on Charisma
rolling 0
0
= 0
Test on Intuition
rolling 1
1
= 1

Assuming a qualifying roll for Intuition? Note that as written, only the second line will be whispered to the GM, all others will follow whatever output the sheet dictates? Or open chat text in the case of no sheet?

February 14 (6 years ago)

Edited February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Also, there are a number of things I don't understand about your sub macro, now that I take a closer look. You use the /r command, but follow it with an inline roll. This tells the roller to resolve the inline roll, and then roll that result. This is redundant at best and might introduce errors. Also, as written, it is reporting the number of successes (d100 rolls that are under the referenced attribute) and then whether that number is a critical success (less than 10 outlines roll in green) or critical failure (greater than 90 outlines roll in red). Is that the intent?

February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Got it.

For whatever reason, the master macro wants to know which character's Ability to use, possibly because they are running within the master macro. You could put the character name in there, but that would make the macro specific for that character, and you'd have to re-write for every character.

Use this for your master macro code:

***Probe für *** *Tal1*
/w gm Ausgleichwert ist @{Tal1}
%{@{character_name}|Wissen}
%{@{character_name}|Charisma}
%{@{character_name}|Geschick}
February 14 (6 years ago)

Edited February 14 (6 years ago)

keithcurtis said:

So the output you are expecting will be:

Test on Tal1
compensation value is [Some value for Tal1]
Test on knowledge
rolling 0
0
= 0
Test on Charisma
rolling 0
0
= 0
Test on Intuition
rolling 1
1
= 1

Assuming a qualifying roll for Intuition? Note that as written, only the second line will be whispered to the GM, all others will follow whatever output the sheet dictates? Or open chat text in the case of no sheet?


That is exactly what I want it to do.

keithcurtis said:

Also, there are a number of things I don't understand about your sub macro, now that I take a closer look. You use the /r command, but follow it with an inline roll. This tells the roller to resolve the inline roll, and then roll that result. This is redundant at best and might introduce errors. Also, as written, it is reporting the number of successes (d100 rolls that are under the referenced attribute) and then whether that number is a critical success (less than 10 outlines roll in green) or critical failure (greater than 90 outlines roll in red). Is that the intent?


Yeah, probably there are some rendundancies, I'm quite new to roll20 as a GM and made the best I could out of the wiki articles and my understanding of it. The part with the crits is important to know, since a critical failure might result in injuries to the party, while a critical success might end up killing off not just one, but two opponents in one strike.


keithcurtis said:

Got it.

For whatever reason, the master macro wants to know which character's Ability to use, possibly because they are running within the master macro. You could put the character name in there, but that would make the macro specific for that character, and you'd have to re-write for every character.

Use this for your master macro code:

***Probe für *** *Tal1*
/w gm Ausgleichwert ist @{Tal1}
%{@{character_name}|Wissen}
%{@{character_name}|Charisma}
%{@{character_name}|Geschick}


Well, that looks very plausible to me, but either I'm implementing it at the wrong place, or roll20 doesn't finds this as plausible as I do.

Copy pasted it as well to a character ability as to a new standalone macro, which is later called by the ability, and neither worked. Both gave me an error, second version also a TypeError, but this time c is undefined. First version (your code  copy-pasted to an ability) throws multiple errors and then just prints the character name, like this:

No ability was found for %{@{CharTemplate|character_name}
No ability was found for %{@{CharTemplate|character_name}
No ability was found for %{@{CharTemplate|character_name}
Asd Z. (GM): Probe für Tal1
(To GM): Ausgleichwert ist 12
Asd Z. (GM): CharTemplate
CharTemplate
CharTemplate
February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Post the code from your Ability, since that was my test case.

This is what I was getting from my test (Note that I put the value "Value " in Tal1, since I wasn't sure what was wanted there):


February 14 (6 years ago)

Ability code is this:

***Probe für *** *Tal1*
/w gm Ausgleichwert ist @{Tal1}
%{@{character_name}|Wissen}
%{@{character_name}|Charisma}
%{@{character_name}|Geschick}
February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

What is the value of Tal1? I'm trying to duplicate your setup as closely as possible. I have "50" in each of the other attributes.

Is my screen shot showing what you are trying to make happen?

February 14 (6 years ago)

Called abilities look like this:

***Probe auf Wissen***
/roll [[1d100<@{Wis}cs<10cf>90]]
***Probe auf Charisma***
/roll [[1d100<@{Cha}cs<10cf>90]]
***Probe auf Geschick***
/roll [[1d100<@{Ges}cs<10cf>90]]

Attributes in question are these:

Wis 10/100

Cha 50/100

Ges 70/100

Tal1 12/39


Hope that helps in any way

February 14 (6 years ago)

Yes, it is. Now I just have to get it to my screen too.

February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Also, make sure all the sub abilities are closed and saved. You can run them independently when they are open, but if you reference them, they only deliver the code they had the last time they were closed and saved.
February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


Asd Z. said:

Yes, it is. Now I just have to get it to my screen too.

I feel we are very close.

February 14 (6 years ago)

Alright, that seems to have been the trick. Closing and saving them all. One could have thought about that.

Sorry to have stolen you so much of your time and thank you for helping me out with this.

February 14 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Whew! It was an interesting problem and it taught me a few things I didn't know. Glad you got it!