mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
Cleanup and document Counter
This commit is contained in:
parent
85d487a56c
commit
97b415fabd
1 changed files with 6 additions and 4 deletions
|
@ -1,18 +1,17 @@
|
||||||
extends Node
|
extends Node
|
||||||
class_name Counter
|
class_name Counter
|
||||||
|
|
||||||
|
## Counts up or down from a starting value.
|
||||||
|
|
||||||
|
|
||||||
signal changed(old: int, new: int)
|
signal changed(old: int, new: int)
|
||||||
|
|
||||||
|
|
||||||
@export var starting_value: int
|
@export var starting_value: int
|
||||||
|
|
||||||
var value: int
|
var value: int = 0
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
value = starting_value
|
|
||||||
|
|
||||||
func change(amount: int):
|
func change(amount: int):
|
||||||
var old = value
|
var old = value
|
||||||
value = amount
|
value = amount
|
||||||
|
@ -27,3 +26,6 @@ func decrease(amount: int = 1):
|
||||||
if amount < 0:
|
if amount < 0:
|
||||||
Log.w(self, "Decreasing a counter by a negative value.")
|
Log.w(self, "Decreasing a counter by a negative value.")
|
||||||
change(value - amount)
|
change(value - amount)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
value = starting_value
|
||||||
|
|
Loading…
Reference in a new issue