Trying to make a Skill check makro and my head hurts...

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
User avatar
icingShadow
Kobold
Posts: 6
Joined: Mon Feb 24, 2020 2:18 pm

Trying to make a Skill check makro and my head hurts...

Post by icingShadow »

Hi.
I am trying to make a Skill check macro for my players, but I have no Idea how I can do it the way I want it.
I want a macro wich opens a selection window with a list of all the skills. Then if someone selects one I want it to automatically roll a d20 and add the correct Ability Modifier, then display the number in the chat.

Right now I have a macro for every single skill with the most basic of code.
Here is an example with the Acrobatics skill:

For skills without proficiency

Code: Select all

 
[1d20+DEXMod] 
For skills with proficiency

Code: Select all

 
[1d20+DEXMod+PROFBonus] 
This is working just fine, but I want a more compact macro set for the players so they don't have to search for the right macros.

Here is my code I have right now for the new macro:

Code: Select all

 
 [input("Skill| Acrobatis, Animal Handling ,Arcana, Athletics, Deception, History, Insight, Intimidation, Medicine, Nature, Perception, Performance, Persuation, Religion, Slight of Hand, Stealth, Survival |Skill|LIST|VALUE=STRING")] 
I know this code only shows the List of the skills and if I select one I get a 1 in the chat.

I tried using eval() on the input by giving it a name and then using if() to make something happen if one specific skill is picked, but I only got errors.

Code: Select all

[h: skillChoice = input(	
"Skill| Acrobatis, Animal Handling ,Arcana, Athletics, Deception, History, Insight, Intimidation, Medicine, Nature, Perception, Performance, Persuation, Religion, Slight of Hand, Stealth, Survival |Skill|LIST|VALUE=STRING"
)]
[h: skill = eval(skillChoice)]
[if(skill = Acrobatics), Code:{
	[1d20+DEXMod]
};{}]
Does a list even give out the thing you selected from the list, or is it just a number?

Is there any way to let the macro do something specific if you put in a specific skill? I am looking frantically through all forums I can find, but I can't understand most of them. Please help me.

User avatar
wolph42
Deity
Posts: 9790
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Trying to make a Skill check makro and my head hurts...

Post by wolph42 »

what you want is rather complex. but...if you're willing to put in the effort: http://lmwcs.com/rptools/wiki/input#Examples you want to have a look at example 5, which roughly describes what you want to do with the input.

User avatar
aliasmask
Deity
Posts: 8609
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to make a Skill check makro and my head hurts...

Post by aliasmask »

There's a lot going on there. One bug is to use == in your if() comparison. Also, I'm not sure you can eval something like "Slight of Hand" since it isn't a valid variable name. I just checked, you can't.

User avatar
icingShadow
Kobold
Posts: 6
Joined: Mon Feb 24, 2020 2:18 pm

Re: Trying to make a Skill check makro and my head hurts...

Post by icingShadow »

ok I found something. I can let the program tell me what was selected.

Code: Select all

[token.name] performs an [r: Skill] Check: 
This will give me the skill I selected in my list. But now I've run into another problem. I can try to use if() to let the macro do something when a skill is selected, but I tried that with the Acrobatics skill and the program asks me for another input. specifically what "check" is.

Code: Select all

[if(Skill == "Acrobatics"),code:{
	[h: check = roll+DEXMod]
};{}] 

[token.name] performs an [r: Skill] Check: [check]
Am I doing something wrong with the if() or is it something else entirely?

User avatar
aliasmask
Deity
Posts: 8609
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Trying to make a Skill check makro and my head hurts...

Post by aliasmask »

You'll need a default value for check, like 0 when Skill doesn't equal "Acrobatics". Also, when you only have 1 statement under an if, you can skip some of the block code (for multiple statements) syntax.

Code: Select all

[H: check = 0]
[H, if(Skill == "Acrobatics"): check = roll + DEXMod]

[R: strformat("%{token.name} performs an %{Skill} Check: %{check}")]
Of course, you only need to set a default if there is a chance that check doesn't get set by another if() statement.

User avatar
icingShadow
Kobold
Posts: 6
Joined: Mon Feb 24, 2020 2:18 pm

Re: Trying to make a Skill check makro and my head hurts...

Post by icingShadow »

Thank you very much for your replies. The code works in this form:

Code: Select all

[H: skillChoice = input(	
"Skill| Acrobatics, Animal Handling ,Arcana, Athletics, Deception, History, Insight, Intimidation, Medicine, Nature, Perception, Performance, Persuasion, Religion, Sleight of Hand, Stealth, Survival |Skill|LIST|VALUE=STRING"
)]

[H: abort(skillChoice)]
[H: roll = 1d20]
[H: check = 0]

[H, if(Skill == "Acrobatics"): 			check = roll + DEXMod]
[H, if(Skill == "Animal Handling"):		check = roll + WISMod]
[H, if(Skill == "Arcana"): 			check = roll + INTMod]
[H, if(Skill == "Athletics"): 			check = roll + STRMod]
[H, if(Skill == "Deception"): 			check = roll + CHAMod]
[H, if(Skill == "History"): 			check = roll + INTMod]
[H, if(Skill == "Insight"): 			check = roll + WISMod]
[H, if(Skill == "Intimidation"): 		check = roll + CHAMod]
[H, if(Skill == "Investigation"): 		check = roll + INTMod]
[H, if(Skill == "Medicine"): 			check = roll + WISMod]
[H, if(Skill == "Nature"): 			check = roll + INTMod]
[H, if(Skill == "Perception"): 			check = roll + WISMod]
[H, if(Skill == "Performance"): 		check = roll + CHAMod]
[H, if(Skill == "Persuasion"): 			check = roll + CHAMod]
[H, if(Skill == "Religion"): 			check = roll + INTMod]
[H, if(Skill == "Sleight of Hand"):		check = roll + DEXMod]
[H, if(Skill == "Stealth"): 			check = roll + DEXMod]
[H, if(Skill == "Survival"): 			check = roll + WISMod]


[R: strformat("%{token.name} is making a <b>%{Skill}</b> Check: <b>%{check}</b>")]
Now i only have to add the Proficiency bonus to the right skills and I'm done.
I also used the same method to create a macro for saving throws:

Code: Select all

[H: savingThrow = input(
	"save|Strength,Dexterity,Constitution,Intelligence,Wisdom,Charisma|SKILL|LIST|VALUE=STRING")]
[H: abort(savingThrow)]
[H: roll = 1d20]
[H: check = 0]

[H, if(save=="Strength"): 		check = roll+STRMod]
[H, if(save=="Dexterity"): 		check = roll+DEXMod]
[H, if(save=="Constitution"): 		check = roll+CONMod]
[H, if(save=="Intelligence"):		check = roll+INTMod]
[H, if(save=="Wisdom"):			check = roll+WISMod]
[H, if(save=="Charisma"): 		check = roll+CHAMod]

[R: strformat("%{token.name} is making a <b>%{save}</b> saving Throw: <b>%{check}</b>")]
Thank you all very much for your help :D

User avatar
icingShadow
Kobold
Posts: 6
Joined: Mon Feb 24, 2020 2:18 pm

Re: Trying to make a Skill check makro and my head hurts...

Post by icingShadow »

I also added a litte thing to tell me when it rolls a 20.

Code: Select all

[H: critMessage = ""]

[H, if(roll>19), code:{
	[H: critMessage = '<b>(NICE!)</b>']
};{}]

[R: strformat("%{token.name} makes a <b>%{Skill}</b> Check: <b>%{check} %{critMessage}</b>")]

User avatar
wolph42
Deity
Posts: 9790
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Trying to make a Skill check makro and my head hurts...

Post by wolph42 »

Nice work!! Couple of pointers to help you improve your code skills:

as AM already explained, try to limit the use of cde:{} as you only get to nest two! Here's another way of doing it:

Code: Select all

[H, critMessage = if(roll>19, '<b>(NICE!)</b>', "")]
[R: strformat("%{token.name} makes a <b>%{Skill}</b> Check: <b>%{check} %{critMessage}</b>")]
note that there are TWO if statements in MT, one is the Wiki: if() and the other the [if:] both have their own purpose and use, in the above example I used the function variant, one tricky thing with that one is that it evaluates BOTH true and false and then passes on the correct one. While with the if roll option only the correct statement is evaluated.

as for the input solution you found. when working with those kinds of lists, theres a neat trick to do the same but much quicker and cleaner. What is vital is that the order of the skills and the order of the modifiers match!

Code: Select all

[skillList	= "Acrobatics, Animal Handling ,Arcana, Athletics, Deception, History, Insight, Intimidation, Medicine, Nature, Perception, Performance, Persuasion, Religion, Sleight of Hand, Stealth, Survival"]
[modList	= "DEXMod, WISMod, INTMod, STRMod, CHAMod, INTMod, WISMod, CHAMod, INTMod, WISMod, INTMod, WISMod, CHAMod, CHAMod, INTMod, DEXMod, DEXMod, WISMod"]

[H: abort(input(	
	"Skill| "+skillList+" |Skill|LIST|VALUE=STRING"
))]

[h:check	= 1d20 + listGet(modList, listFind(skillList, Skill))]

[R: strformat("%{token.name} is making a <b>%{Skill}</b> Check: <b>%{check}</b>")]
what this does is look for the index of the position of the skill in the skill list and then gets the corresponding modifier from the modlist (as it has the same position in the list).

You can even do this simpler if you dont' use value=string as that immediately returns the index, then you simply get:

Code: Select all

[h:check	= 1d20 + listGet(modList, Skill)]

betavash
Kobold
Posts: 1
Joined: Fri Oct 16, 2020 10:14 pm

Re: Trying to make a Skill check makro and my head hurts...

Post by betavash »

I really like this macro and want to use it in my campaign.
I was curious if it was possible to add a 2nd roll for Advantage/Disadvantage so the result looks like this?

Acrobatics: 24 (Adv/Dis: 12)

Post Reply

Return to “Macros”