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

22 lines
391 B
GDScript3
Raw Normal View History

2022-11-20 13:02:47 +00:00
extends Button
onready var dice_label_one = get_node("../DiceLabelOne")
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)