education-apps/digibord_tools/godot/Tools/Dice.gd

22 lines
392 B
GDScript3
Raw Normal View History

2022-11-20 13:02:47 +00:00
extends Button
2023-03-30 07:30:04 +00:00
@onready var dice_label_one = get_node("../DiceLabelOne")
2022-11-20 13:02:47 +00:00
var dice_print_value = 0
var rng = RandomNumberGenerator.new()
func _ready():
pass # Replace with function body.
func roll_die(dice, sides):
while dice >= 1:
dice_print_value = rng.randi_range(1, sides)
dice -= 1
func _on_ButtonRoll_pressed():
roll_die(1, 6)
dice_label_one.text = str(dice_print_value)