Need a fresh eye

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
qcgreywolf
Cave Troll
Posts: 43
Joined: Mon Dec 09, 2013 10:23 pm

Need a fresh eye

Post by qcgreywolf »

For the life of me I cannot see a problem with this, so I need a quick second look at the code. If it looks perfectly good to you guys too, that means I got SOMETHING somewhere else in my code going funky.

Calling function code snippet:

Code: Select all

<!-- Where criticalHit1 can be 0, 1 or 20 -->
<!-- Where DamageDice1 is the first damage die in the first attack(with dmg modifier) -->
<!-- Where CriticalType1 is the critical multiplier of the attack -->

[h, if(criticalHit1 == 1 || criticalHit1 == 20), CODE:
  {
    [h: critPass = listGet(DamageDice1, 0)]
    [h: critPass = listAppend(critPass, listGet(CriticalType1, 1)]
    [h: critPassJ = json.fromList(critPass)]
    [h, MACRO("criticalMulti@Lib:Lib") : critPassJ]
    [h: critDamage1 = macro.return + damage1a]
    [h: toHitRoll1con = 1d20]
    [h: toHit1con = toHitRoll1con + DefaultAttackModifier1 + TempAttackModifier]
  };{}]

Called function code snippet:

Code: Select all

[h: attackPile1 = macro.args]
[h: attackPile = json.toList(attackPile1)]

[h: totalDamage = 0]
[h: critMulti = listGet(attackPile, 1)]
[h: damageDie = listGet(attackPile, 0)]


[h, switch(critMulti), code:
case "2": {

[h: totalDamage = eval(damageDie)]

};
case "3": {

[h: totalDamage = eval(damageDie) + eval(damageDie)]

};
case "4": {

[h: totalDamage = eval(damageDie) + eval(damageDie) + eval(damageDie)]

};
case "5": {

[h: totalDamage = eval(damageDie) + eval(damageDie) + eval(damageDie) + eval(damageDie)]

};
default: {


}]




[macro.return=totalDamage]

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Need a fresh eye

Post by wolph42 »

whats the problem?

error? does not run? does not do what you expect?

if its an error, pls copy paste the error log here (not the one in the chat but the real one. See debug article in sig. for more info).

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

Re: Need a fresh eye

Post by aliasmask »

Nothing seems wrong with the syntax and since you didn't specify the error you're getting there's not much else I can do. I suggest using some of the debug methods on the forums to pinpoint the exact line of the error. The most simplistic method is to put abort(0) in the code until you find which line as a problem, then you can focus on that. You can also set up a watch or pause in the middle of the code see watch variable values. I have some code for that here: http://forums.rptools.net/viewtopic.php?f=20&t=24704

qcgreywolf
Cave Troll
Posts: 43
Joined: Mon Dec 09, 2013 10:23 pm

Re: Need a fresh eye

Post by qcgreywolf »

I found it about 5 minutes after posting this, sorry guys!

I was missing a ")" in the

Code: Select all

[h: critPass = listAppend(critPass, listGet(CriticalType1, 1)]
Coding for hours on end blinds me to the stupid mistakes sometimes, sorry for the false alarm!

I am recoding my groups attack macro to call on a Lib:Token for the individual components of the macro after a couple of our members started to get the dreaded Stack Overflow. I guess 28 pages of clump-o-code is a little much for older laptops :)

Frameworking is hard work...

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

Re: Need a fresh eye

Post by aliasmask »

I do that all the time with ) and ] and sometimes ; I should have seen that though :(

qcgreywolf
Cave Troll
Posts: 43
Joined: Mon Dec 09, 2013 10:23 pm

Re: Need a fresh eye

Post by qcgreywolf »

No worries! Just knowing that there are people still willing to take a quick look at the forums makes me happy.
I've come quite a ways in the last few months of messing with the innards of Maptools, and I am starting to get to the tough stuff now.

(Darn you JSON, DARN YOU!)

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: Need a fresh eye

Post by Bone White »

Always use a text program to count your syntax characters, as long as you don't use an uneven amount in comments or strings, the pairs of each brackets should count to the same value. This would've easily shown you that you were missing a right bracket.

Post Reply

Return to “Macros”