ResourceMeter
class in OpalScript
A named bounded numeric resource with exact spending and committed change results.
Properties
| Member | Description |
|---|---|
| ResourceMeter.Name | Read-only runtime value. Use component methods to change state. |
| ResourceMeter.Min | Read-only runtime value. Use component methods to change state. |
| ResourceMeter.Max | Read-only runtime value. Use component methods to change state. |
| ResourceMeter.InitialValue | Read-only runtime value. Use component methods to change state. |
| ResourceMeter.Value | Read-only runtime value. Use component methods to change state. |
| ResourceMeter.Fraction | Read-only runtime value. Use component methods to change state. |
Methods
| Member | Description |
|---|---|
| ResourceMeter.Set | Set an exact value within the authored range, or return a refusal without changing it. |
| ResourceMeter.Add | Apply an exact signed amount, refusing changes outside the authored range. |
| ResourceMeter.Spend | Subtract a finite nonnegative cost only when the entire cost is available. |
| ResourceMeter.Refill | Set the resource to its authored maximum and return the committed change. |
| ResourceMeter.CanSpend | True when a finite nonnegative cost can be spent in full without crossing the minimum. |
| ResourceMeter.IsEmpty | True when the current value equals a valid authored minimum. |
| ResourceMeter.IsFull | True when the current value equals a valid authored maximum. |
Events
| Member | Description |
|---|---|
| ResourceMeter.changed | Emitted after an accepted command commits a new value. |
| ResourceMeter.empty | Emitted when an accepted change reaches the minimum from above. |
| ResourceMeter.full | Emitted when an accepted change reaches the maximum from below. |