Nope that syntax doesn’t show when I start typing as far as the button group/get button part is concerned. Still seems to be no way to reference the saved group.
Think I’ve worked it out but can’t try it for a couple of days. Will update if necessary.
Nope not working. Tried preloading the saved button group resource but when I try to iterate through it, it reads as empty even though all the buttons in the editor are assigned to the saved group in the inspector.
Was an issue with get button somehow. I can now iterate through the group. Considering a constant check of what’s toggled by using _process(delta) but it seems a little too often. So rather than on ready for initial toggle and then each button has a function, I can cycle through the group constantly, get a match on button name and trigger the relevant texture change.
That would serve a purpose if having extra lines of code costed someting, and running cpu cycles did not, but it’s the other way around. Up to you, but I would add the functions and saved the processor time.
I’ll probably tinker with both options for a while. As far as setting up persistence I’ll probably use use dictionaries for the textures and use the buttons to set a global variable to the key of the respective texture. That all comes later though as the 3 textures I have currently were just to help me sort the basics of the syntax. I’m going to have all 16 of the textures as an atlas texture. Implementing the atlas and at least the dictionary for these textures is the current step. Then also tying in the difficulty level of each option and then a randomise function.
Got it working. Next will be adding a random selection button.
extends Control
var enviroatlas = preload("res://EnviroAtlas.tres")
@export var enviro = preload("res://enviro.tres")
var envdict = {"Aeternus":[0, 0], "Diamond":[300, 0], "Freedom":[600, 0], "Insula":[900, 0],
"Magmaria":[0, 200], "Megalopolis":[300, 200], "Pike":[600, 200], "Rook":[900, 200],
"Silver":[0, 400], "Block":[300, 400], "Wasteland":[600, 400], "Discord":[900, 400],
"Atlantis":[0, 600], "ZhuLong":[300, 600], "Anubis":[600, 600], "Wagner":[900, 600]}
func _ready() -> void:
for n in enviro.get_buttons():
n.toggled.connect(_enviropressed)
enviroatlas.region = Rect2(envdict[enviro.get_pressed_button().name][0], envdict[enviro.get_pressed_button().name][1], 300, 200)
$choice.texture = enviroatlas
func _enviropressed(toggled_on: bool) -> void:
if toggled_on:
enviroatlas.region = Rect2(envdict[enviro.get_pressed_button().name][0], envdict[enviro.get_pressed_button().name][1], 300, 200)
$choice.texture = enviroatlas
func _on_button_17_pressed() -> void:
get_tree().change_scene_to_file.call_deferred("res://Mainmenu.tscn")