RPTools.net

Discussion and Support

Skip to content

It is currently Thu Aug 17, 2017 10:35 am 






Reply to topic  [ 8 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Tue Oct 26, 2010 6:08 am
Posts: 9
 Post subject: if inside if inside if?
PostPosted: Sun Nov 07, 2010 8:59 pm 
Okay, so what I've got here is a little predicament; I'm working on a macro that has a variety of variables. First off, if the token is not "latched", then it latches the token to their target (which is outlined in the properties). Then, if it is latched (which will be on another turn) it asks if the target is still alive. If it is it deals damage. If it is not, it delatched the token from the target.

Up to this point everything is golden, but I need to add another if command asking if it won a strength percentile, and if it did, then the token is thrown from the target. It would ask this after it determined the token's target was still alive.

Here's what I have. Individually they work, but once I get about 3 if's deep it doesn't want to work anymore.

Code:
[if(state.Latch == 0),CODE:
{
    [h:Essence = Essence - (15)]
    [h:bar.Essence = Essence / MaxES]
    <b>[r:token.name]</b> latches on to <b>[r:target]</b>, digging in hard with her teeth and dealing <b>[r:round(Strength*Level/2/4)] damage</b>!
    [h: setState("Latch", 1)]};
     {
     [h:status = input(
     "alive|Yes|Is your target alive?")]
     [h:abort(status)]

          [if(alive=="Yes"),CODE:
          {
          [h:status = input(
          "win|Yes|Did you win your Strength Percentile?")]
          [h:abort(status)]

   [if(win=="Yes"),CODE:
   {
   <b>[r:token.name]</b> continues her hold on <b>[r:target]</b>, dealing <b>[r:round(Strength*Level/2/4)] damage</b>!
   };
   {<b>[r:token.name]</b> is thrown off <b>[r:target]</b>!
   [h: setState("Latch", 0)]
   };]
          };
          {
          <b>[r:token.name]</b> releases her grip on <b>[r:target]</b>!
         [h: setState("Latch", 0)]
          };]
     };]


If you remove the
Code:
   [if(win=="Yes"),CODE:
   {
   <b>[r:token.name]</b> continues her hold on <b>[r:target]</b>, dealing <b>[r:round(Strength*Level/2/4)] damage</b>!
   };
   {<b>[r:token.name]</b> is thrown off <b>[r:target]</b>!
   [h: setState("Latch", 0)]
   };]

and replace it with whatever, it will work. It's that if command that it doesn't like.


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 1001
Location: California
 Post subject: Re: if inside if inside if?
PostPosted: Sun Nov 07, 2010 9:09 pm 
You can only nest 'ifs' 2 deep.

_________________
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."


Top
 Profile  
 
 Offline
Kobold
 
Joined: Tue Oct 26, 2010 6:08 am
Posts: 9
 Post subject: Re: if inside if inside if?
PostPosted: Sun Nov 07, 2010 9:14 pm 
if that's the case, is there any way to work around what I'm trying to do, or is it simply too complicated?


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 1001
Location: California
 Post subject: Re: if inside if inside if?
PostPosted: Sun Nov 07, 2010 9:27 pm 
There probably a couple of ways you could do it. I haven't looked too hard at your code but maybe you could use switch/case for multiple options. That would allow you to pick one of many choices.
You could also daisy chain your if statements one right after another instead of nesting them.
You could also use macro roll option to shoot out to another macro and return with an answer. Here is the wiki for that. http://www.lmwcs.com/rptools/wiki/macro_%28roll_option%29

_________________
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."


Top
 Profile  
 
 Offline
Kobold
 
Joined: Tue Oct 26, 2010 6:08 am
Posts: 9
 Post subject: Re: if inside if inside if?
PostPosted: Sun Nov 07, 2010 9:32 pm 
Yeah that helps. Thanks mfriz!


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7782
Location: Bay Area
 Post subject: Re: if inside if inside if?
PostPosted: Sun Nov 07, 2010 9:55 pm 
[Deleted]
edit: Nevermind, I was being a retard.

Code:
[R, if(state.Latch == 0), CODE: {
   [H:Essence = Essence - 15]
   [H: bar.Essence = Essence / MaxES]
   [R: strformat("<b>%{token.name}</b> latches on to <b>%{target}</b>, digging in hard with her teeth and dealing <b>%d damage</b>!",
      round(Strength * Level /8))
   ]
   [H: state.Latch = 1]
};{
   [H:status = input("alive|1|Target is Alive|CHECK")]
   [H: abort(status)]
   [R, if(alive), CODE: {
      [H: status = input("win|1|You won Strength Challange|CHECK")]
      [H: abort(status)]
      [R, if(win): strformat("<b>%{token.name}</b> continues her hold on <b>%{target}</b>, dealing <b>%s damage</b>!",round(Strength * Level /8));
         strformat("<b>%{token.name}</b> is thrown off <b>%{target}</b>!")]
      [H, if(!win): state.Latch = 0]
   };{
      [R: strformat("<b>%{token.name}</b> releases her grip on <b>%{target}</b>!")]
      [H: state.Latch = 0]
   }]
}]
 

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Tue Oct 26, 2010 6:08 am
Posts: 9
 Post subject: Re: if inside if inside if?
PostPosted: Mon Nov 08, 2010 12:14 am 
My god you are amazing.

Now to pick-apart your macro so I can figure out what you did!

I don't really have a good grasp on commas or exclamation marks (or %'s either, haven't seen those before).


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9315
Location: Netherlands
 Post subject: Re: if inside if inside if?
PostPosted: Mon Nov 08, 2010 2:51 am 
allan wrote:
My god you are amazing.

Now to pick-apart your macro so I can figure out what you did!

I don't really have a good grasp on commas or exclamation marks (or %'s either, haven't seen those before).


the ! is not part of the code.
the strformat AFAIK does two things:
1. it will substitute any string between %{ and } with its corresponding variable so
[damage = 5]
[strformat("hit for %{damage}")]
And you can use erm... operators(?) like %d %s and probably others, though I only use %s (string). which will substitute that operator with anything after the ",". So
[damage=5]
[strformat("hit for %s", damage)]

It took me about a year before I started using these, but its fast and handy.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 8 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 3 users online :: 2 registered, 0 hidden and 1 guest (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: Bing [Bot], Yahoo [Bot] and 1 guest





cron

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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman