RPTools.net

Discussion and Support

Skip to content

It is currently Wed Oct 18, 2017 7:04 pm 






Reply to topic  [ 7 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Cave Troll
 
Joined: Thu Aug 26, 2010 1:54 pm
Posts: 27
 Post subject: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 10:08 am 
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?


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Aug 31, 2011 8:49 pm
Posts: 495
Location: Somewhere between Heaven and Hell
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 11:13 am 
Code:
[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:
[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

Image


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3728
Location: MD
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 2:06 pm 
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."


Top
 Profile  
 
 Offline
Cave Troll
 
Joined: Thu Aug 26, 2010 1:54 pm
Posts: 27
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 3:54 pm 
Thanks a ton guys? What about functions?


Top
 Profile  
 
 Offline
Cave Troll
 
Joined: Thu Aug 26, 2010 1:54 pm
Posts: 27
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 4:43 pm 
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.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7884
Location: Bay Area
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 5:34 pm 
There's an example here: viewtopic.php?f=3&t=27300#p267480 of that.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3728
Location: MD
 Post subject: Re: Macro help - If Statements and Functions
PostPosted: Wed Sep 06, 2017 11:43 pm 
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: viewtopic.php?f=85&t=25490

And this one hasn't been released yet, but looks very promising and simple to use: 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."


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 7 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 2 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman