GM only macro output

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

GM only macro output

Post by qcgreywolf »

Gentlemen!

I am having a difficult time getting macro output to be displayed only to GM's. I can get simple rolls to whisper to a specific person (getting around the 'only GM' issue), but I cannot get items inside a if(): block to do it.

Here is sample code;
Spoiler
[h: abort(isGM())]

[h: tempState = 0]
[h: negCon = 0]
[h: massiveDMG = 0]
[h: acidDamage = 0]
[h: coldDamage = 0]
[h: electricityDamage = 0]
[h: fireDamage = 0]
[h: damage = 0]

[h:status=input(
"physicalDamage|0|Amount of damage",
"AD|0|Acid based damage",
"CD|0|Cold based damage",
"ED|0|Electricity based damage",
"FD|0|Fire based damage")]
[h:abort(status)]

<!-- Take care of the elemental damages -->


[h: oldAcidProtection = AcidProtection]

[h, if(AD == 0), CODE:
{

};{
[if(AD <= AcidProtection), CODE:
{
[h: AcidProtection = AcidProtection - AD]
Takes [AD] Acid damage, losing [AD] Acid Protection. You now have [AcidProtection] Acid Protection with [AcidResistance] Resistance.<br>
[h: AD = 0]
};{
[h: overdamage = 0]
[h: overdamage = AD - AcidProtection]
[h: AcidProtection = 0]
[h: setState("Protection from Acid",0)]
Takes [AD] damage, losing [oldAcidProtection] Acid Protection. You now have 0 Acid Protection with [AcidResistance] Resistance.<br>
[h: overdamage = if(AcidResistance > 0, overdamage - AcidResistance, overdamage)]
[h: overdamage = if(overdamage < 0, 0, overdamage)]
[h: acidDamage = overdamage]
}]
}]


[h: oldColdProtection = ColdProtection]

[h, if(CD == 0), CODE:
{

};{
[if(CD <= ColdProtection), CODE:
{
[h: ColdProtection = ColdProtection - CD]
Takes [CD] Cold damage, losing [CD] Cold Protection. You now have [ColdProtection] Cold Protection with [ColdResistance] Resistance.<br>
[h: CD = 0]
};{
[h: overdamage = 0]
[h: overdamage = CD - ColdProtection]
[h: ColdProtection = 0]
[h: setState("Protection from Cold",0)]
Takes [CD] damage, losing [oldColdProtection] Cold Protection. You now have 0 Cold Protection with [ColdResistance] Resistance.<br>
[h: overdamage = if(ColdResistance > 0, overdamage - ColdResistance, overdamage)]
[h: overdamage = if(overdamage < 0, 0, overdamage)]
[h: coldDamage = overdamage]
}]
}]


[h: oldElectricityProtection = ElectricityProtection]

[h, if(ED == 0), CODE:
{

};{
[if(ED <= ElectricityProtection), CODE:
{
[h: ElectricityProtection = ElectricityProtection - ED]
Takes [ED] Electricity damage, losing [ED] Electricity Protection. You now have [ElectricityProtection] Electricity Protection with [ElectricityResistance] Resistance.<br>
[h: ED = 0]
};{
[h: overdamage = 0]
[h: overdamage = ED - ElectricityProtection]
[h: ElectricityProtection = 0]
[h: setState("Protection from Electricity",0)]
Takes [ED] damage, losing [oldElectricityProtection] Electricity Protection. You now have 0 Electricity Protection with [ElectricityResistance] Resistance.<br>
[h: overdamage = if(ElectricityResistance > 0, overdamage - ElectricityResistance, overdamage)]
[h: overdamage = if(overdamage < 0, 0, overdamage)]
[h: electricityDamage = overdamage]
}]
}]

[h: oldFireProtection = FireProtection]

[h, if(FD == 0), CODE:
{

};{
[if(FD <= FireProtection), CODE:
{
[h: FireProtection = FireProtection - FD]
Takes [FD] Fire damage, losing [FD] Fire Protection. You now have [FireProtection] Fire Protection with [FireResistance] Resistance.<br>
[h: FD = 0]
};{
[h: overdamage = 0]
[h: overdamage = FD - FireProtection]
[h: FireProtection = 0]
[h: setState("Protection from Fire",0)]
Takes [FD] damage, losing [oldFireProtection] Fire Protection. You now have 0 Fire Protection with [FireResistance] Resistance.<br>
[h: overdamage = if(FireResistance > 0, overdamage - FireResistance, overdamage)]
[h: overdamage = if(overdamage < 0, 0, overdamage)]
[h: fireDamage = overdamage]
}]
}]



<!-- Get damage ammount and check for massive damage -->

[w("meera"): damage = acidDamage + coldDamage + electricityDamage + fireDamage + physicalDamage]
I want the "Takes [FD] Fire damage, losing [FD] Fire Protection. You now have [FireProtection] Fire Protection with [FireResistance] Resistance." text to ONLY go to GM's. If I change the [h, with anything else, all my players can see all the output ([gmtt, [st, etc...)

Is there something I am just overlooking?

EDIT: There very last line works as intended.

User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Re: GM only macro output

Post by Irrlicht »

Try "[g, r:", and see how it behaves, if you haven't tried already.
Also, as far as I know, all the code in which it is nested, must not have "[h:" to show properly.

I mean:

Code: Select all

[r, if(Var == 1), code:
{
[g, r: Var]
}]
If that "[r:" was a "[h:", it wouldn't display.

Also, you can try this:

Code: Select all

<!-- This one is just for better code formatting: if you set the starting IF to "FD != 0" you don't need to include the case for when it is == 0; when it is, it'll just do nothing. -->
[h, if(FD != 0), CODE:
{
   [if(FD <= FireProtection), CODE:
   {
      [h: FireProtection = FireProtection - FD]
      Takes [FD] Fire damage, losing [FD] Fire Protection. You now have [FireProtection] Fire Protection with [FireResistance] Resistance.<br>
      [h: FD = 0]
   };{
      [h: overdamage = 0]
      [h: overdamage = FD - FireProtection]
      [h: FireProtection = 0]
      [h: setState("Protection from Fire",0)]
<!-- Storing the string inside a variable. -->
      [h: Text = "Takes %{FD} damage, losing %{oldFireProtection} Fire Protection. You now have 0 Fire Protection with %{FireResistance} Resistance.<br>"]
      [h: overdamage = if(FireResistance > 0, overdamage - FireResistance, overdamage)]
      [h: overdamage = if(overdamage < 0, 0, overdamage)]
      [h: fireDamage = overdamage]
   }]
}]

<!-- Retrieving the variable when you need, with the visibility you want. -->
[g, r: Text]
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

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

Re: GM only macro output

Post by qcgreywolf »

Thanks for the reply.

I didn't know about the

Code: Select all

if(var != 0)code:
option. That is handy, it saves a step and removes yet another chance at forgetting a bracket somewhere.

The

Code: Select all

<!-- Storing the string inside a variable. -->
      [h: Text = "Takes %{FD} damage, losing %{oldFireProtection} Fire Protection. You now have 0 Fire Protection with %{FireResistance} Resistance.<br>"]
sadly outputs the line of text exactly as written, it does not substitute the data in the %{} braces. I did do a cut/paste from here, did we miss something?

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

Re: GM only macro output

Post by wolph42 »

sadly outputs the line of text exactly as written, it does not substitute the data in the %{} braces. I did do a cut/paste from here, did we miss something?
yup: Wiki: strformat()

o and just so you know

0 == FALSE
(NOT 0, but must be a number) == TRUE
! == NOT

so

if(var != 0) can be written as if(var)
and
if(var == 0) can be written as if(!var)

might be handy. Especially if you have variables like hasSkill then you get if(hasSkill):.... which reads much more pleasantly.

User avatar
Irrlicht
Dragon
Posts: 426
Joined: Mon Feb 09, 2009 10:53 am

Re: GM only macro output

Post by Irrlicht »

Yes, pardon, I forgot to put the string into strformat().

EDIT
Alternatively, without strformat():

Code: Select all

      [h: Text = "Takes " + FD + " damage, losing " + oldFireProtection + " Fire Protection. You now have 0 Fire Protection with " + FireResistance + " Resistance.<br>"]
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."

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

Re: GM only macro output

Post by qcgreywolf »

Wolph42:

That is helpful. Anything that makes reading my own code easier on the eyes and my memory is very helpful.

Irrlicht:

Not a problem, you got me moving down the right path, thanks for the correction though!

I am rewriting my entire framework from the ground up using all the tricks I have learned over the last 6 months. Pain is the operative word of the week.

The decision came about after my players started having strange stack overflow problems and larger and larger stack sizes to compensate. Since my macros have been growing steadily, I figured it was time to go back and do some heavy splitting up and optimizing of the code.

Question #1:

My tokens have multiple attacks saved as properties such as;

Code: Select all

 
[AttackModifier1]
[CriticalThreatModifier1]
[DamageDice1]
...etc} 
Can I call a generic macro with a UDF

Code: Select all

 
[h: [GatherUpSomeTokenPropterties(1)]
[h: pileOfProperties = macro.return] 
and have that called macro gather

Code: Select all

[h: attackModifier = AttackModifier%{arg(0)}]
[h: criticalThreatModifier = CriticalThreatModifier%{arg(0)}] 
[h: propertyPile = listAppend(propertyPile, attackModifier)]
[h: propertyPile = listAppend(propertyPile, criticalThreatModifier)]
[macro.return = propertyPile]
and pass those back to the calling macro? I don't know the term for that, dynamic variable, maybe?

(Side note: I do lots of arg() passing in my existing macros, but I need whole if() trees for each possible attack. It would be really slick if I could have one super generic macro that I can call to get properties. )


Question #2:

The root cause has me stumped, however;

Server is running on a windows 8.1 pc with Java 7, 2048 Max, 1024 min and stack size of 4.

I run a macbook pro retina 15' with 16gb of ram. I am running Java 8 (just updated to Yosemite). My launcher vars are 2048 max, 1024 min, and 3 stack size. (never seen a single stack overflow)

My GF has a macbook pro retina 13' with 8gb of ram, running Java 8 as well. 2048 Max, 1024 Min and she needs a stack size of 7 or she gets stack overflows.

I am not positive, but my other players all have different stack sizes as well.

Can you think of a reason the 2 very similar MacBooks with Java 8 need such radically different stack sizes? Logic tells me that if every single macro runs great on my PC with a stack of 3, other peoples PC's should be capable of the same...

Post Reply

Return to “Macros”