switch statement stops working

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
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

switch statement stops working

Post by xavram »

So I'm going along with my project and suddenly, a macro I haven't modified stops working. Through broadcast statments, I find out it something in this block...

Code: Select all

[h : switch(side), code : 
		case "Front Side" :
		{
			[h : damageOrder = "Armor_Front_M,Armor_Front_P,Weapons/Front,Cabin,Weapons/Back,Armor_Back_P"]
		};
		case "Back Side" :
		{
			[h : damageOrder = "Armor_Back_M,Armor_Back_P,Weapons/Back,Cabin,Weapons/Front,Armor_Front_P"]
		};
		case "Left Side" :
		{
			[h : damageOrder = "LeftEWPCheck,Armor_Left_M,Armor_Left_P,Weapons/Left,Cabin,Weapons/Right,Armor_Right_P"]
		};
		case "Right Side" :
		{
			[h : damageOrder = "RightEWPCheck,Armor_Right_M,Armor_Right_P,Weapons/Right,Cabin,Weapons/Left,Armor_Left_P"]
		};
		case "Top Side" :
		{
			[h : damageOrder = "Armor_Top_M,Armor_Top_P,Weapons/Top,Cabin,Weapons/Under,Armor_Under_P"]
		};
		case "Under Side" :
		{
			[h : damageOrder = "Armor_Under_M,Armor_Under_P,Weapons/Under,Cabin,Weapons/Top,Armor_Top_P"]
		}
	]
Error is cryptic...
Error in body of roll.       Statement options (if any): h       Statement Body (first 200 characters): switch(side), code : case "Front Side" : { [h : damageOrder = "Armor_Front_M,Armor_Front_P,Weapons/Front,Cabin,Weapons/Back,Armor_Back_P"] }; case "Back Side" : { [h : damageOrder =

But normally, that 'first 200 characters" message is usually because I have too many "codes" in each other. In this case though, nothing has changed and this switch statement is just inside one other switch statement. Like it always has been and its been working fine.

Cannot figure this out, so I try replacing the switch statement with...

Code: Select all

[h, if(side == "Front Side") : damageOrder = "Armor_Front_M,Armor_Front_P,Weapons/Front,Cabin,Weapons/Back,Armor_Back_P"]
[h, if(side == "Back Side") : damageOrder = "Armor_Back_M,Armor_Back_P,Weapons/Back,Cabin,Weapons/Front,Armor_Front_P"]
[h, if(side == "Left Side") :damageOrder = "LeftEWPCheck,Armor_Left_M,Armor_Left_P,Weapons/Left,Cabin,Weapons/Right,Armor_Right_P"]
[h, if(side == "Right Side") :damageOrder = "RightEWPCheck,Armor_Right_M,Armor_Right_P,Weapons/Right,Cabin,Weapons/Left,Armor_Left_P"]
[h, if(side == "Top Side") :damageOrder = "Armor_Top_M,Armor_Top_P,Weapons/Top,Cabin,Weapons/Under,Armor_Under_P"]
[h, if(side == "Under Side") :damageOrder = "Armor_Under_M,Armor_Under_P,Weapons/Under,Cabin,Weapons/Top,Armor_Top_P"]
Lol and behold, that works. But why, when the previous code has been working just fine.

The only thing I can think of is that as I've worked on other macros, I've hit some kind of "universal" limit to the number of switch/code statements I can have? Is there anything like that?

Puzzled and frustrated...

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: switch statement stops working

Post by xavram »

turned on logging, don't think it really helps, here's the error line in the logs.

2017-03-03 14:41:58,971 [client.MapToolLineParser:1280] DEBUG - net.rptools.parser.ParserException: <br>   Error in body of roll.<br>      <u>Statement options (if any)</u>: h <br>      <u>Statement Body (first 200 characters)</u>: switch(side), code :
case "Front Side" :
{
[h : damageOrder = "Armor_Front_M,Armor_Front_P,Weapons/Front,Cabin,Weapons/Back,Armor_Back_P"]
};
case "Back Side" :
{
[h : damage

As near as I can tell, this is just the first 200 lines of that switch statement. I know that the problem is there...but believe me, this wasn't a problem yesterday or the day before or...you get it. This was all working fine, until today.

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

Re: switch statement stops working

Post by Full Bleed »

xavram wrote:As near as I can tell, this is just the first 200 lines of that switch statement. I know that the problem is there...but believe me, this wasn't a problem yesterday or the day before or...you get it. This was all working fine, until today.
I kinda don't believe you...

Code: Select all

[h : switch(side), code :
should be

Code: Select all

[h, switch(side), code :
And I doubt it changed itself. ;)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: switch statement stops working

Post by xavram »

Sigh, I'm calling "gremlins" on that one...why in the world would I have switched that out???

Thanks though FB...I obviously was looking for something "bigger" and just didn't even see that obvious error.

Post Reply

Return to “Macros”