Page 1 of 1

Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 11:08 am
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?

Re: Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 12:13 pm
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."]
};{}]

Re: Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 3:06 pm
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.

Re: Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 4:54 pm
by CixrTyx
Thanks a ton guys? What about functions?

Re: Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 5:43 pm
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.

Re: Macro help - If Statements and Functions

Posted: Wed Sep 06, 2017 6:34 pm
by aliasmask

Re: Macro help - If Statements and Functions

Posted: Thu Sep 07, 2017 12:43 am
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