A key attribute's value shown in a subtitle of a note

Hello,

I would like to show the aforementioned value as a subtitle of a note (ideally with some added text but this I should be able to handle). I couldn’t get it to work in a prototype I am using for the notes so I have tried with an Action of an adornment. The attribute is a number type. Since I don’t seem to be able to set no default value, it is set to zero when I create a note.

I have managed to make it work so that the value is shown when I create the note (thus, it shows zero). However, it doesn’t update the subtitle when I change the value of the aforementioned attribute (here, the attribute is “DamagePerSecond” and the value I change it to is “20”).


This is the Action code for the green adornment I created the “untitled” note on. You can see the value “0” shown in the subtitle.

Screenshot 2023-04-06 at 09.54.43

This is the attribute value I have changed. However, the note still shows “0” in the subtitle.

My questions are as follows:

  1. How can I make Tinderbox to automatically update the shown value in subtitles whenever I change it (the value, not the subtitle)?
  2. How can I set it in a prototype itself?

Thank you for any help you can provide.

Kind regards,
Mateusz

Ah, you’re using OnAdd, which fires once when a note is added to the container. Move the code:

$Subtitle=$DamagePerSecond;

To a rule. Now, whenever $DamagePerSecond changes the next rule run will update the note. In small/medium documents this will be near-instant. In a very big map (or with big/complex) rules there may be a small delay. In the latter case, in the tab bar above the view pane, click the title of the current tab and it will cause the view to refresh.

A quick side note re subtitles and Quickstamp or Inspector edits. You can’t set a value this way as what you type in the box on screen is a literal value. If you type $MyNumber, that is literally what the subtitle shows. To get a dynamic value you need to use actions code (rule/edict/agent action) to change the value. Indeed, if you were to like at the Subtitle Inspector between the running of the actions you would not see $MyNumber but an actual number, i.e. the value of $MyNumber last time the action code ran.

1 Like

Thank you kindly, Mark.
It did work when I put it into the prototype’s rule.
Funny enough, firstly I put it into the rule of the adornment and it showed the zero value under the adornment’s title - I giggled a bit.

A quick side note re subtitles and Quickstamp or Inspector edits. You can’t set a value this way as what you type in the box on screen is a literal value. If you type $MyNumber , that is literally what the subtitle shows. To get a dynamic value you need to use actions code (rule/edict/agent action) to change the value. Indeed, if you were to like at the Subtitle Inspector between the running of the actions you would not see $MyNumber but an actual number, i.e. the value of $MyNumber last time the action code ran.

That was actually the first thing I tried: I placed $DamagePerSecond in the subtitle of the prototype with all kinds of quotation marks and brackets, haha.

I am going to have a read about the difference between rules, edicts and agent actions to better know my options.

Thanks again,
Mateusz

1 Like

No problem, glad it’s working.

Think of agent action as a rule run on the child aliases in the agent - i.e. the notes its query matches. The agent itself has its own rule and edict, just as a normal note does. Agent actions and rules run on continuous cycle, noting that all have to run per cycle. Plus aliases (e.g in agent) also run their rules/edicts as well. So the rule a note with a rule that is aliased in 5 agents is run six times per cycle. This really doesn’t matter when first building out. But, I mention it so you’ve an inkling of where to look if things slow down as your documents grow.

Edicts are essentially rules that run on doc open and then c. once an hour until/unless various things trigger it early. One such is editing Displayed Attributes, which cause that note’s Edict to run (to reflect the any effects of the changed attribute(s) values).

Don’t worry unduly about rule vs. edicts at outset; rules are just fine and immediate. Just be aware that if you project grows, edicts may have a pay-off for you.