Macro help - If Statements and Functions

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
CixrTyx
Cave Troll
Posts: 38
Joined: Thu Aug 26, 2010 2:54 pm

Macro help - If Statements and Functions

Post by CixrTyx »

Hey Guys,
I'm looking at making a multi-line if statement is this possible?
Also are nested if's possible?

IF (condition = value) THEN
Line1
Line2
Line3

ELSE
Line1
Line2
Line3

END IF

Also wondering if you can write functions?
Call DamageTaken()
Function DamageTaken
{
IF (condition = value) THEN
Line1
Line2
Line3

ELSE
Line1
Line2
Line3

END IF
}


Can you give me an example in code?

User avatar
Xaelvaen
Dragon
Posts: 498
Joined: Wed Aug 31, 2011 9:49 pm
Location: Somewhere between Heaven and Hell

Re: Macro help - If Statements and Functions

Post by Xaelvaen »

Code: Select all

[h, if(condition=X), CODE:{
<!---- You can put multiple lines of code here----->
[h: variable1=Y]
[h: variable2=Z]
[h: output="This resulted in True."]

};{
<!---- Anything put here is the failure, or the not IF ----->
[h: variable1=1]
[h: variable2=2]
[h: output="This resulted in False."]
}]
If you don't want the ELSE section, just close off the CODE as follows:

Code: Select all

[h, if(condition=X), CODE:{
[h: variable1=Y]
[h: variable2=Z]
[h: output="This resulted in True."]
};{}]
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Macro help - If Statements and Functions

Post by Full Bleed »

CixrTyx wrote:Hey Guys,
I'm looking at making a multi-line if statement is this possible?
Also are nested if's possible?

Can you give me an example in code?
Be sure to check out this: http://lmwcs.com/rptools/wiki/Macros:Br ... nd_Looping

In particular, look at how to use nested code blocks with the various branching and looping functions.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

CixrTyx
Cave Troll
Posts: 38
Joined: Thu Aug 26, 2010 2:54 pm

Re: Macro help - If Statements and Functions

Post by CixrTyx »

Thanks a ton guys? What about functions?

CixrTyx
Cave Troll
Posts: 38
Joined: Thu Aug 26, 2010 2:54 pm

Re: Macro help - If Statements and Functions

Post by CixrTyx »

Alright I have some code that is acting up on me? Can you guys help, and if you have the time write out some simple code for me?
I'm trying to make three super simple Hit Point macros; one for damage, one for healing, and one for temporary HP.
I need the damage macro to make sure that its doesn't go below 0 HP and it takes away from the TempHP first before the HP (e.g. I have 50 HP and 10 THP, I take 5 damage I now have 50 HP and 5 THP, I take 40 damage I now have 15 HP and 0 THP.)
Healing macro can't go above MaxHP.
TempHP should just set the THP to whatever value they enter, though make sure that if the value they enter is larger than the Current THP (e.g. I have 10 HP and 10 THP, I gain 5 THP I should still have 10 THP. If I gain 20 THP then I have 20 THP instead of the 10 I had).
I use this for D&D 5th Ed so it's those rules for TempHP.

My template is basic this is what's in it:
MaxHP:0
*@HP:0
*@TempHP:0
I need ot add more items in my basic template tell me and I will.
Can you guys help me out on this? I'm not a great programmer and I've been stuck on this for months and months now.

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

Re: Macro help - If Statements and Functions

Post by aliasmask »


User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Macro help - If Statements and Functions

Post by Full Bleed »

CixrTyx wrote: I use this for D&D 5th Ed so it's those rules for TempHP.
You might be reinventing the wheel.

Have you taken a look at the available 5e frameworks?

This one has been around awhile: http://forums.rptools.net/viewtopic.php?f=85&t=25490

And this one hasn't been released yet, but looks very promising and simple to use: http://forums.rptools.net/viewtopic.php?f=8&t=27296
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “Macros”