Advertisement
Guest User

Untitled

a guest
Dec 14th, 2024
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Control
  2.  
  3.  
  4. signal bar_filled
  5.  
  6. var disabled := false
  7.  
  8. @onready var texture_progress_bar := %TextureProgressBar
  9.  
  10.  
  11. func _ready() -> void:
  12.     hide()
  13.     if Input.is_action_pressed("reset"):
  14.         disabled = true
  15.  
  16.  
  17. func _unhandled_input(event: InputEvent) -> void:
  18.     if disabled:
  19.         if event.is_action_released("reset"):
  20.             disabled = false
  21.     elif event.is_action("reset"):
  22.         texture_progress_bar.value += texture_progress_bar.step * 3.0
  23.  
  24.  
  25. func _physics_process(delta: float) -> void:
  26.     if disabled:
  27.         return
  28.    
  29.     if Input.is_action_pressed("reset"):
  30.         show()
  31.     elif texture_progress_bar.value > 0.0:
  32.         texture_progress_bar.value -= texture_progress_bar.step * delta * 100.0
  33.     else:
  34.         hide()
  35.  
  36.  
  37. func _on_texture_progress_bar_value_changed(value: float) -> void:
  38.     if value == 100.0:
  39.         bar_filled.emit()
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement