Dwenny/Scripts/Main.gd

45 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-01-17 23:40:36 +01:00
extends Control
@onready var MultiplierLB = $MainMC/VBoxContainer/EnumMC/EnumHB/VBoxContainer/MPLB/MultiplierLB
@onready var DieTypeLB = $MainMC/VBoxContainer/EnumMC/EnumHB/VBoxContainer2/DTTP/DieTypeLB
@onready var DieLB = $MainMC/VBoxContainer/Die/DiceCR/DieLB
var Multiplier : int = 1
var ChosenDie : int = 20
func _ready():
pass
func _process(_delta):
MultiplierLB.text = str(Multiplier)
DieTypeLB.text = str(ChosenDie)
2024-01-17 23:40:36 +01:00
func Die():
var result = ChosenDie * Multiplier
return randi() % result + 1
2024-01-17 23:40:36 +01:00
var dice_values = [4, 6, 8, 10, 12, 20]
func _on_updt_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if ChosenDie < 20:
ChosenDie = dice_values[dice_values.find(ChosenDie)+1]
2024-01-17 23:40:36 +01:00
func _on_dwdt_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if ChosenDie > 4:
ChosenDie = dice_values[dice_values.find(ChosenDie)-1]
2024-01-17 23:40:36 +01:00
func _on_mpup_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if Multiplier < 10:
Multiplier += 1
2024-01-17 23:40:36 +01:00
func _on_mpdw_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if Multiplier > 1:
Multiplier -= 1
func _on_roll_rect_gui_input(event:InputEvent):
if event is InputEventScreenTouch and event.is_pressed():
Die();
DieLB.text = str(Die());