Godot Version
Godot 4
Question
Hi everyone,
I am making a custom DND character sheet in Godot basically for coding practice, as I am pretty new to it. As of right now, I have functions determining ability mods based on changing values from a score spinbox, and a function to add a proficiency bonus with a signal from a button toggle. Right now, the setup looks like this:
## Parent container for Stats and Skills, one example stat
func _ready() -> void:
$Stats.supplies_mod_changed.connect(Skills.supplies_skill_mod)
##Stats, set modifier
func _on_supplies_score_value_changed():
var supplies_mod = (new_value - 10) / 2
var prof_bonus = %ProfBonus.value ## int = 2
$SuppliesMdd.value = supplies_mod
supplies_mod_changed.emit(supplies_mod)
##Skills
## Applies supplies_mod to supplies skills
func supplies_skill_mod(supplies_mod):
var supplies_skill = get_tree().get_nodes_in_group("SupSkill")
for skill in get_children():
for member in supplies_skill:
for mod in member.get_children():
if mod is SpinBox:
mod.value = supplies_mod
##Applies prof_bonus based on toggle
func proficiency(is_toggled_on: bool, button_reference: Button):
var prof_bonus = %ProfBonus.value
var skill = button_reference.get_parent()
for mod in skill.get_children():
if mod is SpinBox:
if is_toggled_on:
mod.value += prof_bonus
else:
mod.value -= prof_bonus
The problem I’m having is that if the button is already toggled, and then I adjust the score, supplies_mod doesn’t apply prof_bonus.
I think the fix I can do for this is to send a boolean argument to on_supplies_score_value_changed to check if the button is toggled, but I am pretty lost on how I would go about implementing that. I know I would need to send the argument to all of the nodes in the group, but do I check for that argument in the proficiency function and then send it as a separate signal? Do I even need the proficiency function?
Any and all help on this would be greatly appreciated, I am happy to clarify things if need be - I hope I have explained this properly.