Quit-Rolling-Around-gmtk-ja.../UI/Dice.gd

32 lines
592 B
GDScript3
Raw Normal View History

2022-07-16 21:33:47 +01:00
tool
extends Control
const dice_image_string = "res://Assets/Dice/Dice%s.png"
const selected_shader = preload("res://UI/RainbowOutline.tres")
2022-07-16 21:33:47 +01:00
export (int, 0, 6) var dice_value : int = 0
export var selected : bool setget _set_selected
func _set_selected(new_value):
selected = new_value
if selected:
self.material = selected_shader
else:
self.material = null
2022-07-16 21:33:47 +01:00
func _physics_process(delta):
self.texture = load(dice_image_string % dice_value)
2022-07-16 21:33:47 +01:00
func _ready():
randomize()
if dice_value == 0:
self.dice_value = int(round(rand_range(0.5, 6.49999999)))
_physics_process(0)