My game has many button devices that I need to enable and disable, and I don’t want to manually assign them to an array as that hurts my soul. I am trying to get all the buttons in my level with tag Button and then either disable or enable all of these buttons. Here is my code for gathering the buttons and casting them all to button_device and adding them to an array of button_devices:
var Buttons : []button_device = array{}
FindButtons():void =
TempButtons := GetCreativeObjectsWithTag(Button{})
var Iterator: int = 0
for(TempButton : TempButtons):
#cast to button
if(ValidButton:= button_device[TempButton]):
#Add to button array
if(set Buttons[Iterator] = ValidButton):
set Iterator += 1
Print("{Buttons.Length} TotalButtons")
Using this code it always Prints the correct length, so I know it collected all the buttons and added them to the array. However, when I then use a simple for loop to go through and disable each button, they will print confirmation that the button was disabled, but not actually disable:
if(Buttons[Num].Disable):
Print("Button {Num} Disabled")
What is most confusing in that when I make the array editable and manually assign the buttons, the same for loop works and they all properly disable. I have brought all this into an empty project and recreated this error, you can go ahead and try for yourself as well.
My question is basically am I doing something wrong here with my code or is this a bug? Are dynamically generated arrays in Verse somehow different than editable ones? Any help is greatly appreciated!