a game about throwing hammers made for the github game off
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extends HBoxContainer
class_name CaretOptionButton

signal changed(current_option: int)

@onready var button: Button = $button as Button
@export var options: PackedStringArray = []
@export var current_option: int = 0:
  set(val):
    current_option = wrapi(val, 0, len(options))
    if not button: return
    button.text = options[current_option]
    changed.emit(current_option)

func _ready() -> void:
  current_option = current_option

func sub() -> void:
  current_option -= 1

func add() -> void:
  current_option += 1