Skip to content

ResourceMeter ​

class in OpalScript

A named bounded numeric resource with exact spending and committed change results.

Properties ​

MemberDescription
ResourceMeter.NameRead-only runtime value. Use component methods to change state.
ResourceMeter.MinRead-only runtime value. Use component methods to change state.
ResourceMeter.MaxRead-only runtime value. Use component methods to change state.
ResourceMeter.InitialValueRead-only runtime value. Use component methods to change state.
ResourceMeter.ValueRead-only runtime value. Use component methods to change state.
ResourceMeter.FractionRead-only runtime value. Use component methods to change state.

Methods ​

MemberDescription
ResourceMeter.SetSet an exact value within the authored range, or return a refusal without changing it.
ResourceMeter.AddApply an exact signed amount, refusing changes outside the authored range.
ResourceMeter.SpendSubtract a finite nonnegative cost only when the entire cost is available.
ResourceMeter.RefillSet the resource to its authored maximum and return the committed change.
ResourceMeter.CanSpendTrue when a finite nonnegative cost can be spent in full without crossing the minimum.
ResourceMeter.IsEmptyTrue when the current value equals a valid authored minimum.
ResourceMeter.IsFullTrue when the current value equals a valid authored maximum.

Events ​

MemberDescription
ResourceMeter.changedEmitted after an accepted command commits a new value.
ResourceMeter.emptyEmitted when an accepted change reaches the minimum from above.
ResourceMeter.fullEmitted when an accepted change reaches the maximum from below.

See also ​