API for Stats module

Joshua Devine 5 months ago in Stats updated by Marti (Lead Developer) 5 months ago 1

Hi there,

Specific need: How can I set a status effect from a script using the Stats API?

I have been trying dozens of different things all day. Could be I am missing something obvious... in any case, I am resorting to the support forum. I did figure out how to set an attribute from a custom object, but that was not so easy and did take longer than it should have.

Generally, really loving Game Creator. Thanks for the great tools.
Are you planning to document / expose the stats API any further?

Example of one attempt below. Bold piece gives expected result. Italics piece throws errors because Stats not finding the status effect.

private void CalculateAttributeEffects(AttrAsset attr, float combatValue)
   if (stats.GetAttrValue(attr.GetNodeTitle()) - Mathf.Abs(combatValue) < 0)

if (attr.GetNodeTitle() == "endurance")

         StatusEffectAsset se = new StatusEffectAsset();
         se.statusEffect.uniqueName = "stagger10";



Unity version:
Game Creator version:

The GetNodeTitle does not return the id of the attribute. Instead, you need to query for the member called "uniqueName". Like you did with the status effects.