michael-buschbeck / mychs-macro-magic

A simple, sane, and friendly little scripting language for your Roll20 macros.
MIT License
1 stars 1 forks source link

Access to strange Midgard attributes for "act of strength" #132

Open phylll opened 3 years ago

phylll commented 3 years ago

I discovered two "attributes" of sorts of Midgard character sheets, @{Yorric MacRathgar|KraftaktW} and @{Yorric MacRathgar|ItemBKraftakt} that I cannot seem to access through MMM, neither as attributes (sender.KraftaktW) nor through the tables (none of the tables available through findattr() seem to fit). They are not skills, nor do they belong to attack, defense, languages, senses or any other table I can see. Do you have a more convenient way than groping in the dark to identify where to find these, or are they not accessible through MMM?

michael-buschbeck commented 3 years ago

Very curious – I'll have to investigate.

From how you're saying you can access these attributes through vanilla Roll20 attribute calls I can't see any reason why they shouldn't work with getattr(). This also doesn't look like it's a table attribute.

Can you find these attributes in the character sheet's "Attributes" tab? (You can see the other non-table attributes there, right?)

phylll commented 3 years ago

No. I can find all the others (Gw, Wk [Willenskraft], AP, LP) in the "Attributes" tab but not these two. So where does the character sheet store the data?

michael-buschbeck commented 2 years ago

Workaround: roll("Finn MacRathgar", "@"&"{KraftaktW}") – with the implied benefit of having the dice engine evaluate the expression stored in the KraftaktW attribute, which is actually something like floor((@{St}+@{ItemBStärke})/10) rather than a direct numeric value.

Still not clear why getattr() isn't able to fetch this attribute (and even ItemBKraftakt, which is completely vanilla as far as I can tell).

phylll commented 2 years ago

The workaround works nicely, AFAIC that's good enough for our rare use of this attribute.

phylll commented 2 years ago

From where I sit, we could close this issue.

michael-buschbeck commented 2 years ago

Just found this in the docs:

Working with Character Sheets The Character Sheets affects the usage of the Attributes object type, because the sheets have the capability of specifying a default value for each attribute on the sheet. However, if the attribute is set to the default value, there is not yet an actual Attribute object created in the game for that Character. We provide a convenience function which hides this complexity from you. You should use this function to get the value of an attribute going forward, especially if you know that a game is using a Character Sheet. getAttrByName(character_id, attribute_name, value_type)

So I'm guessing now that this strange floor((@{St}+@{ItemBStärke})/10)-valued attribute never makes it into the database because the formula is its default value, and clearly the getAttrByName() API function does something magical under the hood not available to normal API scripts to be able to access that default value.

MMM's getattr() currently shares code with setattr() that fetches the attribute object in order to then read or change it. To fix this issue, getattr() would have to fall back to the getAttrByName() API function when no attribute object can be found.